Files
coopgo/node_modules/ol/geom/LinearRing.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

148 lines
5.8 KiB
JavaScript

var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @module ol/geom/LinearRing
*/
import GeometryLayout from './GeometryLayout.js';
import SimpleGeometry from './SimpleGeometry.js';
import { assignClosestPoint, maxSquaredDelta } from './flat/closest.js';
import { closestSquaredDistanceXY } from '../extent.js';
import { deflateCoordinates } from './flat/deflate.js';
import { douglasPeucker } from './flat/simplify.js';
import { inflateCoordinates } from './flat/inflate.js';
import { linearRing as linearRingArea } from './flat/area.js';
/**
* @classdesc
* Linear ring geometry. Only used as part of polygon; cannot be rendered
* on its own.
*
* @api
*/
var LinearRing = /** @class */ (function (_super) {
__extends(LinearRing, _super);
/**
* @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
* For internal use, flat coordinates in combination with `opt_layout` are also accepted.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
*/
function LinearRing(coordinates, opt_layout) {
var _this = _super.call(this) || this;
/**
* @private
* @type {number}
*/
_this.maxDelta_ = -1;
/**
* @private
* @type {number}
*/
_this.maxDeltaRevision_ = -1;
if (opt_layout !== undefined && !Array.isArray(coordinates[0])) {
_this.setFlatCoordinates(opt_layout,
/** @type {Array<number>} */ (coordinates));
}
else {
_this.setCoordinates(
/** @type {Array<import("../coordinate.js").Coordinate>} */ (coordinates), opt_layout);
}
return _this;
}
/**
* Make a complete copy of the geometry.
* @return {!LinearRing} Clone.
* @api
*/
LinearRing.prototype.clone = function () {
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.
*/
LinearRing.prototype.closestPointXY = function (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
*/
LinearRing.prototype.getArea = function () {
return linearRingArea(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
};
/**
* Return the coordinates of the linear ring.
* @return {Array<import("../coordinate.js").Coordinate>} Coordinates.
* @api
*/
LinearRing.prototype.getCoordinates = function () {
return inflateCoordinates(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride);
};
/**
* @param {number} squaredTolerance Squared tolerance.
* @return {LinearRing} Simplified LinearRing.
* @protected
*/
LinearRing.prototype.getSimplifiedGeometryInternal = function (squaredTolerance) {
var simplifiedFlatCoordinates = [];
simplifiedFlatCoordinates.length = douglasPeucker(this.flatCoordinates, 0, this.flatCoordinates.length, this.stride, squaredTolerance, simplifiedFlatCoordinates, 0);
return new LinearRing(simplifiedFlatCoordinates, GeometryLayout.XY);
};
/**
* Get the type of this geometry.
* @return {import("./Geometry.js").Type} Geometry type.
* @api
*/
LinearRing.prototype.getType = function () {
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
*/
LinearRing.prototype.intersectsExtent = function (extent) {
return false;
};
/**
* Set the coordinates of the linear ring.
* @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
* @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
* @api
*/
LinearRing.prototype.setCoordinates = function (coordinates, opt_layout) {
this.setLayout(opt_layout, coordinates, 1);
if (!this.flatCoordinates) {
this.flatCoordinates = [];
}
this.flatCoordinates.length = deflateCoordinates(this.flatCoordinates, 0, coordinates, this.stride);
this.changed();
};
return LinearRing;
}(SimpleGeometry));
export default LinearRing;
//# sourceMappingURL=LinearRing.js.map