@@ -35,7 +35,7 @@ def test_geomtype(self):
35
35
with self .assertRaises (GDALException ):
36
36
OGRGeomType ("fooD" )
37
37
with self .assertRaises (GDALException ):
38
- OGRGeomType (9 )
38
+ OGRGeomType (4001 )
39
39
40
40
# Equivalence can take strings, ints, and other OGRGeomTypes
41
41
self .assertEqual (OGRGeomType (1 ), OGRGeomType (1 ))
@@ -635,3 +635,82 @@ def test_empty(self):
635
635
def test_empty_point_to_geos (self ):
636
636
p = OGRGeometry ("POINT EMPTY" , srs = 4326 )
637
637
self .assertEqual (p .geos .ewkt , p .ewkt )
638
+
639
+ def test_geometry_types (self ):
640
+ tests = [
641
+ ("Point" , 1 , True ),
642
+ ("LineString" , 2 , True ),
643
+ ("Polygon" , 3 , True ),
644
+ ("MultiPoint" , 4 , True ),
645
+ ("Multilinestring" , 5 , True ),
646
+ ("MultiPolygon" , 6 , True ),
647
+ ("GeometryCollection" , 7 , True ),
648
+ ("CircularString" , 8 , False ),
649
+ ("CompoundCurve" , 9 , False ),
650
+ ("CurvePolygon" , 10 , False ),
651
+ ("MultiCurve" , 11 , False ),
652
+ ("MultiSurface" , 12 , False ),
653
+ # 13 (Curve) and 14 (Surface) are abstract types.
654
+ ("PolyhedralSurface" , 15 , False ),
655
+ ("TIN" , 16 , False ),
656
+ ("Triangle" , 17 , False ),
657
+ ("Linearring" , 2 , True ),
658
+ # Types 1 - 7 with Z dimension have 2.5D enums.
659
+ ("Point Z" , - 2147483647 , True ), # 1001
660
+ ("LineString Z" , - 2147483646 , True ), # 1002
661
+ ("Polygon Z" , - 2147483645 , True ), # 1003
662
+ ("MultiPoint Z" , - 2147483644 , True ), # 1004
663
+ ("Multilinestring Z" , - 2147483643 , True ), # 1005
664
+ ("MultiPolygon Z" , - 2147483642 , True ), # 1006
665
+ ("GeometryCollection Z" , - 2147483641 , True ), # 1007
666
+ ("CircularString Z" , 1008 , False ),
667
+ ("CompoundCurve Z" , 1009 , False ),
668
+ ("CurvePolygon Z" , 1010 , False ),
669
+ ("MultiCurve Z" , 1011 , False ),
670
+ ("MultiSurface Z" , 1012 , False ),
671
+ ("PolyhedralSurface Z" , 1015 , False ),
672
+ ("TIN Z" , 1016 , False ),
673
+ ("Triangle Z" , 1017 , False ),
674
+ ("Point M" , 2001 , False ),
675
+ ("LineString M" , 2002 , False ),
676
+ ("Polygon M" , 2003 , False ),
677
+ ("MultiPoint M" , 2004 , False ),
678
+ ("MultiLineString M" , 2005 , False ),
679
+ ("MultiPolygon M" , 2006 , False ),
680
+ ("GeometryCollection M" , 2007 , False ),
681
+ ("CircularString M" , 2008 , False ),
682
+ ("CompoundCurve M" , 2009 , False ),
683
+ ("CurvePolygon M" , 2010 , False ),
684
+ ("MultiCurve M" , 2011 , False ),
685
+ ("MultiSurface M" , 2012 , False ),
686
+ ("PolyhedralSurface M" , 2015 , False ),
687
+ ("TIN M" , 2016 , False ),
688
+ ("Triangle M" , 2017 , False ),
689
+ ("Point ZM" , 3001 , False ),
690
+ ("LineString ZM" , 3002 , False ),
691
+ ("Polygon ZM" , 3003 , False ),
692
+ ("MultiPoint ZM" , 3004 , False ),
693
+ ("MultiLineString ZM" , 3005 , False ),
694
+ ("MultiPolygon ZM" , 3006 , False ),
695
+ ("GeometryCollection ZM" , 3007 , False ),
696
+ ("CircularString ZM" , 3008 , False ),
697
+ ("CompoundCurve ZM" , 3009 , False ),
698
+ ("CurvePolygon ZM" , 3010 , False ),
699
+ ("MultiCurve ZM" , 3011 , False ),
700
+ ("MultiSurface ZM" , 3012 , False ),
701
+ ("PolyhedralSurface ZM" , 3015 , False ),
702
+ ("TIN ZM" , 3016 , False ),
703
+ ("Triangle ZM" , 3017 , False ),
704
+ ]
705
+
706
+ for test in tests :
707
+ geom_type , num , supported = test
708
+ with self .subTest (geom_type = geom_type , num = num , supported = supported ):
709
+ if supported :
710
+ g = OGRGeometry (f"{ geom_type } EMPTY" )
711
+ self .assertEqual (g .geom_type .num , num )
712
+ else :
713
+ type_ = geom_type .replace (" " , "" )
714
+ msg = f"Unsupported geometry type: { type_ } "
715
+ with self .assertRaisesMessage (TypeError , msg ):
716
+ OGRGeometry (f"{ geom_type } EMPTY" )
0 commit comments