Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const corner1 = this._clickSequence[0];
const corner2 = groundCoords;
const minX = Math.min(corner1[0], corner2[0]);
const minY = Math.min(corner1[1], corner2[1]);
const maxX = Math.max(corner1[0], corner2[0]);
const maxY = Math.max(corner1[1], corner2[1]);
const polygonPoints = bboxPolygon([minX, minY, maxX, maxY]).geometry.coordinates[0];
const centerCoordinates = getIntermediatePosition(corner1, corner2);
const xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001);
const ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001);
this._setTentativeFeature(ellipse(centerCoordinates, xSemiAxis, ySemiAxis));
}
const corner1 = clickSequence[0];
const corner2 = event.groundCoords;
const minX = Math.min(corner1[0], corner2[0]);
const minY = Math.min(corner1[1], corner2[1]);
const maxX = Math.max(corner1[0], corner2[0]);
const maxY = Math.max(corner1[1], corner2[1]);
const polygonPoints = bboxPolygon([minX, minY, maxX, maxY]).geometry.coordinates[0];
const centerCoordinates = getIntermediatePosition(corner1, corner2);
const xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001);
const ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001);
this._setTentativeFeature(ellipse(centerCoordinates, xSemiAxis, ySemiAxis));
return result;
}
}
this._setTentativeFeature({
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [clickSequence[0], groundCoords]
}
});
} else if (clickSequence.length === 2) {
const [p1, p2] = clickSequence;
const centerCoordinates = getIntermediatePosition(p1, p2);
const xSemiAxis = Math.max(distance(centerCoordinates, point(groundCoords)), 0.001);
const ySemiAxis = Math.max(distance(p1, p2), 0.001) / 2;
const options = { angle: bearing(p1, p2) };
this._setTentativeFeature(ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options));
}
return result;
}
}
this._setTentativeFeature({
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [this._clickSequence[0], groundCoords]
}
});
} else if (this._clickSequence.length === 2) {
const [p1, p2] = this._clickSequence;
const centerCoordinates = getIntermediatePosition(p1, p2);
const xSemiAxis = Math.max(distance(centerCoordinates, point(groundCoords)), 0.001);
const ySemiAxis = Math.max(distance(p1, p2), 0.001) / 2;
const options = { angle: bearing(p1, p2) };
this._setTentativeFeature(ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options));
}
}
}
var sigmaY = Math.sqrt(sigmaYsum * (1 / (n)));
sigmaX = radiansToLength(degreesToRadians(sigmaX));
sigmaY = radiansToLength(degreesToRadians(sigmaY));
theta = radiansToDegrees(theta);
var semiMajorAxis, semiMinorAxis;
if (sigmaX > sigmaY) {
semiMajorAxis = sigmaX;
semiMinorAxis = sigmaY;
} else {
semiMinorAxis = sigmaX;
semiMajorAxis = sigmaY;
theta = theta - 90;
}
var theEllipse = ellipse(meanCenter, semiMajorAxis, semiMinorAxis, {angle: theta, steps: steps, properties: properties});
var eccentricity = (Math.sqrt(Math.pow(semiMajorAxis, 2) - Math.pow(semiMinorAxis, 2))) / semiMajorAxis;
var pointsWithinEllipse = pointsWithinPolygon(points, turf.featureCollection([theEllipse]));
var standardDeviationalEllipseProperties = {
meanCenterCoordinates: getCoord(theMeanCenter),
semiMajorAxis: semiMajorAxis,
semiMinorAxis: semiMinorAxis,
angle: theta,
eccentricity: eccentricity,
pctWithinEllipse: 100 * turf.coordAll(pointsWithinEllipse).length / n
};
theEllipse.properties.standardDeviationalEllipse = standardDeviationalEllipseProperties;
return theEllipse;
};