5

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?

1 Answer 1

2

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.

1
  • thanks for pointing me to those, I'll take a look. If there is one thing I have plenty of experience with it's extending existing functionality.
    – 4xle
    Commented Mar 10, 2017 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.