Open jaakkor2 opened 1 year ago
So this is a problem with the GeometryBasics.jl convert
method.
Needs to be changed to:
LineString(Point{dim, Float64}[Point{dim, Float64}(GeoInterface.coordinates(p)) for p in getgeom(geom)])
So the vector type is set even when its empty. In fact most of the vectors in the file need that treatement, e.g.
I looked into this: we need to think about what to do with empty geometries in getgeom
.
It's currently not clear what to return as we don't know the eltype.
We may need to implement at better iterator that has a know eltype even when its empty.
Maybe we could explicitly create an empty geometry for polygon https://github.com/jaakkor2/GeometryBasics.jl/blob/emptypolygon/src/geointerface.jl#L94 and for multipolygon https://github.com/jaakkor2/GeometryBasics.jl/blob/emptypolygon/src/geointerface.jl#L116
But now I am a bit puzzled what the dimension should be since GeometryBasics.ncoord
returns zero for empty polygons.
Yeah, there are a lot of issues with zero length polygons and other geometries.
Base julia uses some dark arts like return value inference to make zero length iterators make sense. We probably don't want to do that. But I think this might need some serious design work to solve this in a general way.
But: does plotting zero length polygons even work in Makie.jl with GeometryBasics.Polygon
??
using GLMakie
using GLMakie.Makie.GeometryBasics
p1 = Polygon(Point2{Float64}[])
p2 = Polygon([Point2(NaN, NaN)])
plot(p1)
errors, but plot(p2)
works.
Ok so what you want isn't possible in Makie unless we do that NaN point hack.
@SimonDanisch any ideas here? should Makie be able to plot zero length polygons?
I've implemented the NaN-point hack for missing geometries in GeoInterfaceMakie (see #139). I guess we could also check whether the geometry is empty or not and then convert appropriately? That's not going in #139 but it could be a separate PR.
gives
with