On Aug 27, 2009, at 11:32 PM, Marcelo wrote: > > The best you can do is to check if the route crosses a polygon, and to > do that you'd just need to write a loop that checks each vertex of the > polyline of the route against the polygon.
Not to be pedantic, but that's not *quite* correct. Checking each vertex is insufficient for genuine clipping. Instead, you have to check the line created by each (sequential) pair of vertices against the polygon. The simple case being a rectangle from (1, 1) to (3, 3) and a line from (0, 2) to (4, 2)...neither of the line's endpoints clip the rectangle, but the line between them goes right through the middle. :) Either way, testing for intersection of a (point, line, polygon) against a (point, line, polygon) is a very standard operation and you should be able to find all sorts of examples out there. Try googling something like "clipping algorithm," adding point, line, or polygon to that as needed. You'll have your pick as to how efficient you want to get (more efficient will generally involve more overhead.) -G --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
