6
$\begingroup$

We're dealing with country borders, that is the set of multiple disjoint domains that is made of polygons.

To extract the different point on the map by a given country we've been said to implement the ray casting algorithm which is absolutely fine, but the country is hardly to be the simply-connected domain. For example, the Italy consists of many disjoint domains (islands).

In this case the crossing number algorithm or the even-odd rule algorithm is still a valid approach to validate if the point in question is within the country borders or not?

EDIT

After days of research finally found one discussion: MySQL implementation of ray-casting Algorithm? which gives the exhausting number of links, answers and code snippets to implement the algorithm in code (Pseudo-code: http://rosettacode.org/wiki/Ray-casting_algorithm).

Thanks!

$\endgroup$

1 Answer 1

3
$\begingroup$

Yes, the even-odd rule works for any closed set of polygons.

The only thing to be careful about is the ray hitting a vertex, since code which is not equipped to handle degeneracies may return incorrect results in that case. The lowest effort solution is usually to (1) first check if you are on the boundary of the polygon and (2) try rays with random directions until no vertex is hit.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.