I need to find union of polygons represented as javascript arrays of geocoordinates as in the code bellow:
var polygon1 = [[51.49151151647854, -0.20633749635419463],
[51.491517887745886, -0.20663465247037038],
[51.49125377257769, -0.20707803457401042],
[51.49125377257769, -0.20707803457401042],
[51.49090541057069, -0.2071046417369189],
[51.490605858341326, -0.20637621141179352],
[51.49081102624578, -0.20598780005047956],
[51.490859930095496, -0.20592173450688733]]
var polygon2 = [[51.492223312188386, -0.20784254067885688],
[51.49226262897666, -0.20812681455816695],
[51.49162516066342, -0.2090258514344801],
[51.491538051645385, -0.2089717941050469],
[51.49200661100099, -0.20759325088262348]]
I would draw that resulting polygon on Google map with Google maps Javascript API v3, so they can be structured like in the code bellow, too:
var googleMapPolygon1 = [
new google.maps.LatLng(51.49151151647854, -0.20633749635419463),
new google.maps.LatLng(51.491517887745886, -0.20663465247037038),
new google.maps.LatLng(51.49125377257769, -0.20707803457401042),
new google.maps.LatLng(51.49090541057069, -0.2071046417369189),
new google.maps.LatLng(51.490605858341326, -0.20637621141179352),
new google.maps.LatLng(51.49081102624578, -0.20598780005047956),
new google.maps.LatLng(51.490859930095496, -0.20592173450688733),
new google.maps.LatLng(51.49151151647854, -0.20633749635419463)
];
var googleMapPolygon2 = [
new google.maps.LatLng(51.492223312188386, -0.20784254067885688),
new google.maps.LatLng(51.49226262897666, -0.20812681455816695),
new google.maps.LatLng(51.49162516066342, -0.2090258514344801),
new google.maps.LatLng(51.491538051645385, -0.2089717941050469),
new google.maps.LatLng(51.49200661100099, -0.20759325088262348),
new google.maps.LatLng(51.492223312188386, -0.20784254067885688)
]
So, what could I use for finding the union of polygons? Thanks in advance.
EDIT: This is what I do. I have array of Voronoi cells structured as polygons (left side of the picture bellow). And what I am trying to get is boundary around them (green polygon on the right side of the picture bellow).
So, I think I can get it with union operation. Can anyone help?