Skip to content

Commit 222bf29

Browse files
smithdc1felixxm
authored andcommitted
Refs #35058 -- Added support for measured geometries to GDAL GeometryCollection and subclasses.
1 parent f8ff61c commit 222bf29

File tree

3 files changed

+49
-16
lines changed

3 files changed

+49
-16
lines changed

django/contrib/gis/gdal/geometries.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,14 +801,22 @@ class MultiPolygon(GeometryCollection):
801801
2001: Point, # POINT M
802802
2002: LineString, # LINESTRING M
803803
2003: Polygon, # POLYGON M
804+
2004: MultiPoint, # MULTIPOINT M
805+
2005: MultiLineString, # MULTILINESTRING M
806+
2006: MultiPolygon, # MULTIPOLYGON M
807+
2007: GeometryCollection, # GEOMETRYCOLLECTION M
804808
3001: Point, # POINT ZM
805809
3002: LineString, # LINESTRING ZM
806810
3003: Polygon, # POLYGON ZM
811+
3004: MultiPoint, # MULTIPOINT ZM
812+
3005: MultiLineString, # MULTILINESTRING ZM
813+
3006: MultiPolygon, # MULTIPOLYGON ZM
814+
3007: GeometryCollection, # GEOMETRYCOLLECTION ZM
807815
1 + OGRGeomType.wkb25bit: Point, # POINT Z
808816
2 + OGRGeomType.wkb25bit: LineString, # LINESTRING Z
809817
3 + OGRGeomType.wkb25bit: Polygon, # POLYGON Z
810-
4 + OGRGeomType.wkb25bit: MultiPoint,
811-
5 + OGRGeomType.wkb25bit: MultiLineString,
812-
6 + OGRGeomType.wkb25bit: MultiPolygon,
813-
7 + OGRGeomType.wkb25bit: GeometryCollection,
818+
4 + OGRGeomType.wkb25bit: MultiPoint, # MULTIPOINT Z
819+
5 + OGRGeomType.wkb25bit: MultiLineString, # MULTILINESTRING Z
820+
6 + OGRGeomType.wkb25bit: MultiPolygon, # MULTIPOLYGON Z
821+
7 + OGRGeomType.wkb25bit: GeometryCollection, # GEOMETRYCOLLECTION Z
814822
}

docs/releases/5.1.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ Minor features
8181

8282
* :class:`~django.contrib.gis.gdal.OGRGeometry`,
8383
:class:`~django.contrib.gis.gdal.Point`,
84-
:class:`~django.contrib.gis.gdal.LineString`, and
85-
:class:`~django.contrib.gis.gdal.Polygon` now support measured geometries
86-
via the new :attr:`.OGRGeometry.is_measured` and ``m`` properties, and the
87-
:meth:`.OGRGeometry.set_measured` method.
84+
:class:`~django.contrib.gis.gdal.LineString`,
85+
:class:`~django.contrib.gis.gdal.Polygon`, and
86+
:class:`~django.contrib.gis.gdal.GeometryCollection` and its subclasses now
87+
support measured geometries via the new :attr:`.OGRGeometry.is_measured` and
88+
``m`` properties, and the :meth:`.OGRGeometry.set_measured` method.
8889

8990
* :attr:`.OGRGeometry.centroid` is now available on all supported geometry
9091
types.

tests/gis_tests/gdal_tests/test_geom.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,10 @@ def test_geometry_types(self):
675675
("Point M", 2001, True),
676676
("LineString M", 2002, True),
677677
("Polygon M", 2003, True),
678-
("MultiPoint M", 2004, False),
679-
("MultiLineString M", 2005, False),
680-
("MultiPolygon M", 2006, False),
681-
("GeometryCollection M", 2007, False),
678+
("MultiPoint M", 2004, True),
679+
("MultiLineString M", 2005, True),
680+
("MultiPolygon M", 2006, True),
681+
("GeometryCollection M", 2007, True),
682682
("CircularString M", 2008, False),
683683
("CompoundCurve M", 2009, False),
684684
("CurvePolygon M", 2010, False),
@@ -690,10 +690,10 @@ def test_geometry_types(self):
690690
("Point ZM", 3001, True),
691691
("LineString ZM", 3002, True),
692692
("Polygon ZM", 3003, True),
693-
("MultiPoint ZM", 3004, False),
694-
("MultiLineString ZM", 3005, False),
695-
("MultiPolygon ZM", 3006, False),
696-
("GeometryCollection ZM", 3007, False),
693+
("MultiPoint ZM", 3004, True),
694+
("MultiLineString ZM", 3005, True),
695+
("MultiPolygon ZM", 3006, True),
696+
("GeometryCollection ZM", 3007, True),
697697
("CircularString ZM", 3008, False),
698698
("CompoundCurve ZM", 3009, False),
699699
("CurvePolygon ZM", 3010, False),
@@ -943,6 +943,30 @@ def test_polygon_m_dimension(self):
943943
geom.shell.wkt, "LINEARRING (0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)"
944944
)
945945

946+
def test_multi_geometries_m_dimension(self):
947+
tests = [
948+
"MULTIPOINT M ((10 40 10), (40 30 10), (20 20 10))",
949+
"MULTIPOINT ZM ((10 40 0 10), (40 30 1 10), (20 20 1 10))",
950+
"MULTILINESTRING M ((10 10 1, 20 20 2),(40 40 1, 30 30 2))",
951+
"MULTILINESTRING ZM ((10 10 0 1, 20 20 0 2),(40 40 1, 30 30 0 2))",
952+
(
953+
"MULTIPOLYGON ZM (((30 20 1 0, 45 40 1 0, 30 20 1 0)),"
954+
"((15 5 0 0, 40 10 0 0, 15 5 0 0)))"
955+
),
956+
(
957+
"GEOMETRYCOLLECTION M (POINT M (40 10 0),"
958+
"LINESTRING M (10 10 0, 20 20 0, 10 40 0))"
959+
),
960+
(
961+
"GEOMETRYCOLLECTION ZM (POINT ZM (40 10 0 1),"
962+
"LINESTRING ZM (10 10 1 0, 20 20 1 0, 10 40 1 0))"
963+
),
964+
]
965+
for geom_input in tests:
966+
with self.subTest(geom_input=geom_input):
967+
geom = OGRGeometry(geom_input)
968+
self.assertIs(geom.is_measured, True)
969+
946970

947971
class DeprecationTests(SimpleTestCase):
948972
def test_coord_setter_deprecation(self):

0 commit comments

Comments
 (0)