diff options
| author | David Smith <smithdc@gmail.com> | 2023-12-22 17:21:08 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-12-27 11:40:28 +0100 |
| commit | 21b0b23a67ee1aa1a35f7f64cd8fe997e4de89d7 (patch) | |
| tree | 00f7bc43cefb4127fc8bd9d85c174d6707c92935 /django | |
| parent | 7c26dbf6ef9415f873ae43f12e6ab3742857c898 (diff) | |
Refs #35058 -- Made OGRGeomType aware of additional WKB geometry types.
This commit increases OGRGeomType's knowledge of WKB types and allows
for improved error messages when Django doesn't yet have a corresponding
class to wrap a given type.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/gdal/geometries.py | 4 | ||||
| -rw-r--r-- | django/contrib/gis/gdal/geomtype.py | 48 | ||||
| -rw-r--r-- | django/contrib/gis/geometry.py | 4 |
3 files changed, 54 insertions, 2 deletions
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index f74dc688b3..5094413642 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -123,7 +123,9 @@ class OGRGeometry(GDALBase): self.srs = srs # Setting the class depending upon the OGR Geometry Type - self.__class__ = GEO_CLASSES[self.geom_type.num] + if (geo_class := GEO_CLASSES.get(self.geom_type.num)) is None: + raise TypeError(f"Unsupported geometry type: {self.geom_type}") + self.__class__ = geo_class # Pickle routines def __getstate__(self): diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 6f342b3c96..c8c4703a82 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -16,9 +16,57 @@ class OGRGeomType: 5: "MultiLineString", 6: "MultiPolygon", 7: "GeometryCollection", + 8: "CircularString", + 9: "CompoundCurve", + 10: "CurvePolygon", + 11: "MultiCurve", + 12: "MultiSurface", + 15: "PolyhedralSurface", + 16: "TIN", + 17: "Triangle", 100: "None", 101: "LinearRing", 102: "PointZ", + 1008: "CircularStringZ", + 1009: "CompoundCurveZ", + 1010: "CurvePolygonZ", + 1011: "MultiCurveZ", + 1012: "MultiSurfaceZ", + 1013: "CurveZ", + 1014: "SurfaceZ", + 1015: "PolyhedralSurfaceZ", + 1016: "TINZ", + 1017: "TriangleZ", + 2001: "PointM", + 2002: "LineStringM", + 2003: "PolygonM", + 2004: "MultiPointM", + 2005: "MultiLineStringM", + 2006: "MultiPolygonM", + 2007: "GeometryCollectionM", + 2008: "CircularStringM", + 2009: "CompoundCurveM", + 2010: "CurvePolygonM", + 2011: "MultiCurveM", + 2012: "MultiSurfaceM", + 2015: "PolyhedralSurfaceM", + 2016: "TINM", + 2017: "TriangleM", + 3001: "PointZM", + 3002: "LineStringZM", + 3003: "PolygonZM", + 3004: "MultiPointZM", + 3005: "MultiLineStringZM", + 3006: "MultiPolygonZM", + 3007: "GeometryCollectionZM", + 3008: "CircularStringZM", + 3009: "CompoundCurveZM", + 3010: "CurvePolygonZM", + 3011: "MultiCurveZM", + 3012: "MultiSurfaceZM", + 3015: "PolyhedralSurfaceZM", + 3016: "TINZM", + 3017: "TriangleZM", 1 + wkb25bit: "Point25D", 2 + wkb25bit: "LineString25D", 3 + wkb25bit: "Polygon25D", diff --git a/django/contrib/gis/geometry.py b/django/contrib/gis/geometry.py index b5caf04be4..7aac8644ee 100644 --- a/django/contrib/gis/geometry.py +++ b/django/contrib/gis/geometry.py @@ -10,7 +10,9 @@ wkt_regex = _lazy_re_compile( r"^(SRID=(?P<srid>\-?[0-9]+);)?" r"(?P<wkt>" r"(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|" - r"MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)" + r"MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION|CIRCULARSTRING|COMPOUNDCURVE|" + r"CURVEPOLYGON|MULTICURVE|MULTISURFACE|CURVE|SURFACE|POLYHEDRALSURFACE|TIN|" + r"TRIANGLE)" r"[ACEGIMLONPSRUTYZ0-9,.+() -]+)$", re.I, ) |
