Mapbox-gl-js: Rendering curved lines

Created on 16 Jul 2018  路  2Comments  路  Source: mapbox/mapbox-gl-js

Motivation

Both the GeoJSON and vector tile specifications encode line geometry as discrete points, with straight line segments connecting them. This is a great, lightweight format to store and render geometry, but makes it difficult to render curves, either when

1) we want actual curves, or
2) when we want to draw complex, organic shapes with minimal number of vertices. Curves would allow us to approximate the original line by applying smoothening on the render side.

https://github.com/mapbox/mapbox-gl-js/issues/981 and https://github.com/mapbox/mapbox-gl-js/issues/4180 are related, except they're for camera movements

Design Alternatives

My current workaround is simply to manipulate the source geometry (via turf.bezierSpline and the like), adding more vertices to improve perceived smoothness.

Design

The current workflow is not ideal, because it

1) can greatly bloat the size of the line geometry, and
2) is never actually infinitely smooth (as far as the current screen resolution allows)

Preliminary reading suggests that this is possible on the rendering side, possibly more efficiently than by data manipulation.

Mock-Up

Some kind of line-bezier property, with dimensionless values like in CSS, or resolution and sharpness, or something else.

feature needs discussion

Most helpful comment

is this feature (or any kind of curve smoothing) planned for the near future?

All 2 comments

is this feature (or any kind of curve smoothing) planned for the near future?

This has been proposed in the vector tile spec and is being tracked at https://github.com/mapbox/vector-tile-spec/issues/114. There are no current plans to incorporate this into GL-JS separate from that spec.

Was this page helpful?
0 / 5 - 0 ratings