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 Slide

  2. View Slide

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

    View Slide

  4. github.com/mourner/rbush

    View Slide

  5. box queries

    View Slide

  6. finding nearest neighbors

    View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. • 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 Slide

  12. • 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 Slide

  13. 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 Slide

  14. github.com/mapbox/tile-reduce

    View Slide

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

    View Slide

  16. tile-reduce

    View Slide

  17. which polygon?

    View Slide

  18. github.com/mapbox/which-polygon

    View Slide

  19. github.com/mapbox/linematch

    View Slide

  20. buffer, union, difference: slow

    View Slide

  21. github.com/mapbox/linematch
    freaking fast

    View Slide

  22. github.com/mapbox/lineclip
    freaking fast

    View Slide

  23. github.com/mourner/rbush-knn

    View Slide

  24. distance from a point to a bounding box

    View Slide

  25. distance from a segment to a bounding box

    View Slide

  26. github.com/mapbox/concaveman

    View Slide

  27. github.com/mapbox/concaveman

    View Slide

  28. github.com/mourner/kdbush

    View Slide

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

    •can’t add/remove points dynamically

    •indexing is 5–8 times faster

    View Slide

  30. github.com/mapbox/supercluster

    View Slide

  31. github.com/mapbox/supercluster

    View Slide

  32. View Slide

  33. geodesic nearest neighbors?

    View Slide

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

    View Slide

  35. bbox on a sphere

    View Slide

  36. View Slide

  37. convert to 3D coords?

    View Slide

  38. 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 Slide

  39. View Slide

  40. View Slide

  41. View Slide

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

    View Slide

  43. github.com/mourner/geokdbush

    View Slide

  44. measuring distances fast

    View Slide

  45. measuring distances fast

    View Slide

  46. euclidean geometry with lat/lon

    View Slide

  47. euclidean geometry with lat/lon

    View Slide

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

    •bearing

    •destination

    •lineDistance

    •area

    •along
    •pointOnLine

    •lineSlice

    •lineSliceAlong

    •bufferPoint

    •bufferBBox

    •insideBBox
    freaking
    fast!

    View Slide

  49. github.com/mapbox/earcut

    View Slide

  50. github.com/mapbox/delaunator

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  54. github.com/mapbox/webgl-wind

    View Slide

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

    View Slide