Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14948

Find Points near LineString

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • Affects Version/s: 2.4.10, 2.6.4
    • Component/s: Geo
    • Labels:
      None
    • Query Integration

      I couldn't find an existing ticket, so let me try my luck.

      I would like the ability to search for GeoJSON points that are within x meters of a GeoJSON Polyline. This is currently a costly query to implement outside of a database server, as I either have to; build a Polygon from a Polyline before using a $geoWithin, or hit Mongo multiple times using a $near, then filter all results for a distinct list of Points.

      An approach that could be achieved in the server would be (likely a naive implementation):
      1. make a LineString into a 'complex' LineString by reducing the distance between each point to a small distance. JS example: https://github.com/rwt-to/GeoJSON-Tools#complexify
      2. convert the LineString into a Polygon by creating a circle out of each point in the LineString, then merging them (haven't found an effective way of doing that yet, my Polygons become huge)
      3. use $geoWithin internally to find Points in the Polygon.

      The second approach would be to perform step 1. above, then just use a $near for each point in the LineString, then filtering all the Points before returning a result.

      In case I haven't explained it clearly, here's a SO question explaining the issue: http://stackoverflow.com/questions/19015861/find-points-near-linestring-in-mongodb-sorted-by-distance

      There is likely a more efficient way, but I haven't had the time to try find it. I think the query would still perform decently if ran internally on Mongo, as either method above would use indices while avoiding round-trips.

      Lastly, just for control, it seems like this is easily achievable in PostgreSQL : http://stackoverflow.com/questions/10286899/find-the-nearest-points-along-the-linestring-in-specified-distance-limit-and-ord

            Assignee:
            backlog-query-integration [DO NOT USE] Backlog - Query Integration
            Reporter:
            nevi_me Neville Dipale
            Votes:
            3 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: