I have Many GMSPolygon
inside my google map. Now i want to check for one specific polygon that is it inside(fully inside) any of the other polygons. Also need to find out that which other polygons are intersecting with boundaries to this polygon, and other polygon which are neither intersecting, neither inside given polygon nor covering this polygon.
Can anyone have idea how to do this?
EDIT:
I got the library/code to do the above same thing for MKPolygon, you can see it over here: https://github.com/geeksweep/MKPolygon-GSPolygonIntersections
Now, I am thinking that i should convert whole GMSPolygon into MKPolygon and apply this library's code to get the required result. But I think this is not proper way for doing this. Do anyone have any idea to do this in very simple manner.
After searching lot things, i found one solution, i think that is not that much proper, but still better than other 3-4 solutions that i found. If anyone find better solution that this, tell me, if i find them better and proper, i will accept that one and will change in my code too. Rightnow, i have used following code to do this.
GMSPath *path1=polygon1.path, *path2=polygon2.path;
BOOL flag1= NO;
BOOL flag2= NO;
for (int i=0; i<path1.count; i++)
{
if (GMSGeometryContainsLocation([path1 coordinateAtIndex:i], path2, YES)==false)
{
flag1 = true;
}
if (GMSGeometryIsLocationOnPath([path1 coordinateAtIndex:i], path2, YES)==true)
{
flag2 = true;
}
}
if (flag1==false)
{
NSLog(@"polygon1 is fully inside polygon2");
}
else if (flag2 == true)
{
NSLog(@"polygon1 intersects with polygon2");
}
else
{
//Do the above procedure again just by switching path1 and path2
//and at end you can find that is polygon2 is inside polygon1 or not,
//and if it is not, then this means both polygon1 and polygon2 are distinct
//then neither intersects, nor inside each other
}