Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return the centroid when no Voronoi vertices are inside polygon', function()
{
expect(maxCircle(this.inputTinyPolygon).geometry).to.eql(centroid(this.inputTinyPolygon).geometry);
});
});
onMouseDown: function(state, e) {
if(e.featureTarget) {
if(this._ctx.api.get(e.featureTarget.properties.id)) {
e.target['dragPan'].disable();
state.selectedFeature = this._ctx.api.get(e.featureTarget.properties.id);
state.originalCenter = centroid(e.featureTarget);
state.originalFeature = e.featureTarget;
emitter.emit('rotatestart');
}
}
return state;
},
sql.fn.geohash = function (geometry = {}, precision) {
if (!geometry || !geometry.type || !geometry.coordinates) return
precision = precision || 8
if (geometry.type !== 'Point') geometry = centroid(geometry).geometry
const pnt = geometry.coordinates
return geohash.encode(pnt[1], pnt[0], precision)
}
function seqUnitAgentMaker(id){
let index = this.agents.count();
if (index > this.units.getLayers().length - 1) {
throw new Error("seqUnitAgentMaker cannot accommodate more agents than there are units.");
}
let unit = this.units.getLayers()[index],
unit_id = this.units.getLayerId(unit),
center_point = centroid(unit.feature);
center_point.properties.place = {"type": "unit", "id": unit_id},
center_point.properties.layer_options = {radius: .5, color: "red", fillColor: "red"};
return center_point;
}
const vertices = {
type: "FeatureCollection",
features: []
};
//construct GeoJSON object of voronoi vertices
for(let i = 0; i < diagram.vertices.length; i++) {
vertices.features.push({
type: "Feature",
properties: {},
geometry: {
type: "Point",
coordinates: [diagram.vertices[i].x, diagram.vertices[i].y]
}
})
}
vertices.features.push(centroid(polygon));
//within requires a FeatureCollection for input polygons
const polygonFeatureCollection = {
type: "FeatureCollection",
features: [polygon]
};
const ptsWithin = within(vertices, polygonFeatureCollection); //remove any vertices that are not inside the polygon
if(ptsWithin.features.length === 0) {
throw new NoPointsInShapeError('Neither the centroid nor any Voronoi vertices intersect the shape.');
}
const labelLocation = {
coordinates: [0,0],
maxDist: 0
};
const polygonBoundaries = {
type: "FeatureCollection",
features: []