[OSM-talk] osmxapi/bbox question

Karl Newman siliconfiend at gmail.com
Fri Apr 11 15:50:07 BST 2008


On Fri, Apr 11, 2008 at 5:47 AM, 80n <80n80n at gmail.com> wrote:

> You can have any shaped bbox you like as long as it is a rectangle ;)
>
> Can anyone point me to a good algorithm for selecting points within an
> arbitrary polygon?
>
> 80n


I don't have it in pseudocode, but one I've heard of casts a ray (horizontal
is common) out from the point being tested and then checks the intersection
of that ray against each segment of the polygon. If the total number of
intersections is odd, then the point lies inside the polygon. If the number
is even, then it's outside. This works for holes in a polygon, too.

Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/talk/attachments/20080411/cffeb831/attachment.html>


More information about the talk mailing list