@@ -6,6 +6,7 @@ use arrow_array::{Array, ArrayRef, UnionArray};
66use arrow_buffer:: ScalarBuffer ;
77use arrow_schema:: { DataType , UnionMode } ;
88use geoarrow_schema:: error:: { GeoArrowError , GeoArrowResult } ;
9+ use geoarrow_schema:: type_id:: GeometryTypeId ;
910use geoarrow_schema:: {
1011 CoordType , Dimension , GeoArrowType , GeometryCollectionType , LineStringType ,
1112 MultiLineStringType , MultiPointType , MultiPolygonType , PointType , PolygonType ,
@@ -232,7 +233,7 @@ impl MixedGeometryArray {
232233 // If the array has been sliced, check a point type id still exists
233234 if self . is_sliced ( ) {
234235 for t in self . type_ids . iter ( ) {
235- if * t % 10 == 1 {
236+ if * t % 10 == PointType :: GEOMETRY_TYPE_OFFSET {
236237 return true ;
237238 }
238239 }
@@ -251,7 +252,7 @@ impl MixedGeometryArray {
251252 // If the array has been sliced, check a point type id still exists
252253 if self . is_sliced ( ) {
253254 for t in self . type_ids . iter ( ) {
254- if * t % 10 == 2 {
255+ if * t % 10 == LineStringType :: GEOMETRY_TYPE_OFFSET {
255256 return true ;
256257 }
257258 }
@@ -270,7 +271,7 @@ impl MixedGeometryArray {
270271 // If the array has been sliced, check a point type id still exists
271272 if self . is_sliced ( ) {
272273 for t in self . type_ids . iter ( ) {
273- if * t % 10 == 3 {
274+ if * t % 10 == PolygonType :: GEOMETRY_TYPE_OFFSET {
274275 return true ;
275276 }
276277 }
@@ -289,7 +290,7 @@ impl MixedGeometryArray {
289290 // If the array has been sliced, check a point type id still exists
290291 if self . is_sliced ( ) {
291292 for t in self . type_ids . iter ( ) {
292- if * t % 10 == 4 {
293+ if * t % 10 == MultiPointType :: GEOMETRY_TYPE_OFFSET {
293294 return true ;
294295 }
295296 }
@@ -308,7 +309,7 @@ impl MixedGeometryArray {
308309 // If the array has been sliced, check a point type id still exists
309310 if self . is_sliced ( ) {
310311 for t in self . type_ids . iter ( ) {
311- if * t % 10 == 5 {
312+ if * t % 10 == MultiLineStringType :: GEOMETRY_TYPE_OFFSET {
312313 return true ;
313314 }
314315 }
@@ -327,7 +328,7 @@ impl MixedGeometryArray {
327328 // If the array has been sliced, check a point type id still exists
328329 if self . is_sliced ( ) {
329330 for t in self . type_ids . iter ( ) {
330- if * t % 10 == 6 {
331+ if * t % 10 == MultiPolygonType :: GEOMETRY_TYPE_OFFSET {
331332 return true ;
332333 }
333334 }
@@ -492,15 +493,25 @@ impl MixedGeometryArray {
492493
493494 let expect_msg = "native geometry value access should never error" ;
494495 match type_id % 10 {
495- 1 => Geometry :: Point ( self . points . value ( offset) . expect ( expect_msg) ) ,
496- 2 => Geometry :: LineString ( self . line_strings . value ( offset) . expect ( expect_msg) ) ,
497- 3 => Geometry :: Polygon ( self . polygons . value ( offset) . expect ( expect_msg) ) ,
498- 4 => Geometry :: MultiPoint ( self . multi_points . value ( offset) . expect ( expect_msg) ) ,
499- 5 => {
496+ PointType :: GEOMETRY_TYPE_OFFSET => {
497+ Geometry :: Point ( self . points . value ( offset) . expect ( expect_msg) )
498+ }
499+ LineStringType :: GEOMETRY_TYPE_OFFSET => {
500+ Geometry :: LineString ( self . line_strings . value ( offset) . expect ( expect_msg) )
501+ }
502+ PolygonType :: GEOMETRY_TYPE_OFFSET => {
503+ Geometry :: Polygon ( self . polygons . value ( offset) . expect ( expect_msg) )
504+ }
505+ MultiPointType :: GEOMETRY_TYPE_OFFSET => {
506+ Geometry :: MultiPoint ( self . multi_points . value ( offset) . expect ( expect_msg) )
507+ }
508+ MultiLineStringType :: GEOMETRY_TYPE_OFFSET => {
500509 Geometry :: MultiLineString ( self . multi_line_strings . value ( offset) . expect ( expect_msg) )
501510 }
502- 6 => Geometry :: MultiPolygon ( self . multi_polygons . value ( offset) . expect ( expect_msg) ) ,
503- 7 => {
511+ MultiPolygonType :: GEOMETRY_TYPE_OFFSET => {
512+ Geometry :: MultiPolygon ( self . multi_polygons . value ( offset) . expect ( expect_msg) )
513+ }
514+ GeometryCollectionType :: GEOMETRY_TYPE_OFFSET => {
504515 panic ! ( "nested geometry collections not supported in GeoArrow" )
505516 }
506517 _ => unreachable ! ( "unknown type_id {}" , type_id) ,
@@ -572,7 +583,7 @@ impl TryFrom<(&UnionArray, Dimension, CoordType)> for MixedGeometryArray {
572583 }
573584
574585 match type_id % 10 {
575- 1 => {
586+ PointType :: GEOMETRY_TYPE_OFFSET => {
576587 points = Some (
577588 (
578589 value. child ( type_id) . as_ref ( ) ,
@@ -583,7 +594,7 @@ impl TryFrom<(&UnionArray, Dimension, CoordType)> for MixedGeometryArray {
583594 . unwrap ( ) ,
584595 ) ;
585596 }
586- 2 => {
597+ LineStringType :: GEOMETRY_TYPE_OFFSET => {
587598 line_strings = Some (
588599 (
589600 value. child ( type_id) . as_ref ( ) ,
@@ -594,7 +605,7 @@ impl TryFrom<(&UnionArray, Dimension, CoordType)> for MixedGeometryArray {
594605 . unwrap ( ) ,
595606 ) ;
596607 }
597- 3 => {
608+ PolygonType :: GEOMETRY_TYPE_OFFSET => {
598609 polygons = Some (
599610 (
600611 value. child ( type_id) . as_ref ( ) ,
@@ -605,7 +616,7 @@ impl TryFrom<(&UnionArray, Dimension, CoordType)> for MixedGeometryArray {
605616 . unwrap ( ) ,
606617 ) ;
607618 }
608- 4 => {
619+ MultiPointType :: GEOMETRY_TYPE_OFFSET => {
609620 multi_points = Some (
610621 (
611622 value. child ( type_id) . as_ref ( ) ,
@@ -616,7 +627,7 @@ impl TryFrom<(&UnionArray, Dimension, CoordType)> for MixedGeometryArray {
616627 . unwrap ( ) ,
617628 ) ;
618629 }
619- 5 => {
630+ MultiLineStringType :: GEOMETRY_TYPE_OFFSET => {
620631 multi_line_strings = Some (
621632 (
622633 value. child ( type_id) . as_ref ( ) ,
@@ -627,7 +638,7 @@ impl TryFrom<(&UnionArray, Dimension, CoordType)> for MixedGeometryArray {
627638 . unwrap ( ) ,
628639 ) ;
629640 }
630- 6 => {
641+ MultiPolygonType :: GEOMETRY_TYPE_OFFSET => {
631642 multi_polygons = Some (
632643 (
633644 value. child ( type_id) . as_ref ( ) ,
0 commit comments