Merge pull request #1753 from umap-project/msg-no-csv-header
feat: display a message when importer cannot find lat/lng columns
This commit is contained in:
commit
65e226ff1c
2 changed files with 29 additions and 2 deletions
|
@ -947,6 +947,17 @@ U.DataLayer = L.Evented.extend({
|
||||||
includeLatLon: false,
|
includeLatLon: false,
|
||||||
},
|
},
|
||||||
(err, result) => {
|
(err, result) => {
|
||||||
|
// csv2geojson fallback to null geometries when it cannot determine
|
||||||
|
// lat or lon columns. This is valid geojson, but unwanted from a user
|
||||||
|
// point of view.
|
||||||
|
if (result && result.features.length) {
|
||||||
|
if (result.features[0].geometry === null) {
|
||||||
|
err = {
|
||||||
|
type: 'Error',
|
||||||
|
message: L._('Cannot determine latitude and longitude columns.'),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
let message
|
let message
|
||||||
if (err.type === 'Error') {
|
if (err.type === 'Error') {
|
||||||
|
|
|
@ -431,3 +431,19 @@ def test_import_multipolyline(live_server, page, tilelayer):
|
||||||
# A layer has been created
|
# A layer has been created
|
||||||
expect(layers).to_have_count(1)
|
expect(layers).to_have_count(1)
|
||||||
expect(paths).to_have_count(1)
|
expect(paths).to_have_count(1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_import_csv_without_valid_latlon_headers(tilelayer, live_server, page):
|
||||||
|
page.goto(f"{live_server.url}/map/new/")
|
||||||
|
page.get_by_title("See layers").click()
|
||||||
|
layers = page.locator(".umap-browser .datalayer")
|
||||||
|
markers = page.locator(".leaflet-marker-icon")
|
||||||
|
page.get_by_title("Import data").click()
|
||||||
|
textarea = page.locator(".umap-upload textarea")
|
||||||
|
textarea.fill("a,b,c\n12.23,48.34,mypoint\n12.23,48.34,mypoint2")
|
||||||
|
page.locator('select[name="format"]').select_option("csv")
|
||||||
|
page.get_by_role("button", name="Import", exact=True).click()
|
||||||
|
# FIXME do not create a layer
|
||||||
|
expect(layers).to_have_count(1)
|
||||||
|
expect(markers).to_have_count(0)
|
||||||
|
expect(page.locator(".umap-alert")).to_be_visible()
|
||||||
|
|
Loading…
Reference in a new issue