Ticket #21003: patch-widget-srid.patch​

File patch-widget-srid.patch​, 1.5 KB (added by Mathieu Leplatre, 11 years ago)

Fix if widget srid != field srid

Line 
1diff --git a/django/contrib/gis/forms/fields.py b/django/contrib/gis/forms/fields.py
2index 59e7259..b76de72 100644
3--- a/django/contrib/gis/forms/fields.py
4+++ b/django/contrib/gis/forms/fields.py
5@@ -48,7 +48,7 @@ class GeometryField(forms.Field):
6 if value in self.empty_values:
7 return None
8 try:
9- return GEOSGeometry(value)
10+ return GEOSGeometry(value, self.widget.map_srid)
11 except (GEOSException, ValueError, TypeError):
12 raise forms.ValidationError(self.error_messages['invalid_geom'], code='invalid_geom')
13
14@@ -92,7 +92,7 @@ class GeometryField(forms.Field):
15
16 # Only do a geographic comparison if both values are available
17 if initial and data:
18- data = fromstr(data)
19+ data = fromstr(data, self.widget.map_srid)
20 data.transform(initial.srid)
21 # If the initial value was not added by the browser, the geometry
22 # provided may be slightly different, the first time it is saved.
23diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py
24index 0102ab6..b6f5f92 100644
25--- a/django/contrib/gis/forms/widgets.py
26+++ b/django/contrib/gis/forms/widgets.py
27@@ -39,7 +39,7 @@ class BaseGeometryWidget(Widget):
28
29 def deserialize(self, value):
30 try:
31- return GEOSGeometry(value)
32+ return GEOSGeometry(value, self.map_srid)
33 except (GEOSException, ValueError) as err:
34 logger.error(
35 "Error creating geometry from value '%s' (%s)" % (
Back to Top