@turf/union
Advanced tools
Comparing version 3.0.18 to 3.2.0
22
index.js
@@ -9,7 +9,6 @@ // look here for help http://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/vector/v.overlay/main.c | ||
/** | ||
* Takes two {@link Polygon|polygons} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature. | ||
* Takes two or more {@link Polygon|polygons} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature. | ||
* | ||
* @name union | ||
* @param {Feature<Polygon>} poly1 input polygon | ||
* @param {Feature<Polygon>} poly2 another input polygon | ||
* @param {...Feature<Polygon>} A polygon to combine | ||
* @return {Feature<(Polygon|MultiPolygon)>} a combined {@link Polygon} or {@link MultiPolygon} feature | ||
@@ -60,15 +59,18 @@ * @example | ||
*/ | ||
module.exports = function (poly1, poly2) { | ||
module.exports = function () { | ||
var reader = new jsts.io.GeoJSONReader(); | ||
var a = reader.read(JSON.stringify(poly1.geometry)); | ||
var b = reader.read(JSON.stringify(poly2.geometry)); | ||
var union = a.union(b); | ||
var result = reader.read(JSON.stringify(arguments[0].geometry)); | ||
for (var i = 1; i < arguments.length; i++) { | ||
result = result.union(reader.read(JSON.stringify(arguments[i].geometry))); | ||
} | ||
var writer = new jsts.io.GeoJSONWriter(); | ||
result = writer.write(result); | ||
union = writer.write(union); | ||
return { | ||
type: 'Feature', | ||
geometry: union, | ||
properties: poly1.properties | ||
geometry: result, | ||
properties: arguments[0].properties | ||
}; | ||
}; |
{ | ||
"name": "@turf/union", | ||
"version": "3.0.18", | ||
"version": "3.2.0", | ||
"description": "find the union of geographic features", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
5256