[GIS] Preserving Curve Geometries in Leaflet

curvedgeojsonleafletsvgwell-known-text

Is there any way to represent a polygon geometry that contains a curve accurately in Leaflet (from WKT)? GeoJSON conversion from WKT is insufficient as it digitizes the points of a curve out to an approximation, it's necessary that curves be preserved as their mathematical representation (read:look circular/curved and not like a series of shortly connected lines at lower zoom levels).

I've checked out arc.js and leaflet-omnivore to start with, but my current thinking is that I would have to parse a WKT string into an SVG element and use either the D3 or RaphaelLayer plugins to properly render the layer while preserving curves. I also have performance concerns going the SVG route because I may have many polygons (hundreds to tens of thousands) to render in any given view.

I did find this old question and have looked into the Leaflet.curve and Leaflet.Arc plugins but I don't think either of them could really apply to what I need (I'm also stuck with Leaflet 0.7x for maintainability reasons which eliminates a lot of plugins).

Anyone else have experience with this or a similar problem and have any suggestions or advice on balancing performance/accuracy of the curves?

Best Answer

Is there any way to represent a polygon geometry that contains a curve accurately in Leaflet (from WKT)?

No.

Leaflet currently does not handle curves (besides L.Circle and L.CircleMarker).

I suggest you have a deep look at https://github.com/Leaflet/Leaflet/blob/master/src/layer/vector/SVG.js and https://github.com/Leaflet/Leaflet/blob/master/src/layer/vector/Polyline.js (among other source files). It should be possible to extend Leaflet's renderers to handle arcs, but that would need modifications across several classes.

Related Question