@@ -61,26 +61,43 @@ function _lower(obj)
61
61
)
62
62
return _add_bbox (GI. extent (obj), base)
63
63
elseif GI. isgeometry (obj)
64
- _lower (GI. geomtrait (obj), obj)
64
+ if GI. is3d (obj)
65
+ _lower (GI. geomtrait (obj), Val {true} (), obj)
66
+ else
67
+ _lower (GI. geomtrait (obj), Val {false} (), obj)
68
+ end
65
69
else
66
70
# null geometry
67
71
nothing
68
72
end
69
73
end
70
- _lower (:: GI.AbstractPointTrait , obj) = (type= " Point" , coordinates= GI. coordinates (obj))
71
- _lower (:: GI.AbstractLineStringTrait , obj) =
72
- (type= " LineString" , coordinates= GI. coordinates (obj))
73
- _lower (:: GI.AbstractPolygonTrait , obj) =
74
- (type= " Polygon" , coordinates= GI. coordinates (obj))
75
- _lower (:: GI.AbstractMultiPointTrait , obj) =
76
- (type= " MultiPoint" , coordinates= GI. coordinates (obj))
77
- _lower (:: GI.AbstractMultiLineStringTrait , obj) =
78
- (type= " Polygon" , coordinates= GI. coordinates (obj))
79
- _lower (:: GI.AbstractMultiPolygonTrait , obj) =
80
- (type= " MultiPolygon" , coordinates= collect (GI. coordinates (obj)))
81
- _lower (:: GI.AbstractGeometryCollectionTrait , obj) =
74
+ _lower (t:: GI.AbstractPointTrait , d, obj) =
75
+ (type= " Point" , coordinates= _to_vector_ntuple (t, d, obj))
76
+ _lower (t:: GI.AbstractLineStringTrait , d, obj) =
77
+ (type= " LineString" , coordinates= _to_vector_ntuple (t, d, obj))
78
+ _lower (t:: GI.AbstractPolygonTrait , d, obj) =
79
+ (type= " Polygon" , coordinates= _to_vector_ntuple (t, d, obj))
80
+ _lower (t:: GI.AbstractMultiPointTrait , d, obj) =
81
+ (type= " MultiPoint" , coordinates= _to_vector_ntuple (t, d, obj))
82
+ _lower (t:: GI.AbstractMultiLineStringTrait , d, obj) =
83
+ (type= " Polygon" , coordinates= _to_vector_ntuple (t, d, obj))
84
+ _lower (t:: GI.AbstractMultiPolygonTrait , d, obj) =
85
+ (type= " MultiPolygon" , coordinates= _to_vector_ntuple (t, d, obj))
86
+ _lower (t:: GI.AbstractGeometryCollectionTrait , d, obj) =
82
87
(type= " GeometryCollection" , geometries= _lower .(GI. getgeom (obj)))
83
88
89
+ function _to_vector_ntuple (:: GI.PointTrait , is3d:: Val{false} , geom)
90
+ (GI. x (geom), GI. y (geom))
91
+ end
92
+ function _to_vector_ntuple (:: GI.PointTrait , is3d:: Val{true} , geom)
93
+ (GI. x (geom), GI. y (geom), GI. z (geom))
94
+ end
95
+ function _to_vector_ntuple (:: GI.AbstractGeometryTrait , is3d, geom)
96
+ map (GI. getgeom (geom)) do child_geom
97
+ _to_vector_ntuple (GI. geomtrait (child_geom), is3d, child_geom)
98
+ end
99
+ end
100
+
84
101
_add_bbox (:: Nothing , nt:: NamedTuple ) = nt
85
102
function _add_bbox (ext:: Extents.Extent , nt:: NamedTuple )
86
103
if haskey (ext, :Z )
0 commit comments