Maximkaaa / galileo

General purpose cross-platform GIS-rendering library written in Rust
Apache License 2.0
357 stars 22 forks source link

Feature Request: Mutable Map Projections #80

Open Dunrar opened 3 weeks ago

Dunrar commented 3 weeks ago

Hi, very cool project! Would it be possible to implement dynamic/mutable map projections for feature layers?

Use cases include:

Some examples of other tools that allow similar things:

Maximkaaa commented 2 weeks ago

This is definitely something Galileo has to know how to do. But I'm not sure how useful just having setter on the CRS field in FeatuerLayer would be. This is because with current approach all the caches would have to be dropped in a CRS changes, which is basically same as creating a new FeatureLayer with old one's data and new CRS. And this would work the same way as mapbox does. I would really like Galileo to look more like Bernies demo, with smooth transitions between projections. (Not sure how to implement it though...)

Having said that, I would accept a PR that makes crs field settable in the FeatureLayer for now.

Dunrar commented 2 weeks ago

Great to hear that you think this is in the scope of Galileo!

Wouldn't we need to set the crs field of the MapView, though?

Maximkaaa commented 2 weeks ago

Yes, you are right. crs in the FeatureLayer specifies the CRS of the input data, crs in the MapView is the displayed one. But then, changing it requires resetting all layer's caches... And thinking about that, currently tile layers do not know how to reproject data, if I remember correctly. So if we implement this, currently it would work only for feature layers.

Dunrar commented 1 week ago

In the lambert.rs demo I tried to simply set the Crs of the Map (or rather its MapView) in the .with_event_handler() closure. This does work in some ways, hovering now highlights the countries as if the map were already re-projected. The change does not propagate to the actual render though, even after calling map.redraw(). Before I look into this any further, do you have an idea why this might be the case? Thanks!

Maximkaaa commented 1 week ago

This is because FeatureLayer caches the result of projection/rendering operation, but it does not detect that the CRS has changes and does not invalidate the cache.