Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function difference(polygon1, polygon2) {
var geom1 = getGeom(polygon1);
var geom2 = getGeom(polygon2);
var properties = polygon1.properties || {};
// Issue #721 - JSTS/Martinez can't handle empty polygons
geom1 = removeEmptyPolygon(geom1);
geom2 = removeEmptyPolygon(geom2);
if (!geom1) return null;
if (!geom2) return feature(geom1, properties);
var differenced = martinez.diff(geom1.coordinates, geom2.coordinates);
if (differenced.length === 0) return null;
if (differenced.length === 1) return polygon(differenced[0], properties);
else return multiPolygon(differenced, properties);
}
Offset.prototype.padding = function(dist) {
this.distance(dist);
if (this._distance === 0) return this.ensureLastPoint(this.vertices);
if (this.vertices.length === 2 && typeof this.vertices[0] === 'number') {
return this.vertices;
}
var union = this.offsetLines(this._distance);
var diff = martinez.diff(this.vertices, union);
return orientRings(diff);
};
Offset.prototype.padding = function(dist) {
this.distance(dist);
if (this._distance === 0) return this.ensureLastPoint(this.vertices);
if (this.vertices.length === 2 && typeof this.vertices[0] === 'number') {
return this.vertices;
}
var union = this.offsetLines(this._distance);
var diff = martinez.diff(this.vertices, union);
return orientRings(diff);
};