mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1f6d6c4d9b | ||
![]() |
8a5ad799ce | ||
![]() |
eeaaf0c612 | ||
![]() |
78ee070969 | ||
![]() |
4c9bbb68aa | ||
![]() |
cdc900a9e8 |
10 changed files with 77 additions and 15 deletions
|
@ -1,5 +1,15 @@
|
|||
# Changelog
|
||||
|
||||
## 2.7.3 - 2024-12-10
|
||||
|
||||
### Bug fixes
|
||||
* correctly reset Dialog’s returnValue by @davidbgk in #2356
|
||||
|
||||
## 2.7.2 - 2024-11-15
|
||||
|
||||
### Bug fixes
|
||||
* use our fork of csv2geojson to be able to parse lat/lon with commas
|
||||
|
||||
## 2.7.1 - 2024-10-25
|
||||
|
||||
### Bug fixes
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
"@placemarkio/tokml": "0.3.4",
|
||||
"@tmcw/togeojson": "^5.8.0",
|
||||
"colorbrewer": "1.5.7",
|
||||
"csv2geojson": "5.1.2",
|
||||
"csv2geojson": "github:umap-project/csv2geojson#patched",
|
||||
"dompurify": "3.1.7",
|
||||
"georsstogeojson": "^0.2.0",
|
||||
"jsdom": "^24.0.0",
|
||||
|
|
|
@ -1 +1 @@
|
|||
VERSION = "2.7.1"
|
||||
VERSION = "2.7.3"
|
||||
|
|
|
@ -81,6 +81,8 @@ export class Formatter {
|
|||
{
|
||||
delimiter: 'auto',
|
||||
includeLatLon: false,
|
||||
sexagesimal: false,
|
||||
parseLatLon: (raw) => Number.parseFloat(raw.toString().replace(',', '.')),
|
||||
},
|
||||
(err, result) => {
|
||||
// csv2geojson fallback to null geometries when it cannot determine
|
||||
|
@ -115,7 +117,9 @@ export class Formatter {
|
|||
}
|
||||
|
||||
async fromGeoRSS(str) {
|
||||
const GeoRSSToGeoJSON = await import('../../vendors/georsstogeojson/GeoRSSToGeoJSON.js')
|
||||
const GeoRSSToGeoJSON = await import(
|
||||
'../../vendors/georsstogeojson/GeoRSSToGeoJSON.js'
|
||||
)
|
||||
return GeoRSSToGeoJSON.parse(this.toDom(str))
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,6 @@ export default class Dialog extends WithTemplate {
|
|||
event.preventDefault()
|
||||
this.dialog.returnValue = 'accept'
|
||||
this.close()
|
||||
this.dialog.returnValue = undefined
|
||||
})
|
||||
}
|
||||
this.dialog.addEventListener('keydown', (e) => {
|
||||
|
@ -143,6 +142,7 @@ export default class Dialog extends WithTemplate {
|
|||
|
||||
close() {
|
||||
this.toggle(false)
|
||||
this.dialog.returnValue = undefined
|
||||
}
|
||||
|
||||
toggle(open = false) {
|
||||
|
|
|
@ -81,6 +81,8 @@ function csv2geojson(x, options, callback) {
|
|||
}
|
||||
|
||||
options.delimiter = options.delimiter || ',';
|
||||
options.parseLatLon = options.parseLatLon || parseFloat;
|
||||
options.sexagesimal = options.sexagesimal !== false;
|
||||
|
||||
var latfield = options.latfield || '',
|
||||
lonfield = options.lonfield || '',
|
||||
|
@ -129,6 +131,7 @@ function csv2geojson(x, options, callback) {
|
|||
|
||||
if (!latfield) latfield = guessLatHeader(parsed[0]);
|
||||
if (!lonfield) lonfield = guessLonHeader(parsed[0]);
|
||||
|
||||
var noGeometry = (!latfield || !lonfield);
|
||||
|
||||
if (noGeometry) {
|
||||
|
@ -152,13 +155,15 @@ function csv2geojson(x, options, callback) {
|
|||
lonf, latf,
|
||||
a;
|
||||
|
||||
a = sexagesimal(lonk, 'EW');
|
||||
if (a) lonk = a;
|
||||
a = sexagesimal(latk, 'NS');
|
||||
if (a) latk = a;
|
||||
if (options.sexagesimal) {
|
||||
a = sexagesimal(lonk, 'EW');
|
||||
if (a) lonk = a;
|
||||
a = sexagesimal(latk, 'NS');
|
||||
if (a) latk = a;
|
||||
}
|
||||
|
||||
lonf = parseFloat(lonk);
|
||||
latf = parseFloat(latk);
|
||||
lonf = options.parseLatLon(lonk);
|
||||
latf = options.parseLatLon(latk);
|
||||
|
||||
if (isNaN(lonf) ||
|
||||
isNaN(latf)) {
|
||||
|
@ -179,8 +184,8 @@ function csv2geojson(x, options, callback) {
|
|||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: [
|
||||
parseFloat(lonf),
|
||||
parseFloat(latf)
|
||||
lonf,
|
||||
latf
|
||||
]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import copy
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import factory
|
||||
from django.contrib.auth import get_user_model
|
||||
|
@ -40,7 +41,7 @@ class LicenceFactory(factory.django.DjangoModelFactory):
|
|||
|
||||
class TileLayerFactory(factory.django.DjangoModelFactory):
|
||||
name = "Test zoom layer"
|
||||
url_template = "http://{s}.test.org/{z}/{x}/{y}.png"
|
||||
url_template = "https://{s}.test.org/osmfr/{z}/{x}/{y}.png"
|
||||
attribution = "Test layer attribution"
|
||||
|
||||
class Meta:
|
||||
|
@ -150,3 +151,8 @@ def login_required(response):
|
|||
redirect_url = reverse("login")
|
||||
assert j["login_required"] == redirect_url
|
||||
return True
|
||||
|
||||
|
||||
def mock_tiles(route):
|
||||
path = Path(__file__).parent / "fixtures/empty_tile.png"
|
||||
route.fulfill(path=path)
|
||||
|
|
BIN
umap/tests/fixtures/empty_tile.png
vendored
Normal file
BIN
umap/tests/fixtures/empty_tile.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 103 B |
|
@ -6,6 +6,8 @@ from pathlib import Path
|
|||
import pytest
|
||||
from playwright.sync_api import expect
|
||||
|
||||
from ..base import mock_tiles
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def browser_context_args(browser_context_args):
|
||||
|
@ -23,7 +25,7 @@ def set_timeout(context):
|
|||
@pytest.fixture(autouse=True)
|
||||
def mock_osm_tiles(page):
|
||||
if not bool(os.environ.get("PWDEBUG", False)):
|
||||
page.route("*/**/osmfr/**", lambda route: route.fulfill())
|
||||
page.route("*/**/osmfr/**", mock_tiles)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
@ -10,6 +9,7 @@ from playwright.sync_api import expect
|
|||
|
||||
from umap.models import DataLayer
|
||||
|
||||
from ..base import mock_tiles
|
||||
from .helpers import save_and_get_json
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
@ -72,6 +72,8 @@ def test_umap_import_from_file(live_server, tilelayer, page):
|
|||
|
||||
|
||||
def test_umap_import_from_textarea(live_server, tilelayer, page, settings):
|
||||
page.route("https://tile.openstreetmap.fr/hot/**", mock_tiles)
|
||||
|
||||
settings.UMAP_ALLOW_ANONYMOUS = True
|
||||
page.goto(f"{live_server.url}/map/new/")
|
||||
page.get_by_role("button", name="Open browser").click()
|
||||
|
@ -494,6 +496,39 @@ def test_import_csv_without_valid_latlon_headers(tilelayer, live_server, page):
|
|||
expect(page.locator('umap-alert div[data-level="error"]')).to_be_visible()
|
||||
|
||||
|
||||
def test_import_csv_with_commas_in_latlon(tilelayer, live_server, page, settings):
|
||||
settings.UMAP_ALLOW_ANONYMOUS = True
|
||||
page.goto(f"{live_server.url}/map/new/")
|
||||
page.get_by_title("Open browser").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("lat;lon;foobar\n12,24;48,34;mypoint\n12,23;48,35;mypoint2")
|
||||
page.locator('select[name="format"]').select_option("csv")
|
||||
page.get_by_role("button", name="Import data", exact=True).click()
|
||||
expect(layers).to_have_count(1)
|
||||
expect(markers).to_have_count(2)
|
||||
with page.expect_response(re.compile(r".*/datalayer/create/.*")):
|
||||
page.get_by_role("button", name="Save").click()
|
||||
datalayer = DataLayer.objects.last()
|
||||
saved_data = json.loads(Path(datalayer.geojson.path).read_text())
|
||||
assert saved_data["features"][0]["geometry"] == {
|
||||
"coordinates": [
|
||||
48.35,
|
||||
12.23,
|
||||
],
|
||||
"type": "Point",
|
||||
}
|
||||
assert saved_data["features"][1]["geometry"] == {
|
||||
"coordinates": [
|
||||
48.34,
|
||||
12.24,
|
||||
],
|
||||
"type": "Point",
|
||||
}
|
||||
|
||||
|
||||
def test_create_remote_data(page, live_server, tilelayer):
|
||||
def handle(route):
|
||||
route.fulfill(
|
||||
|
|
Loading…
Reference in a new issue