@@ -4,8 +4,8 @@ GeoInterface.isgeometry(::Type{<:AbstractGeometry}) = true
44GeoInterface. isgeometry (:: Type{<:AbstractFace} ) = true
55GeoInterface. isgeometry (:: Type{<:AbstractPoint} ) = true
66GeoInterface. isgeometry (:: Type{<:AbstractMesh} ) = true
7- GeoInterface. isgeometry (:: Type{<:AbstractLineString} ) = true
87GeoInterface. isgeometry (:: Type{<:AbstractPolygon} ) = true
8+ GeoInterface. isgeometry (:: Type{<:LineString} ) = true
99GeoInterface. isgeometry (:: Type{<:MultiPoint} ) = true
1010GeoInterface. isgeometry (:: Type{<:MultiLineString} ) = true
1111GeoInterface. isgeometry (:: Type{<:MultiPolygon} ) = true
@@ -92,13 +92,29 @@ GeoInterface.ngeom(::PolyhedralSurfaceTrait, g::AbstractMesh) = length(g)
9292GeoInterface. getgeom (:: PolyhedralSurfaceTrait , g:: AbstractMesh , i) = g[i]
9393
9494function 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
97105end
98106
99107function 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
102118end
103119
104120function GeoInterface. convert (:: Type{Polygon} , type:: PolygonTrait , geom)
@@ -113,8 +129,16 @@ function GeoInterface.convert(::Type{Polygon}, type::PolygonTrait, geom)
113129end
114130
115131function 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
118142end
119143
120144function GeoInterface. convert (:: Type{MultiLineString} , type:: MultiLineStringTrait , geom)
0 commit comments