There is a rectangle (we call it A
) defined by two map points:
A = [southWest1, northEast1]
We also have a second rectangle:
B = [southWest2, northEast2]
where southWest_i
and northEast_i
- a point on the map, i.e. couple [lat, lng]
I want to find the best solution for finding the percentage of the rectangle A
in the rectangle B
.
There is no such thing as "percentage of a polygon inside another polygon". I think you rather mean ratio between the area of a polygon and the intersection of that polygon with a second one.
So:
There are lots of ways to calculate areas and intersections of polygons. If you plan to use Javascript, I suggest you look at TurfJS, specifically at its intersect()
and area()
methods