1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #35058 -- Added support for measured geometries to GDAL GeometryCollection and subclasses.

This commit is contained in:
David Smith 2024-02-12 07:50:08 +00:00 committed by Mariusz Felisiak
parent f8ff61c77e
commit 222bf2932b
3 changed files with 49 additions and 16 deletions

View File

@ -801,14 +801,22 @@ GEO_CLASSES = {
2001: Point, # POINT M
2002: LineString, # LINESTRING M
2003: Polygon, # POLYGON M
2004: MultiPoint, # MULTIPOINT M
2005: MultiLineString, # MULTILINESTRING M
2006: MultiPolygon, # MULTIPOLYGON M
2007: GeometryCollection, # GEOMETRYCOLLECTION M
3001: Point, # POINT ZM
3002: LineString, # LINESTRING ZM
3003: Polygon, # POLYGON ZM
3004: MultiPoint, # MULTIPOINT ZM
3005: MultiLineString, # MULTILINESTRING ZM
3006: MultiPolygon, # MULTIPOLYGON ZM
3007: GeometryCollection, # GEOMETRYCOLLECTION ZM
1 + OGRGeomType.wkb25bit: Point, # POINT Z
2 + OGRGeomType.wkb25bit: LineString, # LINESTRING Z
3 + OGRGeomType.wkb25bit: Polygon, # POLYGON Z
4 + OGRGeomType.wkb25bit: MultiPoint,
5 + OGRGeomType.wkb25bit: MultiLineString,
6 + OGRGeomType.wkb25bit: MultiPolygon,
7 + OGRGeomType.wkb25bit: GeometryCollection,
4 + OGRGeomType.wkb25bit: MultiPoint, # MULTIPOINT Z
5 + OGRGeomType.wkb25bit: MultiLineString, # MULTILINESTRING Z
6 + OGRGeomType.wkb25bit: MultiPolygon, # MULTIPOLYGON Z
7 + OGRGeomType.wkb25bit: GeometryCollection, # GEOMETRYCOLLECTION Z
}

View File

@ -81,10 +81,11 @@ Minor features
* :class:`~django.contrib.gis.gdal.OGRGeometry`,
:class:`~django.contrib.gis.gdal.Point`,
:class:`~django.contrib.gis.gdal.LineString`, and
:class:`~django.contrib.gis.gdal.Polygon` now support measured geometries
via the new :attr:`.OGRGeometry.is_measured` and ``m`` properties, and the
:meth:`.OGRGeometry.set_measured` method.
:class:`~django.contrib.gis.gdal.LineString`,
:class:`~django.contrib.gis.gdal.Polygon`, and
:class:`~django.contrib.gis.gdal.GeometryCollection` and its subclasses now
support measured geometries via the new :attr:`.OGRGeometry.is_measured` and
``m`` properties, and the :meth:`.OGRGeometry.set_measured` method.
* :attr:`.OGRGeometry.centroid` is now available on all supported geometry
types.

View File

@ -675,10 +675,10 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
("Point M", 2001, True),
("LineString M", 2002, True),
("Polygon M", 2003, True),
("MultiPoint M", 2004, False),
("MultiLineString M", 2005, False),
("MultiPolygon M", 2006, False),
("GeometryCollection M", 2007, False),
("MultiPoint M", 2004, True),
("MultiLineString M", 2005, True),
("MultiPolygon M", 2006, True),
("GeometryCollection M", 2007, True),
("CircularString M", 2008, False),
("CompoundCurve M", 2009, False),
("CurvePolygon M", 2010, False),
@ -690,10 +690,10 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
("Point ZM", 3001, True),
("LineString ZM", 3002, True),
("Polygon ZM", 3003, True),
("MultiPoint ZM", 3004, False),
("MultiLineString ZM", 3005, False),
("MultiPolygon ZM", 3006, False),
("GeometryCollection ZM", 3007, False),
("MultiPoint ZM", 3004, True),
("MultiLineString ZM", 3005, True),
("MultiPolygon ZM", 3006, True),
("GeometryCollection ZM", 3007, True),
("CircularString ZM", 3008, False),
("CompoundCurve ZM", 3009, False),
("CurvePolygon ZM", 3010, False),
@ -943,6 +943,30 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
geom.shell.wkt, "LINEARRING (0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)"
)
def test_multi_geometries_m_dimension(self):
tests = [
"MULTIPOINT M ((10 40 10), (40 30 10), (20 20 10))",
"MULTIPOINT ZM ((10 40 0 10), (40 30 1 10), (20 20 1 10))",
"MULTILINESTRING M ((10 10 1, 20 20 2),(40 40 1, 30 30 2))",
"MULTILINESTRING ZM ((10 10 0 1, 20 20 0 2),(40 40 1, 30 30 0 2))",
(
"MULTIPOLYGON ZM (((30 20 1 0, 45 40 1 0, 30 20 1 0)),"
"((15 5 0 0, 40 10 0 0, 15 5 0 0)))"
),
(
"GEOMETRYCOLLECTION M (POINT M (40 10 0),"
"LINESTRING M (10 10 0, 20 20 0, 10 40 0))"
),
(
"GEOMETRYCOLLECTION ZM (POINT ZM (40 10 0 1),"
"LINESTRING ZM (10 10 1 0, 20 20 1 0, 10 40 1 0))"
),
]
for geom_input in tests:
with self.subTest(geom_input=geom_input):
geom = OGRGeometry(geom_input)
self.assertIs(geom.is_measured, True)
class DeprecationTests(SimpleTestCase):
def test_coord_setter_deprecation(self):