From c5ca7e5d73869bc4be10f3b8c854992215c2f540 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 8 Sep 2018 22:42:11 +0200 Subject: [PATCH] Change Map.center.widget SRID to 4326 as it should be By default, a PointField uses a OpenLayersWidget, which forces the SRID to 3857 when casting geojson (no idea why, given geojson SRID is 4326). --- umap/forms.py | 3 ++- umap/tests/test_map_views.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/umap/forms.py b/umap/forms.py index 4a240ff4..10efa09f 100644 --- a/umap/forms.py +++ b/umap/forms.py @@ -63,7 +63,8 @@ class MapSettingsForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(MapSettingsForm, self).__init__(*args, **kwargs) - self.fields["slug"].required = False + self.fields['slug'].required = False + self.fields['center'].widget.map_srid = 4326 def clean_slug(self): slug = self.cleaned_data.get('slug', None) diff --git a/umap/tests/test_map_views.py b/umap/tests/test_map_views.py index f8d7947c..b00b8c67 100644 --- a/umap/tests/test_map_views.py +++ b/umap/tests/test_map_views.py @@ -33,6 +33,8 @@ def test_create(client, user, post_data): created_map = Map.objects.latest('pk') assert j['id'] == created_map.pk assert created_map.name == name + assert created_map.center.x == 13.447265624999998 + assert created_map.center.y == 48.94415123418794 def test_map_create_permissions(client, settings):