csv plugin: also detect lat/lon/long field names as likely geometry columns

This commit is contained in:
Dane Springmeyer 2011-10-18 19:27:23 -07:00
parent 14c29379bf
commit 90154e0a1a
6 changed files with 24 additions and 5 deletions

View file

@ -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;

View file

@ -0,0 +1,2 @@
latitude,longitude
0,0
1 latitude longitude
2 0 0

View file

@ -0,0 +1,2 @@
this_is_longitude_yo,this_is_latitude_yo
0,0
1 this_is_longitude_yo this_is_latitude_yo
2 0 0

View file

@ -0,0 +1,2 @@
lon,lat
0,0
1 lon lat
2 0 0

View file

@ -0,0 +1,2 @@
long,lat
0,0
1 long lat
2 0 0

2
tests/data/csv/x_y.csv Normal file
View file

@ -0,0 +1,2 @@
x,y
0,0
1 x y
2 0 0