On Apr 27, 5:00 am, teradactyal <[email protected]> wrote:
> Thanks John
>
> This is a standalone JS app and I am tending to agree that Server Side
> might be the only way to do this accurately, short of breaking up each
> edge to a number of lines and then breaking up each line to a number
> of points and testing these (which may take some time and still won't
> be 100%).

Client-side is not trivial, but it's probably doable.

Consider two polygons A and B. You can discount any possibility of
intersection if the two bounding boxes do not intersect -- that's a
fairly trivial comparison of max and min latitude and longitude.

If there is the possibility of intersection, then they intersect if
there is a vertex of A inside polygon B or if a vertex of B exists
inside polygon A. You can use Mike's EPoly extension to do that, but
it involves testing each vertex of both polygons until success.

You could dispense with that stage, but in most cases it will yield a
result faster than going straight into stage three:

I contend that if the boundaries coincide at any point, you can infer
that there is an intersection (even if it's just a point). You then
need to test every straight-line segment of poly A against every
straight-line segment of poly B and see if they cross. That means
solving simultaneous equations (I think) to see if the equation of the
A segment and the equation of the B segment have a common solution. If
they do, they meet at that point and the polygons can be said to
intersect. But that's the difficult bit.

That particular test can be speeded up by discounting segments whose
bounding box does not intersect the bounding box of the subject
segment in the other polygon, like the very first stage.

It's not a trivial method. If you need to do it client-side, I wish
you good luck!

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to