diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index c1a8a0b4a..88a3cad62 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -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; diff --git a/tests/data/csv/latitude_longitude.csv b/tests/data/csv/latitude_longitude.csv new file mode 100644 index 000000000..109e3464e --- /dev/null +++ b/tests/data/csv/latitude_longitude.csv @@ -0,0 +1,2 @@ +latitude,longitude +0,0 \ No newline at end of file diff --git a/tests/data/csv/latitude_longitude_substring.csv b/tests/data/csv/latitude_longitude_substring.csv new file mode 100644 index 000000000..4cd85d82d --- /dev/null +++ b/tests/data/csv/latitude_longitude_substring.csv @@ -0,0 +1,2 @@ +this_is_longitude_yo,this_is_latitude_yo +0,0 \ No newline at end of file diff --git a/tests/data/csv/lon_lat.csv b/tests/data/csv/lon_lat.csv new file mode 100644 index 000000000..5ce2fc929 --- /dev/null +++ b/tests/data/csv/lon_lat.csv @@ -0,0 +1,2 @@ +lon,lat +0,0 \ No newline at end of file diff --git a/tests/data/csv/long_lat.csv b/tests/data/csv/long_lat.csv new file mode 100644 index 000000000..77be88561 --- /dev/null +++ b/tests/data/csv/long_lat.csv @@ -0,0 +1,2 @@ +long,lat +0,0 \ No newline at end of file diff --git a/tests/data/csv/x_y.csv b/tests/data/csv/x_y.csv new file mode 100644 index 000000000..d436ff3b7 --- /dev/null +++ b/tests/data/csv/x_y.csv @@ -0,0 +1,2 @@ +x,y +0,0 \ No newline at end of file