Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switch (getType(obstacles)) {
case 'FeatureCollection':
if (obstacles.features.length === 0) return lineString([startCoord, endCoord]);
break;
case 'Polygon':
obstacles = featureCollection([feature(getGeom(obstacles))]);
break;
default:
throw new Error('invalid obstacles');
}
// define path grid area
var collection = obstacles;
collection.features.push(start);
collection.features.push(end);
var box = bbox(scale(bboxPolygon(bbox(collection)), 1.15)); // extend 15%
if (!resolution) {
var width = distance([box[0], box[1]], [box[2], box[1]], options);
resolution = width / 100;
}
collection.features.pop();
collection.features.pop();
var west = box[0];
var south = box[1];
var east = box[2];
var north = box[3];
var xFraction = resolution / (distance([west, south], [east, south], options));
var cellWidth = xFraction * (east - west);
var yFraction = resolution / (distance([west, south], [west, north], options));
var cellHeight = yFraction * (north - south);
getScaleAction(startDragPoint: Position, currentPoint: Position, editType: string): EditAction {
const startPosition = startDragPoint;
const centroid = turfCentroid(this._geometryBeingScaled);
const factor = getScaleFactor(centroid, startPosition, currentPoint);
const scaledFeatures = turfTransformScale(this._geometryBeingScaled, factor, {
origin: centroid
});
let updatedData = this.getImmutableFeatureCollection();
const selectedIndexes = this.getSelectedFeatureIndexes();
for (let i = 0; i < selectedIndexes.length; i++) {
const selectedIndex = selectedIndexes[i];
const movedFeature = scaledFeatures.features[i];
updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry);
}
return {
updatedData: updatedData.getObject(),
editType,
featureIndexes: selectedIndexes,
export function scaleBbox(bbox: BBox, scale: number) {
return turfbbox(transformScale(bboxPolygon(bbox), scale));
}