Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow vectors with mixed single and multi geometries to be plotted in Makie #136

Merged
merged 12 commits into from
Jun 28, 2024

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented Jun 25, 2024

This upstreams GeoMakie.to_multipoly and its variants into GeoInterfaceMakie. Performance needs improvement but this is otherwise ready for review, and I have tested it works.

Usecase:

using NaturalEarth
using CairoMakie

fc = NaturalEarth.naturalearth("admin_0_countries", 10)
plot(fc.geometry)

without any fuss or muss.

Its not actually needed
I have no idea what situation this would occur in though.
This enables running that code snippet when ArchGDAL is also loaded.
@asinghvi17
Copy link
Member Author

asinghvi17 commented Jun 25, 2024

Currently this only allows vectors of (poly, multipoly) or (linestring, multilinestring). Should we also allow GeometryCollections, and just assume that GeoMakie or GeometryOps will do some piracy to allow plotting those, maybe an error hinter or something?

GeoMakie's to_multipoly implementation has such a method but it could also be a GeometryOps extension on GeoInterfaceMakie.

GeoInterfaceMakie/src/GeoInterfaceMakie.jl Outdated Show resolved Hide resolved
GeoInterfaceMakie/src/GeoInterfaceMakie.jl Outdated Show resolved Hide resolved
@rafaqz
Copy link
Member

rafaqz commented Jun 26, 2024

Not sure GeometryOps should get involved here, that's some messy piracy... Why not deal with GeometryCollection here too?

@asinghvi17
Copy link
Member Author

Hmm I guess we can assume gc's are well formed...

@00krishna
Copy link

Do you need any additional input from me @asinghvi17 ? I am good with whatever you choose.

@asinghvi17
Copy link
Member Author

I think this approach is good, only problem is that GeometryBasics doesn't support geometry collections. I guess I'd have to rewrite the logic to check for traits then dispatch accordingly instead of eagerly converting.

@rafaqz
Copy link
Member

rafaqz commented Jun 26, 2024

Can we just convert to vector and hit the other vector methods in this PR?

@asinghvi17
Copy link
Member Author

What do you mean? Just skipping GeometryCollection support?

@rafaqz
Copy link
Member

rafaqz commented Jun 26, 2024

No, just collect GI.getgeom on the geometry collection and call the method again to get Vector dispatch and the Union branch you defined in this PR

@asinghvi17
Copy link
Member Author

For the plot type that ought to work - the problem is that there's no GB convert defined, so the convert_arguments for vectors will fail. Just have to reorder the evaluations and check traits first...

This gets around the GeometryBasics issue of not having a GI.convert.
@asinghvi17 asinghvi17 requested a review from rafaqz June 27, 2024 02:41
@asinghvi17 asinghvi17 merged commit beafb9f into main Jun 28, 2024
10 checks passed
@asinghvi17 asinghvi17 deleted the as/promotegeoms branch June 28, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants