Skip to content

Commit 3ec16b8

Browse files
authored
Add geointerface_geomtypes as a method (#189)
* Add geointerface_geomtypes Should get GeoInterface.convert(GeometryBasics, ...) working. Needs testing. * test converts to GeometryBasics
1 parent db65c41 commit 3ec16b8

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/geointerface.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ GeoInterface.geomtrait(::MultiPolygon) = MultiPolygonTrait()
2020
GeoInterface.geomtrait(::Ngon) = PolygonTrait()
2121
GeoInterface.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+
2332
GeoInterface.geomtrait(::Simplex{Dim,T,1}) where {Dim,T} = PointTrait()
2433
GeoInterface.geomtrait(::Simplex{Dim,T,2}) where {Dim,T} = LineStringTrait()
2534
GeoInterface.geomtrait(::Simplex{Dim,T,3}) where {Dim,T} = PolygonTrait()

test/geointerface.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ end
7070
multipolygon_json = GeoJSON.read(multipolygon_str)
7171
multipolygon_hole_json = GeoJSON.read(multipolygon_hole_str)
7272

73-
point_gb = GeoInterface.convert(Point, point_json)
74-
point_3d_gb = GeoInterface.convert(Point, point_3d_json)
75-
linestring_gb = GeoInterface.convert(LineString, linestring_json)
76-
polygon_gb = GeoInterface.convert(Polygon, polygon_json)
77-
polygon_hole_gb = GeoInterface.convert(Polygon, polygon_hole_json)
78-
multipoint_gb = GeoInterface.convert(MultiPoint, multipoint_json)
79-
multilinestring_gb = GeoInterface.convert(MultiLineString, multilinestring_json)
80-
multipolygon_gb = GeoInterface.convert(MultiPolygon, multipolygon_json)
81-
multipolygon_hole_gb = GeoInterface.convert(MultiPolygon, multipolygon_hole_json)
73+
point_gb = GeoInterface.convert(GeometryBasics, point_json)
74+
point_3d_gb = GeoInterface.convert(GeometryBasics, point_3d_json)
75+
linestring_gb = GeoInterface.convert(GeometryBasics, linestring_json)
76+
polygon_gb = GeoInterface.convert(GeometryBasics, polygon_json)
77+
polygon_hole_gb = GeoInterface.convert(GeometryBasics, polygon_hole_json)
78+
multipoint_gb = GeoInterface.convert(GeometryBasics, multipoint_json)
79+
multilinestring_gb = GeoInterface.convert(GeometryBasics, multilinestring_json)
80+
multipolygon_gb = GeoInterface.convert(GeometryBasics, multipolygon_json)
81+
multipolygon_hole_gb = GeoInterface.convert(GeometryBasics, multipolygon_hole_json)
8282

8383
@test point_gb === Point{2, Float64}(30.1, 10.1)
8484
@test point_3d_gb === Point{3, Float64}(30.1, 10.1, 5.1)

0 commit comments

Comments
 (0)