Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Random cool stuff I've been hacking on (mostly spatial indices)

Random cool stuff I've been hacking on (mostly spatial indices)

JSGeo 2017, August 15th

Vladimir Agafonkin

August 15, 2017
Tweet

More Decks by Vladimir Agafonkin

Other Decks in Programming

Transcript

  1. hello, friends!

    View full-size slide

  2. random cool stuff
    I’ve been hacking on
    JSGeo, August 15th 2017
    Vlad
    (mostly spatial indices)

    View full-size slide

  3. github.com/mourner/rbush

    View full-size slide

  4. finding nearest neighbors

    View full-size slide

  5. • rendering and querying shapes in OpenLayers

    • processing shapes in MapShaper

    • placing labels and handling annotations in iD
    OpenStreetMap editor

    • interactive plotting in Bokeh
    real time apps

    View full-size slide

  6. • deriving road speed profiles and live traffic from
    telemetry data

    • deriving lane geometry, turn restrictions, one-way
    roads, sidewalks from telemetry data

    • detecting and fixing issues in OSM data

    • comparing road networks (e.g. OSM vs TIGER)
    map matching / processing

    View full-size slide

  7. map matching / processing
    • matching Wikidata against OSM for geocoding

    • TurfJS modules like line-intersect, line-split, line-
    overlap, dissolve, mask, collect

    • matching features against polygons (e.g.
    administrative classification)

    • concaveman: generating an outline of a point set

    View full-size slide

  8. github.com/mapbox/tile-reduce

    View full-size slide

  9. osmlab.github.io/osm-qa-tiles

    View full-size slide

  10. which polygon?

    View full-size slide

  11. github.com/mapbox/which-polygon

    View full-size slide

  12. github.com/mapbox/linematch

    View full-size slide

  13. buffer, union, difference: slow

    View full-size slide

  14. github.com/mapbox/linematch
    freaking fast

    View full-size slide

  15. github.com/mapbox/lineclip
    freaking fast

    View full-size slide

  16. github.com/mourner/rbush-knn

    View full-size slide

  17. distance from a point to a bounding box

    View full-size slide

  18. distance from a segment to a bounding box

    View full-size slide

  19. github.com/mapbox/concaveman

    View full-size slide

  20. github.com/mapbox/concaveman

    View full-size slide

  21. github.com/mourner/kdbush

    View full-size slide

  22. github.com/mourner/kdbush
    •supports points only (not boxes)

    •can’t add/remove points dynamically

    •indexing is 5–8 times faster

    View full-size slide

  23. github.com/mapbox/supercluster

    View full-size slide

  24. github.com/mapbox/supercluster

    View full-size slide

  25. geodesic nearest neighbors?

    View full-size slide

  26. distance from a point to a bounding box
    on a sphere?!

    View full-size slide

  27. bbox on a sphere

    View full-size slide

  28. convert to 3D coords?

    View full-size slide

  29. convert to 3D coords?
    •can’t use the same index for bounding
    box queries

    •imprecise for bigger distances

    •indexing and querying can be slow

    View full-size slide

  30. when you found a use for differential math
    for the first time in a 13-year career

    View full-size slide

  31. github.com/mourner/geokdbush

    View full-size slide

  32. measuring distances fast

    View full-size slide

  33. measuring distances fast

    View full-size slide

  34. euclidean geometry with lat/lon

    View full-size slide

  35. euclidean geometry with lat/lon

    View full-size slide

  36. github.com/mapbox/cheap-ruler
    •distance

    •bearing

    •destination

    •lineDistance

    •area

    •along
    •pointOnLine

    •lineSlice

    •lineSliceAlong

    •bufferPoint

    •bufferBBox

    •insideBBox
    freaking
    fast!

    View full-size slide

  37. github.com/mapbox/earcut

    View full-size slide

  38. github.com/mapbox/delaunator

    View full-size slide

  39. github.com/mapbox/alpha-shake
    coming soon…

    View full-size slide

  40. github.com/mapbox/polysnap
    coming soon…
    my long-time nemesis

    View full-size slide

  41. github.com/mapbox/geobuf
    GeoJSON <–> compact binary
    lossless &
    freaking fast!

    View full-size slide

  42. github.com/mapbox/webgl-wind

    View full-size slide

  43. awesome job alert:
    GL Map Rendering Engineer
    grnh.se/7g6l4h1

    View full-size slide