File tree Expand file tree Collapse file tree 4 files changed +6
-10
lines changed
tests/django_restframework_gis_tests Expand file tree Collapse file tree 4 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ This field takes four optional arguments:
9797- ``auto_bbox ``: If ``True ``, the GeoJSON object will include
9898 a `bounding box <https://datatracker.ietf.org/doc/html/rfc7946#section-5 >`_,
9999 which is the smallest possible rectangle enclosing the geometry.
100- - ``transform `` (defaults to ``4326 ``): If ``None `` (or the input geometry does not have
100+ - ``transform `` (defaults to ``None ``): If ``None `` (or the input geometry does not have
101101 a SRID), the GeoJSON's coordinates will not be transformed. If any other `spatial
102102 reference <https://docs.djangoproject.com/en/5.0/ref/contrib/gis/geos/#django.contrib.gis.geos.GEOSGeometry.transform> `,
103103 the GeoJSON's coordinates will be transformed correspondingly.
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ def __init__(
2222 precision = None ,
2323 remove_duplicates = False ,
2424 auto_bbox = False ,
25- transform = 4326 ,
25+ transform = None ,
2626 ** kwargs ,
2727 ):
2828 """
@@ -41,11 +41,7 @@ def to_representation(self, value):
4141 # we expect value to be a GEOSGeometry instance
4242 if value .geojson :
4343 # NOTE: For repeated transformations a gdal.CoordTransform is recommended
44- if (
45- self .transform is not None
46- and value .srid is not None
47- and value .srid != 4326
48- ):
44+ if self .transform is not None and value .srid is not None :
4945 value .transform (self .transform )
5046
5147 geojson = GeoJsonDict (value .geojson )
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ class Meta:
5858class OtherSridLocationGeoSerializer (gis_serializers .GeoFeatureModelSerializer ):
5959 """Other SRID location geo serializer"""
6060
61- geometry = GeometryField (auto_bbox = True )
61+ geometry = GeometryField (auto_bbox = True , transform = 4326 )
6262
6363 class Meta :
6464 model = OtherSridLocation
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ def test_transform_Point_no_srid(self):
196196 def test_transform_Point_to_4326 (self ):
197197 model = self .get_instance (Point31287 )
198198 model .geometry .srid = 31287
199- Serializer = self .create_serializer ()
199+ Serializer = self .create_serializer (transform = 4326 )
200200 data = Serializer (model ).data
201201
202202 expected_coords = (16.372500007573713 , 48.20833306345481 )
@@ -222,7 +222,7 @@ def test_transform_Point_to_3857(self):
222222 def test_transform_Point_bbox_to_4326 (self ):
223223 model = self .get_instance (Point31287 )
224224 model .geometry .srid = 31287
225- Serializer = self .create_serializer (auto_bbox = True )
225+ Serializer = self .create_serializer (auto_bbox = True , transform = 4326 )
226226 data = Serializer (model ).data
227227
228228 expected_coords = (
You can’t perform that action at this time.
0 commit comments