Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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