Search with boundary.polygon parameter


#1

Hello,

I’ve been reading the docus of ORS and Pelias, but I didn’t find any solution for what I’m searching for.
I would like to search for an address within a given custom polygon.
Search offers parameters for filtering countries, rectangles, and circles, but not polygons. Would this just be too performance intensive? Or is there maybe another way to achieve this?

Thanks!


#2

Hi @Harald_Kofler

Sorry, we only provide existing services from Pelias.
Of course a Point in Polygon is a more complex computation compared to point to point distance or Point in Rectangle.
If you want to see this feature implemented you can always open an issue in the pelias repository.

You could also filter the results afterwards, by checking if the response entry is within your polygon.

Best regards


#3

Hi @amandus,

thanks for your answer!

For anyone else having the same question, I found the following function in the Pelias repo:

https://github.com/pelias/polygon-lookup

Seems like this function relies on:

substack/point-in-polygon (link removed, as new users can only post 2 links :wink:

Out there is a more robust implementation of this algorithm:

https://github.com/mikolalysenko/robust-point-in-polygon

@amandus:
As it seems that pelias/polygon-lookup is part of the pelias stack- is there a way to access this function through ORS?
If not possible I’ll try to get coordinates from ORS and then reimplement a point-in-polygon lookup.


#4

Hi @Harald_Kofler,

Interesting. I don’t think we have set this up. But maybe @nils can provide more info :slight_smile:

Best regards


#5

Hi,

no, I don’t think so. It’s a dependency of wof-admin-lookup, which is used to extract the admin hierarchy from WhosOnFirst data during the data import pipelines. It’s not exposed via any API and what you’re trying to do @Harald_Kofler is a better fit for Pelias forum.

Try their gitter channel, it’s fairly active: gitter.im/pelias/pelias


#6

Hello @nils,

thanks for your feedback.
I think as ORS actually does not provide such a lookup directly out-of-box, I’ll start by including a point-in-polygon search into my application. I’ll need to perform several lookup with different points an different polygon, so to be performant the polygons must be persisted “next to the search algorithm” and not “uploaded on each lookup”.

I would like to share another lib I found online which looks really promising:

It is a C# implementation and should do exactly what needed…
I’ll try to share an update once I tested this code

In the meantime thanks @nils and @amandus for the help!