Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Offset.prototype.offsetContour = function(curve, edges) {
var union, i, len;
if (isArray(curve[0]) && typeof curve[0][0] === 'number') {
// we have 1 less edge than vertices
for (i = 0, len = curve.length - 1; i < len; i++) {
var segment = this.ensureLastPoint(
this._offsetSegment(curve[i], curve[i + 1], edges[i], this._distance)
);
union = (i === 0) ?
[this.ensureLastPoint(segment)] :
martinez.union(union, this.ensureLastPoint(segment));
}
} else {
for (i = 0, len = edges.length; i < len; i++) {
union = (i === 0) ?
this.offsetContour(curve[i], edges[i]) :
martinez.union(union, this.offsetContour(curve[i], edges[i]));
}
}
return union;
};
var union, i, len;
if (isArray(curve[0]) && typeof curve[0][0] === 'number') {
// we have 1 less edge than vertices
for (i = 0, len = curve.length - 1; i < len; i++) {
var segment = this.ensureLastPoint(
this._offsetSegment(curve[i], curve[i + 1], edges[i], this._distance)
);
union = (i === 0) ?
[this.ensureLastPoint(segment)] :
martinez.union(union, this.ensureLastPoint(segment));
}
} else {
for (i = 0, len = edges.length; i < len; i++) {
union = (i === 0) ?
this.offsetContour(curve[i], edges[i]) :
martinez.union(union, this.offsetContour(curve[i], edges[i]));
}
}
return union;
};
Offset.prototype.offsetContour = function(curve, edges) {
var union, i, len;
if (isArray(curve[0]) && typeof curve[0][0] === 'number') {
// we have 1 less edge than vertices
for (i = 0, len = curve.length - 1; i < len; i++) {
var segment = this.ensureLastPoint(
this._offsetSegment(curve[i], curve[i + 1], edges[i], this._distance)
);
union = (i === 0) ?
[this.ensureLastPoint(segment)] :
martinez.union(union, this.ensureLastPoint(segment));
}
} else {
for (i = 0, len = edges.length; i < len; i++) {
union = (i === 0) ?
this.offsetContour(curve[i], edges[i]) :
martinez.union(union, this.offsetContour(curve[i], edges[i]));
}
}
return union;
};
var union, i, len;
if (isArray(curve[0]) && typeof curve[0][0] === 'number') {
// we have 1 less edge than vertices
for (i = 0, len = curve.length - 1; i < len; i++) {
var segment = this.ensureLastPoint(
this._offsetSegment(curve[i], curve[i + 1], edges[i], this._distance)
);
union = (i === 0) ?
[this.ensureLastPoint(segment)] :
martinez.union(union, this.ensureLastPoint(segment));
}
} else {
for (i = 0, len = edges.length; i < len; i++) {
union = (i === 0) ?
this.offsetContour(curve[i], edges[i]) :
martinez.union(union, this.offsetContour(curve[i], edges[i]));
}
}
return union;
};
Offset.prototype.margin = function(dist) {
this.distance(dist);
if (typeof this.vertices[0] === 'number') { // point
return this.offsetPoint(this._distance);
}
if (dist === 0) return this.vertices;
var union = this.offsetLines(this._distance);
//return union;
union = martinez.union(this.vertices, union);
return orientRings(union);
};
Offset.prototype.margin = function(dist) {
this.distance(dist);
if (typeof this.vertices[0] === 'number') { // point
return this.offsetPoint(this._distance);
}
if (dist === 0) return this.vertices;
var union = this.offsetLines(this._distance);
//return union;
union = martinez.union(this.vertices, union);
return orientRings(union);
};
}
// Generate some unique IDs and add some metadata
var featurehash = utilHashcode(stringify(feature));
var propertyhash = utilHashcode(stringify(feature.properties || {}));
feature.__layerID__ = layerID.replace(/[^_a-zA-Z0-9\-]/g, '_');
feature.__featurehash__ = featurehash;
feature.__propertyhash__ = propertyhash;
features.push(feature);
// Clipped Polygons at same zoom with identical properties can get merged
if (isClipped && geometry.type === 'MultiPolygon') {
var merged = mergeCache[propertyhash];
if (merged && merged.length) {
var other = merged[0];
var coords = martinez.union(
feature.geometry.coordinates, other.geometry.coordinates
);
if (!coords || !coords.length) {
continue; // something failed in martinez union
}
merged.push(feature);
for (var j = 0; j < merged.length; j++) { // all these features get...
merged[j].geometry.coordinates = coords; // same coords
merged[j].__featurehash__ = featurehash; // same hash, so deduplication works
}
} else {
mergeCache[propertyhash] = [feature];
}
}
.add('w8r', () => {
w8r.union(
holeHole.features[0].geometry.coordinates,
holeHole.features[1].geometry.coordinates
)
})
.run()