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 Polygon.

This commit is contained in:
David Smith 2024-01-31 12:11:16 +00:00 committed by GitHub
parent b9e2a3fc63
commit d3922e9e5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 5 deletions

View File

@ -800,11 +800,13 @@ GEO_CLASSES = {
101: LinearRing, 101: LinearRing,
2001: Point, # POINT M 2001: Point, # POINT M
2002: LineString, # LINESTRING M 2002: LineString, # LINESTRING M
2003: Polygon, # POLYGON M
3001: Point, # POINT ZM 3001: Point, # POINT ZM
3002: LineString, # LINESTRING ZM 3002: LineString, # LINESTRING ZM
3003: Polygon, # POLYGON ZM
1 + OGRGeomType.wkb25bit: Point, # POINT Z 1 + OGRGeomType.wkb25bit: Point, # POINT Z
2 + OGRGeomType.wkb25bit: LineString, # LINESTRING Z 2 + OGRGeomType.wkb25bit: LineString, # LINESTRING Z
3 + OGRGeomType.wkb25bit: Polygon, 3 + OGRGeomType.wkb25bit: Polygon, # POLYGON Z
4 + OGRGeomType.wkb25bit: MultiPoint, 4 + OGRGeomType.wkb25bit: MultiPoint,
5 + OGRGeomType.wkb25bit: MultiLineString, 5 + OGRGeomType.wkb25bit: MultiLineString,
6 + OGRGeomType.wkb25bit: MultiPolygon, 6 + OGRGeomType.wkb25bit: MultiPolygon,

View File

@ -79,8 +79,9 @@ Minor features
``Z`` coordinate dimension. ``Z`` coordinate dimension.
* :class:`~django.contrib.gis.gdal.OGRGeometry`, * :class:`~django.contrib.gis.gdal.OGRGeometry`,
:class:`~django.contrib.gis.gdal.Point`, and :class:`~django.contrib.gis.gdal.Point`,
:class:`~django.contrib.gis.gdal.LineString` now support measured geometries :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 via the new :attr:`.OGRGeometry.is_measured` and ``m`` properties, and the
:meth:`.OGRGeometry.set_measured` method. :meth:`.OGRGeometry.set_measured` method.

View File

@ -674,7 +674,7 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
("Triangle Z", 1017, False), ("Triangle Z", 1017, False),
("Point M", 2001, True), ("Point M", 2001, True),
("LineString M", 2002, True), ("LineString M", 2002, True),
("Polygon M", 2003, False), ("Polygon M", 2003, True),
("MultiPoint M", 2004, False), ("MultiPoint M", 2004, False),
("MultiLineString M", 2005, False), ("MultiLineString M", 2005, False),
("MultiPolygon M", 2006, False), ("MultiPolygon M", 2006, False),
@ -689,7 +689,7 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
("Triangle M", 2017, False), ("Triangle M", 2017, False),
("Point ZM", 3001, True), ("Point ZM", 3001, True),
("LineString ZM", 3002, True), ("LineString ZM", 3002, True),
("Polygon ZM", 3003, False), ("Polygon ZM", 3003, True),
("MultiPoint ZM", 3004, False), ("MultiPoint ZM", 3004, False),
("MultiLineString ZM", 3005, False), ("MultiLineString ZM", 3005, False),
("MultiPolygon ZM", 3006, False), ("MultiPolygon ZM", 3006, False),
@ -915,6 +915,34 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
self.assertIs(geom.is_measured, False) self.assertIs(geom.is_measured, False)
self.assertIs(geom.m, None) self.assertIs(geom.m, None)
def test_polygon_m_dimension(self):
geom = OGRGeometry("POLYGON Z ((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0))")
self.assertIs(geom.is_measured, False)
self.assertEqual(
geom.shell.wkt, "LINEARRING (0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)"
)
geom = OGRGeometry("POLYGON M ((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0))")
self.assertIs(geom.is_measured, True)
self.assertEqual(
geom.shell.wkt, "LINEARRING M (0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)"
)
geom = OGRGeometry(
"POLYGON ZM ((0 0 0 1, 10 0 0 1, 10 10 0 1, 0 10 0 1, 0 0 0 1))"
)
self.assertIs(geom.is_measured, True)
self.assertEqual(
geom.shell.wkt,
"LINEARRING ZM (0 0 0 1,10 0 0 1,10 10 0 1,0 10 0 1,0 0 0 1)",
)
geom.set_measured(False)
self.assertEqual(geom.wkt, "POLYGON ((0 0 0,10 0 0,10 10 0,0 10 0,0 0 0))")
self.assertEqual(
geom.shell.wkt, "LINEARRING (0 0 0,10 0 0,10 10 0,0 10 0,0 0 0)"
)
class DeprecationTests(SimpleTestCase): class DeprecationTests(SimpleTestCase):
def test_coord_setter_deprecation(self): def test_coord_setter_deprecation(self):