Skip to content

Commit 5be9ee5

Browse files
evetionrafaqz
authored andcommitted
Plot LinearRings.
1 parent 4243a43 commit 5be9ee5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

GeoInterfaceRecipes/src/GeoInterfaceRecipes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ RecipesBase.@recipe function f(t::Union{GI.PointTrait,GI.MultiPointTrait}, geom)
3939
_coordvecs(t, geom)
4040
end
4141

42-
RecipesBase.@recipe function f(t::Union{GI.LineStringTrait,GI.MultiLineStringTrait}, geom)
42+
RecipesBase.@recipe function f(t::Union{GI.AbstractLineStringTrait,GI.MultiLineStringTrait}, geom)
4343
seriestype --> :path
4444
_coordvecs(t, geom)
4545
end
@@ -63,7 +63,7 @@ function _coordvecs(::GI.MultiPointTrait, geom)
6363
_geom2coordvecs!(ntuple(_ -> Array{Float64}(undef, n), 2)..., geom)
6464
end
6565
end
66-
function _coordvecs(::GI.LineStringTrait, geom)
66+
function _coordvecs(::GI.AbstractLineStringTrait, geom)
6767
n = GI.npoint(geom)
6868
if GI.is3d(geom)
6969
vecs = ntuple(_ -> Array{Float64}(undef, n), 3)

GeoInterfaceRecipes/test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ abstract type MyAbstractGeom{N} end
88
# Implement interface
99
struct MyPoint{N} <: MyAbstractGeom{N} end
1010
struct MyCurve{N} <: MyAbstractGeom{N} end
11+
struct MyLinearRing{N} <: MyAbstractGeom{N} end
1112
struct MyPolygon{N} <: MyAbstractGeom{N} end
1213
struct MyMultiPoint{N} <: MyAbstractGeom{N} end
1314
struct MyMultiCurve{N} <: MyAbstractGeom{N} end
@@ -31,6 +32,11 @@ GeoInterface.ngeom(::GeoInterface.LineStringTrait, geom::MyCurve) = 3
3132
GeoInterface.getgeom(::GeoInterface.LineStringTrait, geom::MyCurve{N}, i) where {N} = MyPoint{N}()
3233
GeoInterface.convert(::Type{MyCurve}, ::GeoInterface.LineStringTrait, geom) = geom
3334

35+
GeoInterface.geomtrait(::MyLinearRing) = GeoInterface.LinearRingTrait()
36+
GeoInterface.ngeom(::GeoInterface.LinearRingTrait, geom::MyLinearRing) = 3
37+
GeoInterface.getgeom(::GeoInterface.LinearRingTrait, geom::MyLinearRing{N}, i) where {N} = MyPoint{N}()
38+
GeoInterface.convert(::Type{MyLinearRing}, ::GeoInterface.LinearRingTrait, geom) = geom
39+
3440
GeoInterface.geomtrait(::MyPolygon) = GeoInterface.PolygonTrait()
3541
GeoInterface.ngeom(::GeoInterface.PolygonTrait, geom::MyPolygon) = 2
3642
GeoInterface.getgeom(::GeoInterface.PolygonTrait, geom::MyPolygon{N}, i) where {N} = MyCurve{N}()
@@ -53,13 +59,15 @@ GeoInterface.getgeom(::GeoInterface.GeometryCollectionTrait, geom::MyCollection{
5359
# 2d
5460
plot(MyPoint{2}())
5561
plot(MyCurve{2}())
62+
plot(MyLinearRing{2}())
5663
plot(MyMultiPoint{2}())
5764
plot(MyPolygon{2}())
5865
plot(MyMultiPolygon{2}())
5966
plot(MyCollection{2}())
6067
# 3d
6168
plot(MyPoint{3}())
6269
plot(MyCurve{3}())
70+
plot(MyLinearRing{3}())
6371
plot(MyMultiPoint{3}())
6472
plot(MyPolygon{3}())
6573
plot(MyMultiPolygon{3}())

0 commit comments

Comments
 (0)