tile38
tile38 copied to clipboard
Add ability to search object nearby other objects. (linestring buffering)
Currently the NEARBY command only supports a radius search around single a point, such as:
NEARBY poi POINT 41.2801 -7.7214 100
But it would be great to add the ability to search nearby other objects such as:
NEARBY poi OBJECT {"type":"LineString","coordinates":[[-7.71175,41.28433],[-7.71708,41.28233],[-7.72145,41.28012],[-7.72579,41.27761],[-7.72791,41.27710],[-7.73216,41.27718],[-7.74237,41.27782]]} 100
Under the hood the NEARBY command would need to generate a new polygon from the linestring by "buffering" the linestring using an algorithm like the Minkowski Sum, PostGIS ST_MinkowskiSum.
Original LineString:

Buffered LineString:

And then the NEARBY command would hand the control to the INTERSECTS command.
If someone wants to implement this, there is a good example in JavaScript, here: https://github.com/Turfjs/turf/blob/master/packages/turf-buffer/index.js
I might implement this in Go eventually, though not any time soon. I am leaving this here for anyone else who may be interested in porting it.
Almost similar in geoLib https://github.com/manuelbieh/geolib/blob/master/src/isPointNearLine.ts Detects if a point is within a certain distance from the line
Has there been some development on this issue?
Actually, I do have something in a dev branch somewhere. I'll dig around and see what state the code is in.
I just committed the ability to buffer objects in 241117c.
It's a little different that what I suggested back in 2016, but it should provide the same underlying functionality.
Here's an example:
INTERSECTS poi BUFFER 100 OBJECT {"type":"LineString","coordinates":[[-7.71175,41.28433],[-7.71708,41.28233],[-7.72145,41.28012],[-7.72579,41.27761],[-7.72791,41.27710],[-7.73216,41.27718],[-7.74237,41.27782]]}
It uses a new BUFFER option that takes one param (meters). This will buffer any object, like Point, LineString, Polygon, etc.