Remove no longer needed checks for coordinates.length
This commit is contained in:
@@ -43,7 +43,6 @@ function addInteraction() {
|
||||
} else if (value === 'Star') {
|
||||
value = 'Circle';
|
||||
geometryFunction = function (coordinates, geometry) {
|
||||
if (coordinates.length) {
|
||||
const center = coordinates[0];
|
||||
const last = coordinates[coordinates.length - 1];
|
||||
const dx = center[0] - last[0];
|
||||
@@ -66,7 +65,6 @@ function addInteraction() {
|
||||
geometry.setCoordinates([newCoordinates]);
|
||||
}
|
||||
return geometry;
|
||||
}
|
||||
};
|
||||
}
|
||||
draw = new Draw({
|
||||
|
||||
@@ -59,7 +59,8 @@ import {squaredDistance as squaredCoordinateDistance} from '../coordinate.js';
|
||||
* polygon rings and `2` for line strings.
|
||||
* @property {import("../events/condition.js").Condition} [finishCondition] A function
|
||||
* that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a
|
||||
* boolean to indicate whether the drawing can be finished.
|
||||
* boolean to indicate whether the drawing can be finished. Not used when drawing
|
||||
* POINT or MULTI_POINT geometries.
|
||||
* @property {import("../style/Style.js").StyleLike} [style]
|
||||
* Style for sketch features.
|
||||
* @property {GeometryFunction} [geometryFunction]
|
||||
@@ -317,17 +318,13 @@ class Draw extends PointerInteraction {
|
||||
* @return {import("../geom/SimpleGeometry.js").default} A geometry.
|
||||
*/
|
||||
geometryFunction = function (coordinates, geometry, projection) {
|
||||
if (coordinates.length) {
|
||||
const circle = geometry
|
||||
? /** @type {Circle} */ (geometry)
|
||||
: new Circle([NaN, NaN]);
|
||||
const center = fromUserCoordinate(coordinates[0], projection);
|
||||
const squaredLength = squaredCoordinateDistance(
|
||||
center,
|
||||
fromUserCoordinate(
|
||||
coordinates[coordinates.length - 1],
|
||||
projection
|
||||
)
|
||||
fromUserCoordinate(coordinates[coordinates.length - 1], projection)
|
||||
);
|
||||
circle.setCenterAndRadius(center, Math.sqrt(squaredLength));
|
||||
const userProjection = getUserProjection();
|
||||
@@ -335,7 +332,6 @@ class Draw extends PointerInteraction {
|
||||
circle.transform(projection, userProjection);
|
||||
}
|
||||
return circle;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
let Constructor;
|
||||
@@ -895,7 +891,8 @@ class Draw extends PointerInteraction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove last point of the feature currently being drawn.
|
||||
* Remove last point of the feature currently being drawn. Does not do anything when
|
||||
* drawing POINT or MULTI_POINT geometries.
|
||||
* @api
|
||||
*/
|
||||
removeLastPoint() {
|
||||
@@ -1150,7 +1147,6 @@ function getDefaultStyleFunction() {
|
||||
*/
|
||||
export function createRegularPolygon(opt_sides, opt_angle) {
|
||||
return function (coordinates, opt_geometry, projection) {
|
||||
if (coordinates.length) {
|
||||
const center = fromUserCoordinate(
|
||||
/** @type {LineCoordType} */ (coordinates)[0],
|
||||
projection
|
||||
@@ -1177,7 +1173,6 @@ export function createRegularPolygon(opt_sides, opt_angle) {
|
||||
geometry.transform(projection, userProjection);
|
||||
}
|
||||
return geometry;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1190,7 +1185,6 @@ export function createRegularPolygon(opt_sides, opt_angle) {
|
||||
*/
|
||||
export function createBox() {
|
||||
return function (coordinates, opt_geometry, projection) {
|
||||
if (coordinates.length) {
|
||||
const extent = boundingExtent(
|
||||
/** @type {LineCoordType} */ ([
|
||||
coordinates[0],
|
||||
@@ -1219,7 +1213,6 @@ export function createBox() {
|
||||
geometry.transform(projection, userProjection);
|
||||
}
|
||||
return geometry;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user