diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 68e67999..ac93f8ca 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -463,8 +463,8 @@ U.Layer.Heat = L.HeatLayer.extend({ this._latlngs[i].alt !== undefined ? this._latlngs[i].alt : this._latlngs[i][2] !== undefined - ? +this._latlngs[i][2] - : 1 + ? +this._latlngs[i][2] + : 1 grid[y] = grid[y] || [] cell = grid[y][x] @@ -947,6 +947,17 @@ U.DataLayer = L.Evented.extend({ includeLatLon: false, }, (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) { let message if (err.type === 'Error') { diff --git a/umap/tests/integration/test_import.py b/umap/tests/integration/test_import.py index 1be5ffd6..6320965c 100644 --- a/umap/tests/integration/test_import.py +++ b/umap/tests/integration/test_import.py @@ -431,3 +431,19 @@ def test_import_multipolyline(live_server, page, tilelayer): # A layer has been created expect(layers).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()