csv plugin: also detect lat/lon/long field names as likely geometry columns
This commit is contained in:
parent
14c29379bf
commit
90154e0a1a
6 changed files with 24 additions and 5 deletions
|
@ -115,7 +115,6 @@ void csv_datasource::bind() const
|
|||
parse_csv(in,escape_, separator_, quote_);
|
||||
in.close();
|
||||
}
|
||||
|
||||
is_bound_ = true;
|
||||
}
|
||||
|
||||
|
@ -257,12 +256,17 @@ void csv_datasource::parse_csv(T& stream,
|
|||
wkt_idx = idx;
|
||||
has_wkt_field = true;
|
||||
}
|
||||
if (lower_val == "x" || (lower_val.find("longitude") != std::string::npos))
|
||||
if (lower_val == "x"
|
||||
|| lower_val == "lon"
|
||||
|| lower_val == "long"
|
||||
|| (lower_val.find("longitude") != std::string::npos))
|
||||
{
|
||||
lon_idx = idx;
|
||||
has_lon_field = true;
|
||||
}
|
||||
if (lower_val == "y" || (lower_val.find("latitude") != std::string::npos))
|
||||
if (lower_val == "y"
|
||||
|| lower_val == "lat"
|
||||
|| (lower_val.find("latitude") != std::string::npos))
|
||||
{
|
||||
lat_idx = idx;
|
||||
has_lat_field = true;
|
||||
|
@ -311,12 +315,17 @@ void csv_datasource::parse_csv(T& stream,
|
|||
wkt_idx = idx;
|
||||
has_wkt_field = true;
|
||||
}
|
||||
if (lower_val == "x" || (lower_val.find("longitude") != std::string::npos))
|
||||
if (lower_val == "x"
|
||||
|| lower_val == "lon"
|
||||
|| lower_val == "long"
|
||||
|| (lower_val.find("longitude") != std::string::npos))
|
||||
{
|
||||
lon_idx = idx;
|
||||
has_lon_field = true;
|
||||
}
|
||||
if (lower_val == "y" || (lower_val.find("latitude") != std::string::npos))
|
||||
if (lower_val == "y"
|
||||
|| lower_val == "lat"
|
||||
|| (lower_val.find("latitude") != std::string::npos))
|
||||
{
|
||||
lat_idx = idx;
|
||||
has_lat_field = true;
|
||||
|
|
2
tests/data/csv/latitude_longitude.csv
Normal file
2
tests/data/csv/latitude_longitude.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
latitude,longitude
|
||||
0,0
|
|
2
tests/data/csv/latitude_longitude_substring.csv
Normal file
2
tests/data/csv/latitude_longitude_substring.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
this_is_longitude_yo,this_is_latitude_yo
|
||||
0,0
|
|
2
tests/data/csv/lon_lat.csv
Normal file
2
tests/data/csv/lon_lat.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
lon,lat
|
||||
0,0
|
|
2
tests/data/csv/long_lat.csv
Normal file
2
tests/data/csv/long_lat.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
long,lat
|
||||
0,0
|
|
2
tests/data/csv/x_y.csv
Normal file
2
tests/data/csv/x_y.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
x,y
|
||||
0,0
|
|
Loading…
Reference in a new issue