Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to search object nearby other objects. (linestring buffering) #79

Open
tidwall opened this issue Nov 9, 2016 · 5 comments

Comments

@tidwall
Copy link
Owner

tidwall commented Nov 9, 2016

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:

LineString

Buffered LineString:

LineString-Buffer

And then the NEARBY command would hand the control to the INTERSECTS command.

@umpc
Copy link
Contributor

umpc commented Dec 8, 2017

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.

@tidwall tidwall changed the title Add ability to search object nearby other objects. Add ability to search object nearby other objects. (linestring buffering) Apr 24, 2018
@ronalddas
Copy link

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

@higoramp
Copy link

higoramp commented Dec 7, 2021

Has there been some development on this issue?

@tidwall
Copy link
Owner Author

tidwall commented Dec 8, 2021

Actually, I do have something in a dev branch somewhere. I'll dig around and see what state the code is in.

@tidwall
Copy link
Owner Author

tidwall commented Dec 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants