Search for points from multiple polygons

123 Views Asked by At

I am using ClusterPoint database to access Open Street Map data (https://github.com/clusterpoint/osm), but I'd like to find POI contained within multiple separate polygons.

Is there any example available how to define and use multiple polygons within query?

1

There are 1 best solutions below

0
On BEST ANSWER

To use multiple polygons in one query, you need to define them under <shapes> tag. Each polygon should have individual name. If you want to search within multiple polygons, than use OR operator "{}" in query.

Example with two polygons and one circle could look like:

<query>
    {&gt;&lt;polygon1 &gt;&lt;polygon2 &gt;&lt;circle1}
</query>
<shapes>
    <polygon1>lat1 lon1; lat2 lon2; lat3 lon3; lat4 lon4; lat5 lon5; ...
        <coord1_tag_name>lat</coord1_tag_name>
        <coord2_tag_name>lon</coord2_tag_name>
    </polygon1>
    <polygon2>lat1 lon1; lat2 lon2; lat3 lon3; lat4 lon4; lat5 lon5; ...
        <coord1_tag_name>lat</coord1_tag_name>
        <coord2_tag_name>lon</coord2_tag_name>
    </polygon2>
    <circle1>
        <center>lat lon</center>
        <radius>10 km</radius> <!-- here you can define distance in "km" or in "mi" -->
        <coord1_tag_name>lat</coord1_tag_name>
        <coord2_tag_name>lon</coord2_tag_name>
    </circle1>
</shapes>

If polygons are overlapped, then matching points within this area will not "duplicate" in result set (will be displayed once).