123 lines
3.1 KiB
JavaScript
123 lines
3.1 KiB
JavaScript
import {
|
|
SimpleGeometry_default,
|
|
deflateCoordinate
|
|
} from "./chunk-YUTQGDGI.js";
|
|
import {
|
|
squaredDistance
|
|
} from "./chunk-54BTDBAD.js";
|
|
import {
|
|
containsXY,
|
|
createOrUpdateFromCoordinate
|
|
} from "./chunk-CKDBVGKM.js";
|
|
|
|
// node_modules/ol/geom/Point.js
|
|
var Point = class _Point extends SimpleGeometry_default {
|
|
/**
|
|
* @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
|
|
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
|
*/
|
|
constructor(coordinates, layout) {
|
|
super();
|
|
this.setCoordinates(coordinates, layout);
|
|
}
|
|
/**
|
|
* Make a complete copy of the geometry.
|
|
* @return {!Point} Clone.
|
|
* @api
|
|
* @override
|
|
*/
|
|
clone() {
|
|
const point = new _Point(this.flatCoordinates.slice(), this.layout);
|
|
point.applyProperties(this);
|
|
return point;
|
|
}
|
|
/**
|
|
* @param {number} x X.
|
|
* @param {number} y Y.
|
|
* @param {import("../coordinate.js").Coordinate} closestPoint Closest point.
|
|
* @param {number} minSquaredDistance Minimum squared distance.
|
|
* @return {number} Minimum squared distance.
|
|
* @override
|
|
*/
|
|
closestPointXY(x, y, closestPoint, minSquaredDistance) {
|
|
const flatCoordinates = this.flatCoordinates;
|
|
const squaredDistance2 = squaredDistance(
|
|
x,
|
|
y,
|
|
flatCoordinates[0],
|
|
flatCoordinates[1]
|
|
);
|
|
if (squaredDistance2 < minSquaredDistance) {
|
|
const stride = this.stride;
|
|
for (let i = 0; i < stride; ++i) {
|
|
closestPoint[i] = flatCoordinates[i];
|
|
}
|
|
closestPoint.length = stride;
|
|
return squaredDistance2;
|
|
}
|
|
return minSquaredDistance;
|
|
}
|
|
/**
|
|
* Return the coordinate of the point.
|
|
* @return {import("../coordinate.js").Coordinate} Coordinates.
|
|
* @api
|
|
* @override
|
|
*/
|
|
getCoordinates() {
|
|
return this.flatCoordinates.slice();
|
|
}
|
|
/**
|
|
* @param {import("../extent.js").Extent} extent Extent.
|
|
* @protected
|
|
* @return {import("../extent.js").Extent} extent Extent.
|
|
* @override
|
|
*/
|
|
computeExtent(extent) {
|
|
return createOrUpdateFromCoordinate(this.flatCoordinates, extent);
|
|
}
|
|
/**
|
|
* Get the type of this geometry.
|
|
* @return {import("./Geometry.js").Type} Geometry type.
|
|
* @api
|
|
* @override
|
|
*/
|
|
getType() {
|
|
return "Point";
|
|
}
|
|
/**
|
|
* Test if the geometry and the passed extent intersect.
|
|
* @param {import("../extent.js").Extent} extent Extent.
|
|
* @return {boolean} `true` if the geometry and the extent intersect.
|
|
* @api
|
|
* @override
|
|
*/
|
|
intersectsExtent(extent) {
|
|
return containsXY(extent, this.flatCoordinates[0], this.flatCoordinates[1]);
|
|
}
|
|
/**
|
|
* @param {!Array<*>} coordinates Coordinates.
|
|
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
|
|
* @api
|
|
* @override
|
|
*/
|
|
setCoordinates(coordinates, layout) {
|
|
this.setLayout(layout, coordinates, 0);
|
|
if (!this.flatCoordinates) {
|
|
this.flatCoordinates = [];
|
|
}
|
|
this.flatCoordinates.length = deflateCoordinate(
|
|
this.flatCoordinates,
|
|
0,
|
|
coordinates,
|
|
this.stride
|
|
);
|
|
this.changed();
|
|
}
|
|
};
|
|
var Point_default = Point;
|
|
|
|
export {
|
|
Point_default
|
|
};
|
|
//# sourceMappingURL=chunk-GA6VLMXX.js.map
|