Skip to content

Commit 8d1266f

Browse files
jw3126visr
authored andcommitted
fix Makie plotting LibGEOS MultiLineString shows additional lines #83
1 parent 827af7c commit 8d1266f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

GeoInterfaceMakie/src/GeoInterfaceMakie.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ basicsgeomtype(::GI.MultiPolygonTrait) = GB.MultiPolygon
6262
basicsgeomtype(::GI.LineStringTrait) = GB.LineString
6363
basicsgeomtype(::GI.MultiLineStringTrait) = GB.MultiLineString
6464

65-
function _convert_arguments(::Type{<:MC.Poly}, geom)::Tuple
65+
function _convert_arguments(t::Type{<:MC.Poly}, geom)::Tuple
6666
geob = basicsgeom(geom)::Union{GB.Polygon, GB.MultiPolygon}
67-
(geob,)
67+
MC.convert_arguments(t,geob)
68+
end
69+
function _convert_arguments(t::Type{<:MC.Lines}, geom)::Tuple
70+
geob = basicsgeom(geom)
71+
MC.convert_arguments(t, geob)
6872
end
6973
function _convert_arguments(::MC.PointBased, geom)::Tuple
7074
pts = points(geom)
@@ -82,6 +86,9 @@ function expr_enable(Geom)
8286
function $MC.convert_arguments(p::$MC.PointBased, geom::$Geom)
8387
$_convert_arguments(p,geom)
8488
end
89+
function $MC.convert_arguments(p::Type{<:$MC.Lines}, geom::$Geom)
90+
$_convert_arguments(p,geom)
91+
end
8592
end
8693
end
8794

GeoInterfaceMakie/test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ GeoInterfaceMakie.@enable(LibGEOS.AbstractGeometry)
2222
]
2323
end
2424

25+
@testset "Makie plotting LibGEOS MultiLineString shows additional lines #83" begin
26+
mls = readgeom("MULTILINESTRING ((0 0,3 0,3 3,0 3,0 0),(1 1,2 1,2 2,1 2,1 1))")
27+
expected = [[0.0, 0.0], [3.0, 0.0], [3.0, 3.0], [0.0, 3.0], [0.0, 0.0],
28+
[NaN, NaN],
29+
[1.0, 1.0], [2.0, 1.0], [2.0, 2.0], [1.0, 2.0], [1.0, 1.0]]
30+
31+
@test isequal(Makie.convert_arguments(Makie.Lines, mls), (expected,))
32+
end
33+
2534
@testset "smoketest 2d" begin
2635
unitsquare = readgeom("POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))")
2736
bigsquare = readgeom("POLYGON((0 0, 11 0, 11 11, 0 11, 0 0))")

0 commit comments

Comments
 (0)