UNPKG

turf-union

Version:

find the union of geographic features

22 lines (17 loc) 646 B
// look here for help http://svn.osgeo.org/grass/grass/branches/releasebranch_6_4/vector/v.overlay/main.c //must be array of polygons // depend on jsts for now https://github.com/bjornharrtell/jsts/blob/master/examples/overlay.html var jsts = require('jsts') module.exports = function(poly1, poly2){ 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 parser = new jsts.io.GeoJSONParser() union = parser.write(union) return { type: 'Feature', geometry: union, properties: poly1.properties } }