Determine the Points of Intersections of Two Overlapping Polygons

Similar to the method described in the post "Determine if Two Polygons Overlap" (!E7DBA9A4BFD458C5!475.entry), we will have to iterate through all the line segments that make up one polygon and see if they overlap with any of the line segments that make up the second polygon. The difference will be that we will create an array of all the points of intersections. The following function takes in two arrays of coordinates that make up two polygons. An array of VELatLong objects will be returned.

//poly1 and poly2 are arrays of VELatlongs that represent polygons
function PolygonIntersections(poly1, poly2)
var intersections = new Array();
if(poly1.length >= 3 && poly2.length >= 3)
//close polygons poly1.push(poly1[0]); poly2.push(poly2[0]); for(var i = 0; i < poly1.length-1;i++)
for(var k = 0; k < poly2.length-1; k++)
var intersect = SimplePolylineIntersection(poly1[i],poly1[i+1],poly2[k],poly2[k+1]);


return intersections;

return null;

The code for the function "SimplePolylineIntersection" can be found here:!E7DBA9A4BFD458C5!474.entry

Here is a screen shot of this function being used and the points being plotted on the map:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s