the method proposed by Andrew Leach only works, if the outer polygon is concave, though. what you should do iot test whether *any* regular polygon lies entirely within another, is to check for each edge of polygon p if there is an intersection with any of the edges of polygon q. if you find at least one (two, actually) intersection(s), then the polygons obviously have got an intersection-area. if there is no intersection, then polygon p lies either entirely within or outside of polygon q. in this case you would have to use Mike William's GPolygon.Contains(GLatLng) method like polygon_p.Contains (polygon_q.getVertex(0)); if this returns true and there are no intersections of edges, then polygon p contains polygon q.
On Jul 14, 3:29 pm, Andrew Leach <[email protected]> wrote: > On Jul 14, 12:13 pm, Prabu Proxy <[email protected]> wrote: > > > Suppose I have 2 Gpolygons. They may overlap with each other or one > > inside of another, but are not identical. How could i find out whether > > the 2 Gpolygons are intersects or inside to one another? > > Use Mike's EPoly extension:http://econym.org.uk/gmap/epoly.htm > > Loop through all the vertices of one polygon; for each vertex, test > whether the other polygon contains it. If it does, increment a > "contains" variable. If it doesn't, increment a "not-contains" > variable. [The names of those variables are up to you] > > At the end of the loop, if your "contains" variable is the same as the > number of points checked, the polygon is entirely contained within the > other. If the "not-contains" variable is the same, the polygon is > entirely outside the other. > > Note that with this method, if you have two concentric polygons and > test whether the outer one is contained by the inner one, the result > will be that it isn't. You shouldn't assume that there is no > intersection until you have tested the other way round as well. > > Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
