Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

So my big question here is how does the Google Maps API determine the "inner" versus the "outer" for a filled polygon?

Playing around with the polygon creator @ http://www.the-di-lab.com/polygon/ there seems to be a preference to:

  1. wrap the north pole;
  2. take the "smallest" polygon possible?

The big reason I want to know is to assist with answering the question "is point (x,y) in multipolygon z?"

Thoughts?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

The big reason I want to know is to assist with answering the question "is point (x,y) in multipolygon z?"

Using a Ray casting algorithm to solve the point in polygon problem, you don't need to know how the Google Code works.

enter image description here

The number of intersections for a ray passing from the exterior of the polygon to any point, if odd, shows the point lies inside the polygon. If even, the point lies outside the polygon. This test also works in three dimensions.

share|improve this answer
    
This begs the question, though: to get started with ray casting, you need to have a point that is known to be in the "exterior." For planar polygons that's easy: the exterior is unbounded. For spherical polygons there is no definite answer: either component can be taken as the exterior. Therefore there must either be a conventional determination of the exterior (which is usually done by means of the orientations of the polygon's rings) or an explicit indication of the exterior in the polygon's representation. –  whuber Jun 8 '11 at 13:04
    
the 2D methodology is fine, however a 3D surface (such as the earth) requires a more accurate methodology in order to deal with the -180 to 180 of the longitude in addition to the issue of which side of a polygon is filled and which one isn't. –  jufemaiz Jun 13 '11 at 7:25
    
Maybe you could clarify your question by adding that you are working with global datasets in lat/lon. –  underdark Jun 13 '11 at 10:16
add comment

for v2 it was the GPolygon.contains() method

http://econym.org.uk/gmap/example_inside.htm

now v3 supports donut polygons

http://gmaps-samples-v3.googlecode.com/svn/trunk/poly/pentagon.html this takes the first set of coordinates as the inner ring.

share|improve this answer
1  
thanks for the reply. I have inspected to the polygon methodology for gmaps v3 however it is not so much as first and second (I believe that it is the second set that is the inner ring) but rather the rotation. While this is acceptable at a small level once I start attempting to ensure all test cases are true I run into trouble (mainly around the definition of the inner v outer of a large polygon projected onto the earths surface as with Gmaps). –  jufemaiz Jun 13 '11 at 7:26
add comment

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.