Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mode: 'query',
layers: [this.props.id],
radius: 100,
viewports: [this.context.viewport]
});
// do nothing when mouse position far away from any point
if (!picks || !picks.length || !picks[0].object.position) {
return;
}
pivot = picks[0].object.position;
} else {
pivot = modeConfig.pivot;
}
const featureIndex = this.props.selectedFeatureIndexes[0];
const feature = this.state.selectedFeatures[0];
const rotatedFeature = turfTransformRotate(feature, 2, { pivot });
const updatedData = this.state.editableFeatureCollection.featureCollection
.replaceGeometry(featureIndex, rotatedFeature.geometry)
.getObject();
this.props.onEdit({
updatedData,
editType: 'transformPosition',
featureIndex,
positionIndexes: this.props.positionIndexes,
position: groundCoords
});
}
static rotateTurfObject(turfObj, deg, pivotLatlng, mutate=true) {
return turfTransformRotate(turfObj, deg, {
pivot: [pivotLatlng[1], pivotLatlng[0]],
mutate: mutate,
});
}
getRotateAction(startDragPoint: Position, currentPoint: Position, editType: string): EditAction {
const startPosition = startDragPoint;
const centroid = turfCentroid(this._geometryBeingRotated);
const angle = getRotationAngle(centroid, startPosition, currentPoint);
const rotatedFeatures = turfTransformRotate(this._geometryBeingRotated, angle);
let updatedData = this.getImmutableFeatureCollection();
const selectedIndexes = this.getSelectedFeatureIndexes();
for (let i = 0; i < selectedIndexes.length; i++) {
const selectedIndex = selectedIndexes[i];
const movedFeature = rotatedFeatures.features[i];
updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry);
}
return {
updatedData: updatedData.getObject(),
editType,
featureIndexes: selectedIndexes,
editContext: null
};
if (stepAngle < -90 && stepAngle >= -270) x = -x;
if (stepAngle < -180 && stepAngle >= -360) y = -y;
if (units === 'degrees') {
var newx = x * Math.cos(angleRad) + y * Math.sin(angleRad);
var newy = y * Math.cos(angleRad) - x * Math.sin(angleRad);
x = newx;
y = newy;
}
coordinates.push([x + centerCoords[0], y + centerCoords[1]]);
}
coordinates.push(coordinates[0]);
if (units === 'degrees') {
return polygon([coordinates], properties);
} else {
return transformRotate(polygon([coordinates], properties), angle, { pivot: pivot });
}
}