mapbox-java icon indicating copy to clipboard operation
mapbox-java copied to clipboard

Add Turf buffer method

Open danesfeder opened this issue 6 years ago • 7 comments

Turf.js has a Turf#buffer method that would be useful for defining offline map regions. An example use case in navigation would be defining a buffer around a route geometry for an offline download:

buffer

@zugaldia mentioned that this may not be a straightforward port to java, possibly necessitating bringing in a third party library to get the job done. We need to look into this a bit further / discuss if that makes sense.

cc @osana @kevinkreiser

danesfeder avatar Apr 02 '19 14:04 danesfeder

Thanks @danesfeder for cutting this ticket.

The old JS Turf Buffer implementation used https://github.com/bjornharrtell/jsts which is in turn a port of the Java library https://github.com/locationtech/jts. The latest JS Turf buffer seems to use something different (d3-geo?). I'd love to use this ticket to understand our options:

  • Implement buffer from scratch
  • Bring in JTS
  • Bring in another library (to be researched)

Particularly in terms of size implications. We're trying to keep MAS lightweight and this might require adding a separate artifact.

zugaldia avatar Apr 02 '19 14:04 zugaldia

Based on https://github.com/Turfjs/turf/blob/master/packages/turf-buffer/index.js#L1, I believe we'll also need to port center() before we can add the buffer method. buffer() could also unlock cool visuals like 👇 (Off the top of my head, I'm not sure how they're creating the white FillLayer area right now without buffer() 🤔 ). GIF is from the Flyover Country app: https://play.google.com/store/apps/details?id=com.ionicframework.app303739&hl=en_US

ezgif com-resize

langsmith avatar Apr 22 '19 18:04 langsmith

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

stale[bot] avatar Oct 19 '19 20:10 stale[bot]

Based on https://github.com/Turfjs/turf/blob/master/packages/turf-buffer/index.js#L1, I believe we'll also need to port center() before we can add the buffer method

Porting the center method is moving at https://github.com/mapbox/mapbox-java/pull/1150

langsmith avatar May 22 '20 21:05 langsmith

Having this buffer method would also help with detecting whether a line has been clicked on. For example, selecting an alternate route that the Mapbox Navigation SDK displays.

Rather than having to click exactly on the line, we could use the click lat/lng, the buffer Polygon, and the Java SDK's TurfJoins.inside() method.

langsmith avatar Sep 09 '20 22:09 langsmith

@1ec5 @MaximAlien curious, how does iOS plan to support the UI to select an alternate route?

zugaldia avatar Sep 10 '20 20:09 zugaldia

@1ec5 @MaximAlien curious, how does iOS plan to support the UI to select an alternate route?

Current implementation of alternative route selection involves conversion of tapped point to coordinate. Alternative routes are then sorted by distance to tapped coordinate (there is minimum threshold as well).

Some examples of this logic can be found here and here.

MaximAlien avatar Sep 10 '20 20:09 MaximAlien