pwaLUPMIS2/node_modules/.vite/deps/chunk-AZGMK675.js
2026-03-04 12:59:40 +01:00

2011 lines
56 KiB
JavaScript

import {
compose,
create,
intersectsLinearRingArray,
linearRingsContainsXY
} from "./chunk-X52LGBOS.js";
import {
get,
getTransform
} from "./chunk-A3RXLHYB.js";
import {
offset
} from "./chunk-ZLPTRF2L.js";
import {
lerp,
modulo,
squaredDistance,
squaredSegmentDistance
} from "./chunk-54BTDBAD.js";
import {
Object_default,
abstract
} from "./chunk-Q5ZULJHM.js";
import {
ascending,
extend,
memoizeOne
} from "./chunk-K25ZO44T.js";
import {
closestSquaredDistanceXY,
containsXY,
createEmpty,
createOrUpdateEmpty,
createOrUpdateFromCoordinate,
createOrUpdateFromFlatCoordinates,
getCenter,
getHeight,
isEmpty,
returnOrUpdate
} from "./chunk-SRXHWJOY.js";
// node_modules/ol/geom/flat/transform.js
function transform2D(flatCoordinates, offset2, end, stride, transform, dest, destinationStride) {
dest = dest ? dest : [];
destinationStride = destinationStride ? destinationStride : 2;
let i = 0;
for (let j = offset2; j < end; j += stride) {
const x = flatCoordinates[j];
const y = flatCoordinates[j + 1];
dest[i++] = transform[0] * x + transform[2] * y + transform[4];
dest[i++] = transform[1] * x + transform[3] * y + transform[5];
for (let k = 2; k < destinationStride; k++) {
dest[i++] = flatCoordinates[j + k];
}
}
if (dest && dest.length != i) {
dest.length = i;
}
return dest;
}
function rotate(flatCoordinates, offset2, end, stride, angle, anchor, dest) {
dest = dest ? dest : [];
const cos = Math.cos(angle);
const sin = Math.sin(angle);
const anchorX = anchor[0];
const anchorY = anchor[1];
let i = 0;
for (let j = offset2; j < end; j += stride) {
const deltaX = flatCoordinates[j] - anchorX;
const deltaY = flatCoordinates[j + 1] - anchorY;
dest[i++] = anchorX + deltaX * cos - deltaY * sin;
dest[i++] = anchorY + deltaX * sin + deltaY * cos;
for (let k = j + 2; k < j + stride; ++k) {
dest[i++] = flatCoordinates[k];
}
}
if (dest && dest.length != i) {
dest.length = i;
}
return dest;
}
function scale(flatCoordinates, offset2, end, stride, sx, sy, anchor, dest) {
dest = dest ? dest : [];
const anchorX = anchor[0];
const anchorY = anchor[1];
let i = 0;
for (let j = offset2; j < end; j += stride) {
const deltaX = flatCoordinates[j] - anchorX;
const deltaY = flatCoordinates[j + 1] - anchorY;
dest[i++] = anchorX + sx * deltaX;
dest[i++] = anchorY + sy * deltaY;
for (let k = j + 2; k < j + stride; ++k) {
dest[i++] = flatCoordinates[k];
}
}
if (dest && dest.length != i) {
dest.length = i;
}
return dest;
}
function translate(flatCoordinates, offset2, end, stride, deltaX, deltaY, dest) {
dest = dest ? dest : [];
let i = 0;
for (let j = offset2; j < end; j += stride) {
dest[i++] = flatCoordinates[j] + deltaX;
dest[i++] = flatCoordinates[j + 1] + deltaY;
for (let k = j + 2; k < j + stride; ++k) {
dest[i++] = flatCoordinates[k];
}
}
if (dest && dest.length != i) {
dest.length = i;
}
return dest;
}
// node_modules/ol/geom/Geometry.js
var tmpTransform = create();
var tmpPoint = [NaN, NaN];
var Geometry = class extends Object_default {
constructor() {
super();
this.extent_ = createEmpty();
this.extentRevision_ = -1;
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
this.simplifiedGeometryRevision = 0;
this.simplifyTransformedInternal = memoizeOne(
(revision, squaredTolerance, transform) => {
if (!transform) {
return this.getSimplifiedGeometry(squaredTolerance);
}
const clone = this.clone();
clone.applyTransform(transform);
return clone.getSimplifiedGeometry(squaredTolerance);
}
);
}
/**
* Get a transformed and simplified version of the geometry.
* @abstract
* @param {number} squaredTolerance Squared tolerance.
* @param {import("../proj.js").TransformFunction} [transform] Optional transform function.
* @return {Geometry} Simplified geometry.
*/
simplifyTransformed(squaredTolerance, transform) {
return this.simplifyTransformedInternal(
this.getRevision(),
squaredTolerance,
transform
);
}
/**
* Make a complete copy of the geometry.
* @abstract
* @return {!Geometry} Clone.
*/
clone() {
return abstract();
}
/**
* @abstract
* @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.
*/
closestPointXY(x, y, closestPoint, minSquaredDistance) {
return abstract();
}
/**
* @param {number} x X.
* @param {number} y Y.
* @return {boolean} Contains (x, y).
*/
containsXY(x, y) {
return this.closestPointXY(x, y, tmpPoint, Number.MIN_VALUE) === 0;
}
/**
* Return the closest point of the geometry to the passed point as
* {@link module:ol/coordinate~Coordinate coordinate}.
* @param {import("../coordinate.js").Coordinate} point Point.
* @param {import("../coordinate.js").Coordinate} [closestPoint] Closest point.
* @return {import("../coordinate.js").Coordinate} Closest point.
* @api
*/
getClosestPoint(point, closestPoint) {
closestPoint = closestPoint ? closestPoint : [NaN, NaN];
this.closestPointXY(point[0], point[1], closestPoint, Infinity);
return closestPoint;
}
/**
* Returns true if this geometry includes the specified coordinate. If the
* coordinate is on the boundary of the geometry, returns false.
* @param {import("../coordinate.js").Coordinate} coordinate Coordinate.
* @return {boolean} Contains coordinate.
* @api
*/
intersectsCoordinate(coordinate) {
return this.containsXY(coordinate[0], coordinate[1]);
}
/**
* @abstract
* @param {import("../extent.js").Extent} extent Extent.
* @protected
* @return {import("../extent.js").Extent} extent Extent.
*/
computeExtent(extent) {
return abstract();
}
/**
* Get the extent of the geometry.
* @param {import("../extent.js").Extent} [extent] Extent.
* @return {import("../extent.js").Extent} extent Extent.
* @api
*/
getExtent(extent) {
if (this.extentRevision_ != this.getRevision()) {
const extent2 = this.computeExtent(this.extent_);
if (isNaN(extent2[0]) || isNaN(extent2[1])) {
createOrUpdateEmpty(extent2);
}
this.extentRevision_ = this.getRevision();
}
return returnOrUpdate(this.extent_, extent);
}
/**
* Rotate the geometry around a given coordinate. This modifies the geometry
* coordinates in place.
* @abstract
* @param {number} angle Rotation angle in radians.
* @param {import("../coordinate.js").Coordinate} anchor The rotation center.
* @api
*/
rotate(angle, anchor) {
abstract();
}
/**
* Scale the geometry (with an optional origin). This modifies the geometry
* coordinates in place.
* @abstract
* @param {number} sx The scaling factor in the x-direction.
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
* of the geometry extent).
* @api
*/
scale(sx, sy, anchor) {
abstract();
}
/**
* Create a simplified version of this geometry. For linestrings, this uses
* the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)
* algorithm. For polygons, a quantization-based
* simplification is used to preserve topology.
* @param {number} tolerance The tolerance distance for simplification.
* @return {Geometry} A new, simplified version of the original geometry.
* @api
*/
simplify(tolerance) {
return this.getSimplifiedGeometry(tolerance * tolerance);
}
/**
* Create a simplified version of this geometry using the Douglas Peucker
* algorithm.
* See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.
* @abstract
* @param {number} squaredTolerance Squared tolerance.
* @return {Geometry} Simplified geometry.
*/
getSimplifiedGeometry(squaredTolerance) {
return abstract();
}
/**
* Get the type of this geometry.
* @abstract
* @return {Type} Geometry type.
*/
getType() {
return abstract();
}
/**
* Apply a transform function to the coordinates of the geometry.
* The geometry is modified in place.
* If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone.
* @abstract
* @param {import("../proj.js").TransformFunction} transformFn Transform function.
* Called with a flat array of geometry coordinates.
*/
applyTransform(transformFn) {
abstract();
}
/**
* Test if the geometry and the passed extent intersect.
* @abstract
* @param {import("../extent.js").Extent} extent Extent.
* @return {boolean} `true` if the geometry and the extent intersect.
*/
intersectsExtent(extent) {
return abstract();
}
/**
* Translate the geometry. This modifies the geometry coordinates in place. If
* instead you want a new geometry, first `clone()` this geometry.
* @abstract
* @param {number} deltaX Delta X.
* @param {number} deltaY Delta Y.
* @api
*/
translate(deltaX, deltaY) {
abstract();
}
/**
* Transform each coordinate of the geometry from one coordinate reference
* system to another. The geometry is modified in place.
* For example, a line will be transformed to a line and a circle to a circle.
* If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone.
*
* @param {import("../proj.js").ProjectionLike} source The current projection. Can be a
* string identifier or a {@link module:ol/proj/Projection~Projection} object.
* @param {import("../proj.js").ProjectionLike} destination The desired projection. Can be a
* string identifier or a {@link module:ol/proj/Projection~Projection} object.
* @return {this} This geometry. Note that original geometry is
* modified in place.
* @api
*/
transform(source, destination) {
const sourceProj = get(source);
const transformFn = sourceProj.getUnits() == "tile-pixels" ? function(inCoordinates, outCoordinates, stride) {
const pixelExtent = sourceProj.getExtent();
const projectedExtent = sourceProj.getWorldExtent();
const scale2 = getHeight(projectedExtent) / getHeight(pixelExtent);
compose(
tmpTransform,
projectedExtent[0],
projectedExtent[3],
scale2,
-scale2,
0,
0,
0
);
const transformed = transform2D(
inCoordinates,
0,
inCoordinates.length,
stride,
tmpTransform,
outCoordinates
);
const projTransform = getTransform(sourceProj, destination);
if (projTransform) {
return projTransform(transformed, transformed, stride);
}
return transformed;
} : getTransform(sourceProj, destination);
this.applyTransform(transformFn);
return this;
}
};
var Geometry_default = Geometry;
// node_modules/ol/geom/SimpleGeometry.js
var SimpleGeometry = class extends Geometry_default {
constructor() {
super();
this.layout = "XY";
this.stride = 2;
this.flatCoordinates;
}
/**
* @param {import("../extent.js").Extent} extent Extent.
* @protected
* @return {import("../extent.js").Extent} extent Extent.
* @override
*/
computeExtent(extent) {
return createOrUpdateFromFlatCoordinates(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
extent
);
}
/**
* @abstract
* @return {Array<*> | null} Coordinates.
*/
getCoordinates() {
return abstract();
}
/**
* Return the first coordinate of the geometry.
* @return {import("../coordinate.js").Coordinate} First coordinate.
* @api
*/
getFirstCoordinate() {
return this.flatCoordinates.slice(0, this.stride);
}
/**
* @return {Array<number>} Flat coordinates.
*/
getFlatCoordinates() {
return this.flatCoordinates;
}
/**
* Return the last coordinate of the geometry.
* @return {import("../coordinate.js").Coordinate} Last point.
* @api
*/
getLastCoordinate() {
return this.flatCoordinates.slice(
this.flatCoordinates.length - this.stride
);
}
/**
* Return the {@link import("./Geometry.js").GeometryLayout layout} of the geometry.
* @return {import("./Geometry.js").GeometryLayout} Layout.
* @api
*/
getLayout() {
return this.layout;
}
/**
* Create a simplified version of this geometry using the Douglas Peucker algorithm.
* @param {number} squaredTolerance Squared tolerance.
* @return {SimpleGeometry} Simplified geometry.
* @override
*/
getSimplifiedGeometry(squaredTolerance) {
if (this.simplifiedGeometryRevision !== this.getRevision()) {
this.simplifiedGeometryMaxMinSquaredTolerance = 0;
this.simplifiedGeometryRevision = this.getRevision();
}
if (squaredTolerance < 0 || this.simplifiedGeometryMaxMinSquaredTolerance !== 0 && squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance) {
return this;
}
const simplifiedGeometry = this.getSimplifiedGeometryInternal(squaredTolerance);
const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();
if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {
return simplifiedGeometry;
}
this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;
return this;
}
/**
* @param {number} squaredTolerance Squared tolerance.
* @return {SimpleGeometry} Simplified geometry.
* @protected
*/
getSimplifiedGeometryInternal(squaredTolerance) {
return this;
}
/**
* @return {number} Stride.
*/
getStride() {
return this.stride;
}
/**
* @param {import("./Geometry.js").GeometryLayout} layout Layout.
* @param {Array<number>} flatCoordinates Flat coordinates.
*/
setFlatCoordinates(layout, flatCoordinates) {
this.stride = getStrideForLayout(layout);
this.layout = layout;
this.flatCoordinates = flatCoordinates;
}
/**
* @abstract
* @param {!Array<*>} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
*/
setCoordinates(coordinates2, layout) {
abstract();
}
/**
* @param {import("./Geometry.js").GeometryLayout|undefined} layout Layout.
* @param {Array<*>} coordinates Coordinates.
* @param {number} nesting Nesting.
* @protected
*/
setLayout(layout, coordinates2, nesting) {
let stride;
if (layout) {
stride = getStrideForLayout(layout);
} else {
for (let i = 0; i < nesting; ++i) {
if (coordinates2.length === 0) {
this.layout = "XY";
this.stride = 2;
return;
}
coordinates2 = /** @type {Array<unknown>} */
coordinates2[0];
}
stride = coordinates2.length;
layout = getLayoutForStride(stride);
}
this.layout = layout;
this.stride = stride;
}
/**
* Apply a transform function to the coordinates of the geometry.
* The geometry is modified in place.
* If you do not want the geometry modified in place, first `clone()` it and
* then use this function on the clone.
* @param {import("../proj.js").TransformFunction} transformFn Transform function.
* Called with a flat array of geometry coordinates.
* @api
* @override
*/
applyTransform(transformFn) {
if (this.flatCoordinates) {
transformFn(
this.flatCoordinates,
this.flatCoordinates,
this.layout.startsWith("XYZ") ? 3 : 2,
this.stride
);
this.changed();
}
}
/**
* Rotate the geometry around a given coordinate. This modifies the geometry
* coordinates in place.
* @param {number} angle Rotation angle in counter-clockwise radians.
* @param {import("../coordinate.js").Coordinate} anchor The rotation center.
* @api
* @override
*/
rotate(angle, anchor) {
const flatCoordinates = this.getFlatCoordinates();
if (flatCoordinates) {
const stride = this.getStride();
rotate(
flatCoordinates,
0,
flatCoordinates.length,
stride,
angle,
anchor,
flatCoordinates
);
this.changed();
}
}
/**
* Scale the geometry (with an optional origin). This modifies the geometry
* coordinates in place.
* @param {number} sx The scaling factor in the x-direction.
* @param {number} [sy] The scaling factor in the y-direction (defaults to sx).
* @param {import("../coordinate.js").Coordinate} [anchor] The scale origin (defaults to the center
* of the geometry extent).
* @api
* @override
*/
scale(sx, sy, anchor) {
if (sy === void 0) {
sy = sx;
}
if (!anchor) {
anchor = getCenter(this.getExtent());
}
const flatCoordinates = this.getFlatCoordinates();
if (flatCoordinates) {
const stride = this.getStride();
scale(
flatCoordinates,
0,
flatCoordinates.length,
stride,
sx,
sy,
anchor,
flatCoordinates
);
this.changed();
}
}
/**
* Translate the geometry. This modifies the geometry coordinates in place. If
* instead you want a new geometry, first `clone()` this geometry.
* @param {number} deltaX Delta X.
* @param {number} deltaY Delta Y.
* @api
* @override
*/
translate(deltaX, deltaY) {
const flatCoordinates = this.getFlatCoordinates();
if (flatCoordinates) {
const stride = this.getStride();
translate(
flatCoordinates,
0,
flatCoordinates.length,
stride,
deltaX,
deltaY,
flatCoordinates
);
this.changed();
}
}
};
function getLayoutForStride(stride) {
let layout;
if (stride == 2) {
layout = "XY";
} else if (stride == 3) {
layout = "XYZ";
} else if (stride == 4) {
layout = "XYZM";
}
return (
/** @type {import("./Geometry.js").GeometryLayout} */
layout
);
}
function getStrideForLayout(layout) {
let stride;
if (layout == "XY") {
stride = 2;
} else if (layout == "XYZ" || layout == "XYM") {
stride = 3;
} else if (layout == "XYZM") {
stride = 4;
}
return (
/** @type {number} */
stride
);
}
function transformGeom2D(simpleGeometry, transform, dest) {
const flatCoordinates = simpleGeometry.getFlatCoordinates();
if (!flatCoordinates) {
return null;
}
const stride = simpleGeometry.getStride();
return transform2D(
flatCoordinates,
0,
flatCoordinates.length,
stride,
transform,
dest
);
}
var SimpleGeometry_default = SimpleGeometry;
// node_modules/ol/geom/flat/area.js
function linearRing(flatCoordinates, offset2, end, stride) {
let twiceArea = 0;
const x0 = flatCoordinates[end - stride];
const y0 = flatCoordinates[end - stride + 1];
let dx1 = 0;
let dy1 = 0;
for (; offset2 < end; offset2 += stride) {
const dx2 = flatCoordinates[offset2] - x0;
const dy2 = flatCoordinates[offset2 + 1] - y0;
twiceArea += dy1 * dx2 - dx1 * dy2;
dx1 = dx2;
dy1 = dy2;
}
return twiceArea / 2;
}
function linearRings(flatCoordinates, offset2, ends, stride) {
let area = 0;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
area += linearRing(flatCoordinates, offset2, end, stride);
offset2 = end;
}
return area;
}
function linearRingss(flatCoordinates, offset2, endss, stride) {
let area = 0;
for (let i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
area += linearRings(flatCoordinates, offset2, ends, stride);
offset2 = ends[ends.length - 1];
}
return area;
}
// node_modules/ol/geom/flat/closest.js
function assignClosest(flatCoordinates, offset1, offset2, stride, x, y, closestPoint) {
const x1 = flatCoordinates[offset1];
const y1 = flatCoordinates[offset1 + 1];
const dx = flatCoordinates[offset2] - x1;
const dy = flatCoordinates[offset2 + 1] - y1;
let offset3;
if (dx === 0 && dy === 0) {
offset3 = offset1;
} else {
const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);
if (t > 1) {
offset3 = offset2;
} else if (t > 0) {
for (let i = 0; i < stride; ++i) {
closestPoint[i] = lerp(
flatCoordinates[offset1 + i],
flatCoordinates[offset2 + i],
t
);
}
closestPoint.length = stride;
return;
} else {
offset3 = offset1;
}
}
for (let i = 0; i < stride; ++i) {
closestPoint[i] = flatCoordinates[offset3 + i];
}
closestPoint.length = stride;
}
function maxSquaredDelta(flatCoordinates, offset2, end, stride, max) {
let x1 = flatCoordinates[offset2];
let y1 = flatCoordinates[offset2 + 1];
for (offset2 += stride; offset2 < end; offset2 += stride) {
const x2 = flatCoordinates[offset2];
const y2 = flatCoordinates[offset2 + 1];
const squaredDelta = squaredDistance(x1, y1, x2, y2);
if (squaredDelta > max) {
max = squaredDelta;
}
x1 = x2;
y1 = y2;
}
return max;
}
function arrayMaxSquaredDelta(flatCoordinates, offset2, ends, stride, max) {
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
max = maxSquaredDelta(flatCoordinates, offset2, end, stride, max);
offset2 = end;
}
return max;
}
function multiArrayMaxSquaredDelta(flatCoordinates, offset2, endss, stride, max) {
for (let i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
max = arrayMaxSquaredDelta(flatCoordinates, offset2, ends, stride, max);
offset2 = ends[ends.length - 1];
}
return max;
}
function assignClosestPoint(flatCoordinates, offset2, end, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint2) {
if (offset2 == end) {
return minSquaredDistance;
}
let i, squaredDistance2;
if (maxDelta === 0) {
squaredDistance2 = squaredDistance(
x,
y,
flatCoordinates[offset2],
flatCoordinates[offset2 + 1]
);
if (squaredDistance2 < minSquaredDistance) {
for (i = 0; i < stride; ++i) {
closestPoint[i] = flatCoordinates[offset2 + i];
}
closestPoint.length = stride;
return squaredDistance2;
}
return minSquaredDistance;
}
tmpPoint2 = tmpPoint2 ? tmpPoint2 : [NaN, NaN];
let index = offset2 + stride;
while (index < end) {
assignClosest(
flatCoordinates,
index - stride,
index,
stride,
x,
y,
tmpPoint2
);
squaredDistance2 = squaredDistance(x, y, tmpPoint2[0], tmpPoint2[1]);
if (squaredDistance2 < minSquaredDistance) {
minSquaredDistance = squaredDistance2;
for (i = 0; i < stride; ++i) {
closestPoint[i] = tmpPoint2[i];
}
closestPoint.length = stride;
index += stride;
} else {
index += stride * Math.max(
(Math.sqrt(squaredDistance2) - Math.sqrt(minSquaredDistance)) / maxDelta | 0,
1
);
}
}
if (isRing) {
assignClosest(
flatCoordinates,
end - stride,
offset2,
stride,
x,
y,
tmpPoint2
);
squaredDistance2 = squaredDistance(x, y, tmpPoint2[0], tmpPoint2[1]);
if (squaredDistance2 < minSquaredDistance) {
minSquaredDistance = squaredDistance2;
for (i = 0; i < stride; ++i) {
closestPoint[i] = tmpPoint2[i];
}
closestPoint.length = stride;
}
}
return minSquaredDistance;
}
function assignClosestArrayPoint(flatCoordinates, offset2, ends, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint2) {
tmpPoint2 = tmpPoint2 ? tmpPoint2 : [NaN, NaN];
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
minSquaredDistance = assignClosestPoint(
flatCoordinates,
offset2,
end,
stride,
maxDelta,
isRing,
x,
y,
closestPoint,
minSquaredDistance,
tmpPoint2
);
offset2 = end;
}
return minSquaredDistance;
}
function assignClosestMultiArrayPoint(flatCoordinates, offset2, endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, tmpPoint2) {
tmpPoint2 = tmpPoint2 ? tmpPoint2 : [NaN, NaN];
for (let i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
minSquaredDistance = assignClosestArrayPoint(
flatCoordinates,
offset2,
ends,
stride,
maxDelta,
isRing,
x,
y,
closestPoint,
minSquaredDistance,
tmpPoint2
);
offset2 = ends[ends.length - 1];
}
return minSquaredDistance;
}
// node_modules/ol/geom/flat/deflate.js
function deflateCoordinate(flatCoordinates, offset2, coordinate, stride) {
for (let i = 0, ii = coordinate.length; i < ii; ++i) {
flatCoordinates[offset2++] = coordinate[i];
}
return offset2;
}
function deflateCoordinates(flatCoordinates, offset2, coordinates2, stride) {
for (let i = 0, ii = coordinates2.length; i < ii; ++i) {
const coordinate = coordinates2[i];
for (let j = 0; j < stride; ++j) {
flatCoordinates[offset2++] = coordinate[j];
}
}
return offset2;
}
function deflateCoordinatesArray(flatCoordinates, offset2, coordinatess, stride, ends) {
ends = ends ? ends : [];
let i = 0;
for (let j = 0, jj = coordinatess.length; j < jj; ++j) {
const end = deflateCoordinates(
flatCoordinates,
offset2,
coordinatess[j],
stride
);
ends[i++] = end;
offset2 = end;
}
ends.length = i;
return ends;
}
function deflateMultiCoordinatesArray(flatCoordinates, offset2, coordinatesss, stride, endss) {
endss = endss ? endss : [];
let i = 0;
for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {
const ends = deflateCoordinatesArray(
flatCoordinates,
offset2,
coordinatesss[j],
stride,
endss[i]
);
if (ends.length === 0) {
ends[0] = offset2;
}
endss[i++] = ends;
offset2 = ends[ends.length - 1];
}
endss.length = i;
return endss;
}
// node_modules/ol/geom/flat/inflate.js
function inflateCoordinates(flatCoordinates, offset2, end, stride, coordinates2) {
coordinates2 = coordinates2 !== void 0 ? coordinates2 : [];
let i = 0;
for (let j = offset2; j < end; j += stride) {
coordinates2[i++] = flatCoordinates.slice(j, j + stride);
}
coordinates2.length = i;
return coordinates2;
}
function inflateCoordinatesArray(flatCoordinates, offset2, ends, stride, coordinatess) {
coordinatess = coordinatess !== void 0 ? coordinatess : [];
let i = 0;
for (let j = 0, jj = ends.length; j < jj; ++j) {
const end = ends[j];
coordinatess[i++] = inflateCoordinates(
flatCoordinates,
offset2,
end,
stride,
coordinatess[i]
);
offset2 = end;
}
coordinatess.length = i;
return coordinatess;
}
function inflateMultiCoordinatesArray(flatCoordinates, offset2, endss, stride, coordinatesss) {
coordinatesss = coordinatesss !== void 0 ? coordinatesss : [];
let i = 0;
for (let j = 0, jj = endss.length; j < jj; ++j) {
const ends = endss[j];
coordinatesss[i++] = ends.length === 1 && ends[0] === offset2 ? [] : inflateCoordinatesArray(
flatCoordinates,
offset2,
ends,
stride,
coordinatesss[i]
);
offset2 = ends[ends.length - 1];
}
coordinatesss.length = i;
return coordinatesss;
}
// node_modules/ol/geom/flat/simplify.js
function douglasPeucker(flatCoordinates, offset2, end, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset) {
const n = (end - offset2) / stride;
if (n < 3) {
for (; offset2 < end; offset2 += stride) {
simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset2];
simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset2 + 1];
}
return simplifiedOffset;
}
const markers = new Array(n);
markers[0] = 1;
markers[n - 1] = 1;
const stack = [offset2, end - stride];
let index = 0;
while (stack.length > 0) {
const last = stack.pop();
const first = stack.pop();
let maxSquaredDistance = 0;
const x1 = flatCoordinates[first];
const y1 = flatCoordinates[first + 1];
const x2 = flatCoordinates[last];
const y2 = flatCoordinates[last + 1];
for (let i = first + stride; i < last; i += stride) {
const x = flatCoordinates[i];
const y = flatCoordinates[i + 1];
const squaredDistance2 = squaredSegmentDistance(x, y, x1, y1, x2, y2);
if (squaredDistance2 > maxSquaredDistance) {
index = i;
maxSquaredDistance = squaredDistance2;
}
}
if (maxSquaredDistance > squaredTolerance) {
markers[(index - offset2) / stride] = 1;
if (first + stride < index) {
stack.push(first, index);
}
if (index + stride < last) {
stack.push(index, last);
}
}
}
for (let i = 0; i < n; ++i) {
if (markers[i]) {
simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset2 + i * stride];
simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset2 + i * stride + 1];
}
}
return simplifiedOffset;
}
function douglasPeuckerArray(flatCoordinates, offset2, ends, stride, squaredTolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
simplifiedOffset = douglasPeucker(
flatCoordinates,
offset2,
end,
stride,
squaredTolerance,
simplifiedFlatCoordinates,
simplifiedOffset
);
simplifiedEnds.push(simplifiedOffset);
offset2 = end;
}
return simplifiedOffset;
}
function snap(value, tolerance) {
return tolerance * Math.round(value / tolerance);
}
function quantize(flatCoordinates, offset2, end, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset) {
if (offset2 == end) {
return simplifiedOffset;
}
let x1 = snap(flatCoordinates[offset2], tolerance);
let y1 = snap(flatCoordinates[offset2 + 1], tolerance);
offset2 += stride;
simplifiedFlatCoordinates[simplifiedOffset++] = x1;
simplifiedFlatCoordinates[simplifiedOffset++] = y1;
let x2, y2;
do {
x2 = snap(flatCoordinates[offset2], tolerance);
y2 = snap(flatCoordinates[offset2 + 1], tolerance);
offset2 += stride;
if (offset2 == end) {
simplifiedFlatCoordinates[simplifiedOffset++] = x2;
simplifiedFlatCoordinates[simplifiedOffset++] = y2;
return simplifiedOffset;
}
} while (x2 == x1 && y2 == y1);
while (offset2 < end) {
const x3 = snap(flatCoordinates[offset2], tolerance);
const y3 = snap(flatCoordinates[offset2 + 1], tolerance);
offset2 += stride;
if (x3 == x2 && y3 == y2) {
continue;
}
const dx1 = x2 - x1;
const dy1 = y2 - y1;
const dx2 = x3 - x1;
const dy2 = y3 - y1;
if (dx1 * dy2 == dy1 * dx2 && (dx1 < 0 && dx2 < dx1 || dx1 == dx2 || dx1 > 0 && dx2 > dx1) && (dy1 < 0 && dy2 < dy1 || dy1 == dy2 || dy1 > 0 && dy2 > dy1)) {
x2 = x3;
y2 = y3;
continue;
}
simplifiedFlatCoordinates[simplifiedOffset++] = x2;
simplifiedFlatCoordinates[simplifiedOffset++] = y2;
x1 = x2;
y1 = y2;
x2 = x3;
y2 = y3;
}
simplifiedFlatCoordinates[simplifiedOffset++] = x2;
simplifiedFlatCoordinates[simplifiedOffset++] = y2;
return simplifiedOffset;
}
function quantizeArray(flatCoordinates, offset2, ends, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEnds) {
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
simplifiedOffset = quantize(
flatCoordinates,
offset2,
end,
stride,
tolerance,
simplifiedFlatCoordinates,
simplifiedOffset
);
simplifiedEnds.push(simplifiedOffset);
offset2 = end;
}
return simplifiedOffset;
}
function quantizeMultiArray(flatCoordinates, offset2, endss, stride, tolerance, simplifiedFlatCoordinates, simplifiedOffset, simplifiedEndss) {
for (let i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
const simplifiedEnds = [];
simplifiedOffset = quantizeArray(
flatCoordinates,
offset2,
ends,
stride,
tolerance,
simplifiedFlatCoordinates,
simplifiedOffset,
simplifiedEnds
);
simplifiedEndss.push(simplifiedEnds);
offset2 = ends[ends.length - 1];
}
return simplifiedOffset;
}
// node_modules/ol/geom/LinearRing.js
var LinearRing = class _LinearRing extends SimpleGeometry_default {
/**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* For internal use, flat coordinates in combination with `layout` are also accepted.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
*/
constructor(coordinates2, layout) {
super();
this.maxDelta_ = -1;
this.maxDeltaRevision_ = -1;
if (layout !== void 0 && !Array.isArray(coordinates2[0])) {
this.setFlatCoordinates(
layout,
/** @type {Array<number>} */
coordinates2
);
} else {
this.setCoordinates(
/** @type {Array<import("../coordinate.js").Coordinate>} */
coordinates2,
layout
);
}
}
/**
* Make a complete copy of the geometry.
* @return {!LinearRing} Clone.
* @api
* @override
*/
clone() {
return new _LinearRing(this.flatCoordinates.slice(), this.layout);
}
/**
* @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) {
if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
return minSquaredDistance;
}
if (this.maxDeltaRevision_ != this.getRevision()) {
this.maxDelta_ = Math.sqrt(
maxSquaredDelta(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
0
)
);
this.maxDeltaRevision_ = this.getRevision();
}
return assignClosestPoint(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
this.maxDelta_,
true,
x,
y,
closestPoint,
minSquaredDistance
);
}
/**
* Return the area of the linear ring on projected plane.
* @return {number} Area (on projected plane).
* @api
*/
getArea() {
return linearRing(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride
);
}
/**
* Return the coordinates of the linear ring.
* @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
* @api
* @override
*/
getCoordinates() {
return inflateCoordinates(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride
);
}
/**
* @param {number} squaredTolerance Squared tolerance.
* @return {LinearRing} Simplified LinearRing.
* @protected
* @override
*/
getSimplifiedGeometryInternal(squaredTolerance) {
const simplifiedFlatCoordinates = [];
simplifiedFlatCoordinates.length = douglasPeucker(
this.flatCoordinates,
0,
this.flatCoordinates.length,
this.stride,
squaredTolerance,
simplifiedFlatCoordinates,
0
);
return new _LinearRing(simplifiedFlatCoordinates, "XY");
}
/**
* Get the type of this geometry.
* @return {import("./Geometry.js").Type} Geometry type.
* @api
* @override
*/
getType() {
return "LinearRing";
}
/**
* 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 false;
}
/**
* Set the coordinates of the linear ring.
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
* @api
* @override
*/
setCoordinates(coordinates2, layout) {
this.setLayout(layout, coordinates2, 1);
if (!this.flatCoordinates) {
this.flatCoordinates = [];
}
this.flatCoordinates.length = deflateCoordinates(
this.flatCoordinates,
0,
coordinates2,
this.stride
);
this.changed();
}
};
var LinearRing_default = LinearRing;
// 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(coordinates2, layout) {
super();
this.setCoordinates(coordinates2, 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(coordinates2, layout) {
this.setLayout(layout, coordinates2, 0);
if (!this.flatCoordinates) {
this.flatCoordinates = [];
}
this.flatCoordinates.length = deflateCoordinate(
this.flatCoordinates,
0,
coordinates2,
this.stride
);
this.changed();
}
};
var Point_default = Point;
// node_modules/ol/geom/flat/interiorpoint.js
function getInteriorPointOfArray(flatCoordinates, offset2, ends, stride, flatCenters, flatCentersOffset, dest) {
let i, ii, x, x1, x2, y1, y2;
const y = flatCenters[flatCentersOffset + 1];
const intersections = [];
for (let r = 0, rr = ends.length; r < rr; ++r) {
const end = ends[r];
x1 = flatCoordinates[end - stride];
y1 = flatCoordinates[end - stride + 1];
for (i = offset2; i < end; i += stride) {
x2 = flatCoordinates[i];
y2 = flatCoordinates[i + 1];
if (y <= y1 && y2 <= y || y1 <= y && y <= y2) {
x = (y - y1) / (y2 - y1) * (x2 - x1) + x1;
intersections.push(x);
}
x1 = x2;
y1 = y2;
}
}
let pointX = NaN;
let maxSegmentLength = -Infinity;
intersections.sort(ascending);
x1 = intersections[0];
for (i = 1, ii = intersections.length; i < ii; ++i) {
x2 = intersections[i];
const segmentLength = Math.abs(x2 - x1);
if (segmentLength > maxSegmentLength) {
x = (x1 + x2) / 2;
if (linearRingsContainsXY(flatCoordinates, offset2, ends, stride, x, y)) {
pointX = x;
maxSegmentLength = segmentLength;
}
}
x1 = x2;
}
if (isNaN(pointX)) {
pointX = flatCenters[flatCentersOffset];
}
if (dest) {
dest.push(pointX, y, maxSegmentLength);
return dest;
}
return [pointX, y, maxSegmentLength];
}
function getInteriorPointsOfMultiArray(flatCoordinates, offset2, endss, stride, flatCenters) {
let interiorPoints = [];
for (let i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
interiorPoints = getInteriorPointOfArray(
flatCoordinates,
offset2,
ends,
stride,
flatCenters,
2 * i,
interiorPoints
);
offset2 = ends[ends.length - 1];
}
return interiorPoints;
}
// node_modules/ol/geom/flat/reverse.js
function coordinates(flatCoordinates, offset2, end, stride) {
while (offset2 < end - stride) {
for (let i = 0; i < stride; ++i) {
const tmp = flatCoordinates[offset2 + i];
flatCoordinates[offset2 + i] = flatCoordinates[end - stride + i];
flatCoordinates[end - stride + i] = tmp;
}
offset2 += stride;
end -= stride;
}
}
// node_modules/ol/geom/flat/orient.js
function linearRingIsClockwise(flatCoordinates, offset2, end, stride) {
let edge = 0;
let x1 = flatCoordinates[end - stride];
let y1 = flatCoordinates[end - stride + 1];
for (; offset2 < end; offset2 += stride) {
const x2 = flatCoordinates[offset2];
const y2 = flatCoordinates[offset2 + 1];
edge += (x2 - x1) * (y2 + y1);
x1 = x2;
y1 = y2;
}
return edge === 0 ? void 0 : edge > 0;
}
function linearRingsAreOriented(flatCoordinates, offset2, ends, stride, right) {
right = right !== void 0 ? right : false;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const isClockwise = linearRingIsClockwise(
flatCoordinates,
offset2,
end,
stride
);
if (i === 0) {
if (right && isClockwise || !right && !isClockwise) {
return false;
}
} else {
if (right && !isClockwise || !right && isClockwise) {
return false;
}
}
offset2 = end;
}
return true;
}
function linearRingssAreOriented(flatCoordinates, offset2, endss, stride, right) {
for (let i = 0, ii = endss.length; i < ii; ++i) {
const ends = endss[i];
if (!linearRingsAreOriented(flatCoordinates, offset2, ends, stride, right)) {
return false;
}
if (ends.length) {
offset2 = ends[ends.length - 1];
}
}
return true;
}
function orientLinearRings(flatCoordinates, offset2, ends, stride, right) {
right = right !== void 0 ? right : false;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const isClockwise = linearRingIsClockwise(
flatCoordinates,
offset2,
end,
stride
);
const reverse = i === 0 ? right && isClockwise || !right && !isClockwise : right && !isClockwise || !right && isClockwise;
if (reverse) {
coordinates(flatCoordinates, offset2, end, stride);
}
offset2 = end;
}
return offset2;
}
function orientLinearRingsArray(flatCoordinates, offset2, endss, stride, right) {
for (let i = 0, ii = endss.length; i < ii; ++i) {
offset2 = orientLinearRings(
flatCoordinates,
offset2,
endss[i],
stride,
right
);
}
return offset2;
}
function inflateEnds(flatCoordinates, ends) {
const endss = [];
let offset2 = 0;
let prevEndIndex = 0;
let startOrientation;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const orientation = linearRingIsClockwise(flatCoordinates, offset2, end, 2);
if (startOrientation === void 0) {
startOrientation = orientation;
}
if (orientation === startOrientation) {
endss.push(ends.slice(prevEndIndex, i + 1));
} else {
if (endss.length === 0) {
continue;
}
endss[endss.length - 1].push(ends[prevEndIndex]);
}
prevEndIndex = i + 1;
offset2 = end;
}
return endss;
}
// node_modules/ol/geom/Polygon.js
var Polygon = class _Polygon extends SimpleGeometry_default {
/**
* @param {!Array<Array<import("../coordinate.js").Coordinate>>|!Array<number>} coordinates
* Array of linear rings that define the polygon. The first linear ring of the
* array defines the outer-boundary or surface of the polygon. Each subsequent
* linear ring defines a hole in the surface of the polygon. A linear ring is
* an array of vertices' coordinates where the first coordinate and the last are
* equivalent. (For internal use, flat coordinates in combination with
* `layout` and `ends` are also accepted.)
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
* @param {Array<number>} [ends] Ends (for internal use with flat coordinates).
*/
constructor(coordinates2, layout, ends) {
super();
this.ends_ = [];
this.flatInteriorPointRevision_ = -1;
this.flatInteriorPoint_ = null;
this.maxDelta_ = -1;
this.maxDeltaRevision_ = -1;
this.orientedRevision_ = -1;
this.orientedFlatCoordinates_ = null;
if (layout !== void 0 && ends) {
this.setFlatCoordinates(
layout,
/** @type {Array<number>} */
coordinates2
);
this.ends_ = ends;
} else {
this.setCoordinates(
/** @type {Array<Array<import("../coordinate.js").Coordinate>>} */
coordinates2,
layout
);
}
}
/**
* Append the passed linear ring to this polygon.
* @param {LinearRing} linearRing Linear ring.
* @api
*/
appendLinearRing(linearRing2) {
if (!this.flatCoordinates) {
this.flatCoordinates = linearRing2.getFlatCoordinates().slice();
} else {
extend(this.flatCoordinates, linearRing2.getFlatCoordinates());
}
this.ends_.push(this.flatCoordinates.length);
this.changed();
}
/**
* Make a complete copy of the geometry.
* @return {!Polygon} Clone.
* @api
* @override
*/
clone() {
const polygon = new _Polygon(
this.flatCoordinates.slice(),
this.layout,
this.ends_.slice()
);
polygon.applyProperties(this);
return polygon;
}
/**
* @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) {
if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {
return minSquaredDistance;
}
if (this.maxDeltaRevision_ != this.getRevision()) {
this.maxDelta_ = Math.sqrt(
arrayMaxSquaredDelta(
this.flatCoordinates,
0,
this.ends_,
this.stride,
0
)
);
this.maxDeltaRevision_ = this.getRevision();
}
return assignClosestArrayPoint(
this.flatCoordinates,
0,
this.ends_,
this.stride,
this.maxDelta_,
true,
x,
y,
closestPoint,
minSquaredDistance
);
}
/**
* @param {number} x X.
* @param {number} y Y.
* @return {boolean} Contains (x, y).
* @override
*/
containsXY(x, y) {
return linearRingsContainsXY(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride,
x,
y
);
}
/**
* Return the area of the polygon on projected plane.
* @return {number} Area (on projected plane).
* @api
*/
getArea() {
return linearRings(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride
);
}
/**
* Get the coordinate array for this geometry. This array has the structure
* of a GeoJSON coordinate array for polygons.
*
* @param {boolean} [right] Orient coordinates according to the right-hand
* rule (counter-clockwise for exterior and clockwise for interior rings).
* If `false`, coordinates will be oriented according to the left-hand rule
* (clockwise for exterior and counter-clockwise for interior rings).
* By default, coordinate orientation will depend on how the geometry was
* constructed.
* @return {Array<Array<import("../coordinate.js").Coordinate>>} Coordinates.
* @api
* @override
*/
getCoordinates(right) {
let flatCoordinates;
if (right !== void 0) {
flatCoordinates = this.getOrientedFlatCoordinates().slice();
orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, right);
} else {
flatCoordinates = this.flatCoordinates;
}
return inflateCoordinatesArray(flatCoordinates, 0, this.ends_, this.stride);
}
/**
* @return {Array<number>} Ends.
*/
getEnds() {
return this.ends_;
}
/**
* @return {Array<number>} Interior point.
*/
getFlatInteriorPoint() {
if (this.flatInteriorPointRevision_ != this.getRevision()) {
const flatCenter = getCenter(this.getExtent());
this.flatInteriorPoint_ = getInteriorPointOfArray(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride,
flatCenter,
0
);
this.flatInteriorPointRevision_ = this.getRevision();
}
return (
/** @type {import("../coordinate.js").Coordinate} */
this.flatInteriorPoint_
);
}
/**
* Return an interior point of the polygon.
* @return {Point} Interior point as XYM coordinate, where M is the
* length of the horizontal intersection that the point belongs to.
* @api
*/
getInteriorPoint() {
return new Point_default(this.getFlatInteriorPoint(), "XYM");
}
/**
* Return the number of rings of the polygon, this includes the exterior
* ring and any interior rings.
*
* @return {number} Number of rings.
* @api
*/
getLinearRingCount() {
return this.ends_.length;
}
/**
* Return the Nth linear ring of the polygon geometry. Return `null` if the
* given index is out of range.
* The exterior linear ring is available at index `0` and the interior rings
* at index `1` and beyond.
*
* @param {number} index Index.
* @return {LinearRing|null} Linear ring.
* @api
*/
getLinearRing(index) {
if (index < 0 || this.ends_.length <= index) {
return null;
}
return new LinearRing_default(
this.flatCoordinates.slice(
index === 0 ? 0 : this.ends_[index - 1],
this.ends_[index]
),
this.layout
);
}
/**
* Return the linear rings of the polygon.
* @return {Array<LinearRing>} Linear rings.
* @api
*/
getLinearRings() {
const layout = this.layout;
const flatCoordinates = this.flatCoordinates;
const ends = this.ends_;
const linearRings2 = [];
let offset2 = 0;
for (let i = 0, ii = ends.length; i < ii; ++i) {
const end = ends[i];
const linearRing2 = new LinearRing_default(
flatCoordinates.slice(offset2, end),
layout
);
linearRings2.push(linearRing2);
offset2 = end;
}
return linearRings2;
}
/**
* @return {Array<number>} Oriented flat coordinates.
*/
getOrientedFlatCoordinates() {
if (this.orientedRevision_ != this.getRevision()) {
const flatCoordinates = this.flatCoordinates;
if (linearRingsAreOriented(flatCoordinates, 0, this.ends_, this.stride)) {
this.orientedFlatCoordinates_ = flatCoordinates;
} else {
this.orientedFlatCoordinates_ = flatCoordinates.slice();
this.orientedFlatCoordinates_.length = orientLinearRings(
this.orientedFlatCoordinates_,
0,
this.ends_,
this.stride
);
}
this.orientedRevision_ = this.getRevision();
}
return (
/** @type {Array<number>} */
this.orientedFlatCoordinates_
);
}
/**
* @param {number} squaredTolerance Squared tolerance.
* @return {Polygon} Simplified Polygon.
* @protected
* @override
*/
getSimplifiedGeometryInternal(squaredTolerance) {
const simplifiedFlatCoordinates = [];
const simplifiedEnds = [];
simplifiedFlatCoordinates.length = quantizeArray(
this.flatCoordinates,
0,
this.ends_,
this.stride,
Math.sqrt(squaredTolerance),
simplifiedFlatCoordinates,
0,
simplifiedEnds
);
return new _Polygon(simplifiedFlatCoordinates, "XY", simplifiedEnds);
}
/**
* Get the type of this geometry.
* @return {import("./Geometry.js").Type} Geometry type.
* @api
* @override
*/
getType() {
return "Polygon";
}
/**
* 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 intersectsLinearRingArray(
this.getOrientedFlatCoordinates(),
0,
this.ends_,
this.stride,
extent
);
}
/**
* Set the coordinates of the polygon.
* @param {!Array<Array<import("../coordinate.js").Coordinate>>} coordinates Coordinates.
* @param {import("./Geometry.js").GeometryLayout} [layout] Layout.
* @api
* @override
*/
setCoordinates(coordinates2, layout) {
this.setLayout(layout, coordinates2, 2);
if (!this.flatCoordinates) {
this.flatCoordinates = [];
}
const ends = deflateCoordinatesArray(
this.flatCoordinates,
0,
coordinates2,
this.stride,
this.ends_
);
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
this.changed();
}
};
var Polygon_default = Polygon;
function circular(center, radius, n, sphereRadius) {
n = n ? n : 32;
const flatCoordinates = [];
for (let i = 0; i < n; ++i) {
extend(
flatCoordinates,
offset(center, radius, 2 * Math.PI * i / n, sphereRadius)
);
}
flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);
return new Polygon(flatCoordinates, "XY", [flatCoordinates.length]);
}
function fromExtent(extent) {
if (isEmpty(extent)) {
throw new Error("Cannot create polygon from empty extent");
}
const minX = extent[0];
const minY = extent[1];
const maxX = extent[2];
const maxY = extent[3];
const flatCoordinates = [
minX,
minY,
minX,
maxY,
maxX,
maxY,
maxX,
minY,
minX,
minY
];
return new Polygon(flatCoordinates, "XY", [flatCoordinates.length]);
}
function fromCircle(circle, sides, angle) {
sides = sides ? sides : 32;
const stride = circle.getStride();
const layout = circle.getLayout();
const center = circle.getCenter();
const arrayLength = stride * (sides + 1);
const flatCoordinates = new Array(arrayLength);
for (let i = 0; i < arrayLength; i += stride) {
flatCoordinates[i] = 0;
flatCoordinates[i + 1] = 0;
for (let j = 2; j < stride; j++) {
flatCoordinates[i + j] = center[j];
}
}
const ends = [flatCoordinates.length];
const polygon = new Polygon(flatCoordinates, layout, ends);
makeRegular(polygon, center, circle.getRadius(), angle);
return polygon;
}
function makeRegular(polygon, center, radius, angle) {
const flatCoordinates = polygon.getFlatCoordinates();
const stride = polygon.getStride();
const sides = flatCoordinates.length / stride - 1;
const startAngle = angle ? angle : 0;
for (let i = 0; i <= sides; ++i) {
const offset2 = i * stride;
const angle2 = startAngle + modulo(i, sides) * 2 * Math.PI / sides;
flatCoordinates[offset2] = center[0] + radius * Math.cos(angle2);
flatCoordinates[offset2 + 1] = center[1] + radius * Math.sin(angle2);
}
polygon.changed();
}
export {
transform2D,
rotate,
Geometry_default,
getLayoutForStride,
getStrideForLayout,
transformGeom2D,
SimpleGeometry_default,
maxSquaredDelta,
arrayMaxSquaredDelta,
multiArrayMaxSquaredDelta,
assignClosestPoint,
assignClosestArrayPoint,
assignClosestMultiArrayPoint,
deflateCoordinate,
deflateCoordinates,
deflateCoordinatesArray,
deflateMultiCoordinatesArray,
inflateCoordinates,
inflateCoordinatesArray,
inflateMultiCoordinatesArray,
douglasPeucker,
douglasPeuckerArray,
snap,
quantizeArray,
quantizeMultiArray,
Point_default,
linearRingss,
LinearRing_default,
getInteriorPointOfArray,
getInteriorPointsOfMultiArray,
linearRingsAreOriented,
linearRingssAreOriented,
orientLinearRings,
orientLinearRingsArray,
inflateEnds,
Polygon_default,
circular,
fromExtent,
fromCircle,
makeRegular
};
//# sourceMappingURL=chunk-AZGMK675.js.map