Skip to content

Commit 3f8b0fd

Browse files
committed
fix Polygon initialization
1 parent 62b2605 commit 3f8b0fd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

django_mongodb_backend_gis/features.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def django_test_expected_failures(self):
2929
"gis_tests.geoapp.tests.GeoModelTest.test_gis_query_as_string",
3030
# No lookups are supported (yet?)
3131
"gis_tests.geoapp.tests.GeoLookupTest.test_gis_lookups_with_complex_expressions",
32-
# LinearRing requires at least 4 points, got 1.
33-
"gis_tests.geoapp.tests.GeoLookupTest.test_null_geometries",
34-
"gis_tests.geoapp.tests.GeoModelTest.test_geometryfield",
3532
# Trying to remove spatial index fails:
3633
# "index not found with name [gis_neighborhood_geom_id]"
3734
"gis_tests.gis_migrations.test_operations.OperationTests.test_alter_field_remove_spatial_index",

django_mongodb_backend_gis/operations.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ def converter(value, expression, connection): # noqa: ARG001
7474
geom_class = getattr(geos, value["type"])
7575
if geom_class.__name__ == "GeometryCollection":
7676
return geom_class(
77-
[getattr(geos, v["type"])(v["coordinates"]) for v in value["geometries"]],
77+
[
78+
getattr(geos, v["type"])(
79+
*v["coordinates"] if v["type"] == "Polygon" else v["coordinates"]
80+
)
81+
for v in value["geometries"]
82+
],
7883
srid=4326,
7984
)
8085
if issubclass(geom_class, geos.GeometryCollection):
@@ -88,6 +93,8 @@ def converter(value, expression, connection): # noqa: ARG001
8893
],
8994
srid=4326,
9095
)
96+
if geom_class.__name__ == "Polygon":
97+
return geom_class(*value["coordinates"], srid=4326)
9198
return geom_class(value["coordinates"], srid=4326)
9299

93100
return converter

0 commit comments

Comments
 (0)