@@ -4,8 +4,8 @@ GeoInterface.isgeometry(::Type{<:AbstractGeometry}) = true
4
4
GeoInterface. isgeometry (:: Type{<:AbstractFace} ) = true
5
5
GeoInterface. isgeometry (:: Type{<:AbstractPoint} ) = true
6
6
GeoInterface. isgeometry (:: Type{<:AbstractMesh} ) = true
7
- GeoInterface. isgeometry (:: Type{<:AbstractLineString} ) = true
8
7
GeoInterface. isgeometry (:: Type{<:AbstractPolygon} ) = true
8
+ GeoInterface. isgeometry (:: Type{<:LineString} ) = true
9
9
GeoInterface. isgeometry (:: Type{<:MultiPoint} ) = true
10
10
GeoInterface. isgeometry (:: Type{<:MultiLineString} ) = true
11
11
GeoInterface. isgeometry (:: Type{<:MultiPolygon} ) = true
@@ -92,13 +92,29 @@ GeoInterface.ngeom(::PolyhedralSurfaceTrait, g::AbstractMesh) = length(g)
92
92
GeoInterface. getgeom (:: PolyhedralSurfaceTrait , g:: AbstractMesh , i) = g[i]
93
93
94
94
function GeoInterface. convert (:: Type{Point} , type:: PointTrait , geom)
95
- dim = Int (ncoord (geom))
96
- return Point {dim, Float64} (GeoInterface. coordinates (geom))
95
+ x, y = GeoInterface. x (geom), GeoInterface. y (geom)
96
+ if GeoInterface. is3d (geom)
97
+ z = GeoInterface. z (geom)
98
+ T = promote_type (typeof (x), typeof (y), typeof (z))
99
+ return Point {3,T} (x, y, z)
100
+ else
101
+ GeoInterface. x (geom), GeoInterface. y (geom)
102
+ T = promote_type (typeof (x), typeof (y))
103
+ return Point {2,T} (x, y)
104
+ end
97
105
end
98
106
99
107
function GeoInterface. convert (:: Type{LineString} , type:: LineStringTrait , geom)
100
- dim = Int (ncoord (geom))
101
- return LineString ([Point {dim, Float64} (GeoInterface. coordinates (p)) for p in getgeom (geom)])
108
+ g1 = getgeom (geom, 1 )
109
+ x, y = GeoInterface. x (g1), GeoInterface. y (g1)
110
+ if GeoInterface. is3d (geom)
111
+ z = GeoInterface. z (g1)
112
+ T = promote_type (typeof (x), typeof (y), typeof (z))
113
+ return LineString ([Point {3,T} (GeoInterface. x (p), GeoInterface. y (p), GeoInterface. z (p)) for p in getgeom (geom)])
114
+ else
115
+ T = promote_type (typeof (x), typeof (y))
116
+ return LineString ([Point {2,T} (GeoInterface. x (p), GeoInterface. y (p)) for p in getgeom (geom)])
117
+ end
102
118
end
103
119
104
120
function GeoInterface. convert (:: Type{Polygon} , type:: PolygonTrait , geom)
@@ -113,8 +129,16 @@ function GeoInterface.convert(::Type{Polygon}, type::PolygonTrait, geom)
113
129
end
114
130
115
131
function GeoInterface. convert (:: Type{MultiPoint} , type:: MultiPointTrait , geom)
116
- dim = Int (ncoord (geom))
117
- return MultiPoint ([Point {dim, Float64} (GeoInterface. coordinates (p)) for p in getgeom (geom)])
132
+ g1 = getgeom (geom, 1 )
133
+ x, y = GeoInterface. x (g1), GeoInterface. y (g1)
134
+ if GeoInterface. is3d (geom)
135
+ z = GeoInterface. z (g1)
136
+ T = promote_type (typeof (x), typeof (y), typeof (z))
137
+ return MultiPoint ([Point {3,T} (GeoInterface. x (p), GeoInterface. y (p), GeoInterface. z (p)) for p in getgeom (geom)])
138
+ else
139
+ T = promote_type (typeof (x), typeof (y))
140
+ return MultiPoint ([Point {2,T} (GeoInterface. x (p), GeoInterface. y (p)) for p in getgeom (geom)])
141
+ end
118
142
end
119
143
120
144
function GeoInterface. convert (:: Type{MultiLineString} , type:: MultiLineStringTrait , geom)
0 commit comments