@@ -20,6 +20,15 @@ GeoInterface.geomtrait(::MultiPolygon) = MultiPolygonTrait()
2020GeoInterface. geomtrait (:: Ngon ) = PolygonTrait ()
2121GeoInterface. geomtrait (:: AbstractMesh ) = PolyhedralSurfaceTrait ()
2222
23+ # GeoInterface calls this method in `GeoInterface.convert(GeometryBasics, ...)`
24+ geointerface_geomtype (:: GeoInterface.PointTrait ) = Point
25+ geointerface_geomtype (:: GeoInterface.MultiPointTrait ) = MultiPoint
26+ geointerface_geomtype (:: GeoInterface.LineStringTrait ) = LineString
27+ geointerface_geomtype (:: GeoInterface.MultiLineStringTrait ) = MultiLineString
28+ geointerface_geomtype (:: GeoInterface.PolygonTrait ) = Polygon
29+ geointerface_geomtype (:: GeoInterface.MultiPolygonTrait ) = MultiPolygon
30+ geointerface_geomtype (:: GeoInterface.PolyhedralSurfaceTrait ) = Mesh
31+
2332GeoInterface. geomtrait (:: Simplex{Dim,T,1} ) where {Dim,T} = PointTrait ()
2433GeoInterface. geomtrait (:: Simplex{Dim,T,2} ) where {Dim,T} = LineStringTrait ()
2534GeoInterface. geomtrait (:: Simplex{Dim,T,3} ) where {Dim,T} = PolygonTrait ()
@@ -30,7 +39,9 @@ GeoInterface.getcoord(::PointTrait, g::Point, i::Int) = g[i]
3039GeoInterface. ngeom (:: LineTrait , g:: Line ) = length (g)
3140GeoInterface. getgeom (:: LineTrait , g:: Line , i:: Int ) = g[i]
3241
33- GeoInterface. ngeom (:: LineStringTrait , g:: LineString ) = length (g) # n line segments + 1
42+
43+ GeoInterface. ngeom (:: LineStringTrait , g:: LineString ) = length (g) + 1 # n line segments + 1
44+ GeoInterface. ncoord (:: LineStringTrait , g:: LineString{Dim} ) where {Dim} = Dim
3445function GeoInterface. getgeom (:: LineStringTrait , g:: LineString , i:: Int )
3546 return GeometryBasics. coordinates (g)[i]
3647end
@@ -52,6 +63,7 @@ function GeoInterface.getgeom(::MultiLineStringTrait, g::MultiLineString,
5263 i:: Int )
5364 return g[i]
5465end
66+ GeoInterface. ncoord (:: MultiLineStringTrait , g:: MultiLineString{Dim} ) where {Dim} = Dim
5567
5668GeoInterface. ngeom (:: MultiPolygonTrait , g:: MultiPolygon ) = length (g)
5769GeoInterface. getgeom (:: MultiPolygonTrait , g:: MultiPolygon , i:: Int ) = g[i]
@@ -80,12 +92,12 @@ GeoInterface.getgeom(::PolyhedralSurfaceTrait, g::AbstractMesh, i) = g[i]
8092
8193function GeoInterface. convert (:: Type{Point} , type:: PointTrait , geom)
8294 dim = Int (ncoord (geom))
83- return Point {dim} (GeoInterface. coordinates (geom))
95+ return Point {dim, Float64 } (GeoInterface. coordinates (geom))
8496end
8597
8698function GeoInterface. convert (:: Type{LineString} , type:: LineStringTrait , geom)
8799 dim = Int (ncoord (geom))
88- return LineString ([Point {dim} (GeoInterface. coordinates (p)) for p in getgeom (geom)])
100+ return LineString ([Point {dim, Float64 } (GeoInterface. coordinates (p)) for p in getgeom (geom)])
89101end
90102
91103function GeoInterface. convert (:: Type{Polygon} , type:: PolygonTrait , geom)
101113
102114function GeoInterface. convert (:: Type{MultiPoint} , type:: MultiPointTrait , geom)
103115 dim = Int (ncoord (geom))
104- return MultiPoint ([Point {dim} (GeoInterface. coordinates (p)) for p in getgeom (geom)])
116+ return MultiPoint ([Point {dim, Float64 } (GeoInterface. coordinates (p)) for p in getgeom (geom)])
105117end
106118
107119function GeoInterface. convert (:: Type{MultiLineString} , type:: MultiLineStringTrait , geom)
0 commit comments