1090 lines
31 KiB
JavaScript
1090 lines
31 KiB
JavaScript
import {
|
||
getDistance
|
||
} from "./chunk-ZLPTRF2L.js";
|
||
import {
|
||
clamp,
|
||
modulo,
|
||
toDegrees,
|
||
toFixed,
|
||
toRadians,
|
||
wrap
|
||
} from "./chunk-54BTDBAD.js";
|
||
import {
|
||
applyTransform,
|
||
getWidth
|
||
} from "./chunk-SRXHWJOY.js";
|
||
|
||
// node_modules/ol/console.js
|
||
var levels = {
|
||
info: 1,
|
||
warn: 2,
|
||
error: 3,
|
||
none: 4
|
||
};
|
||
var level = levels.info;
|
||
function warn(...args) {
|
||
if (level > levels.warn) {
|
||
return;
|
||
}
|
||
console.warn(...args);
|
||
}
|
||
function error(...args) {
|
||
if (level > levels.error) {
|
||
return;
|
||
}
|
||
console.error(...args);
|
||
}
|
||
|
||
// node_modules/ol/string.js
|
||
function padNumber(number, width, precision) {
|
||
const numberString = precision !== void 0 ? number.toFixed(precision) : "" + number;
|
||
let decimal = numberString.indexOf(".");
|
||
decimal = decimal === -1 ? numberString.length : decimal;
|
||
return decimal > width ? numberString : new Array(1 + width - decimal).join("0") + numberString;
|
||
}
|
||
function compareVersions(v1, v2) {
|
||
const s1 = ("" + v1).split(".");
|
||
const s2 = ("" + v2).split(".");
|
||
for (let i = 0; i < Math.max(s1.length, s2.length); i++) {
|
||
const n1 = parseInt(s1[i] || "0", 10);
|
||
const n2 = parseInt(s2[i] || "0", 10);
|
||
if (n1 > n2) {
|
||
return 1;
|
||
}
|
||
if (n2 > n1) {
|
||
return -1;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
// node_modules/ol/coordinate.js
|
||
function add(coordinate, delta) {
|
||
coordinate[0] += +delta[0];
|
||
coordinate[1] += +delta[1];
|
||
return coordinate;
|
||
}
|
||
function closestOnCircle(coordinate, circle) {
|
||
const r = circle.getRadius();
|
||
const center = circle.getCenter();
|
||
const x0 = center[0];
|
||
const y0 = center[1];
|
||
const x1 = coordinate[0];
|
||
const y1 = coordinate[1];
|
||
let dx = x1 - x0;
|
||
const dy = y1 - y0;
|
||
if (dx === 0 && dy === 0) {
|
||
dx = 1;
|
||
}
|
||
const d = Math.sqrt(dx * dx + dy * dy);
|
||
const x = x0 + r * dx / d;
|
||
const y = y0 + r * dy / d;
|
||
return [x, y];
|
||
}
|
||
function closestOnSegment(coordinate, segment) {
|
||
const x0 = coordinate[0];
|
||
const y0 = coordinate[1];
|
||
const start = segment[0];
|
||
const end = segment[1];
|
||
const x1 = start[0];
|
||
const y1 = start[1];
|
||
const x2 = end[0];
|
||
const y2 = end[1];
|
||
const dx = x2 - x1;
|
||
const dy = y2 - y1;
|
||
const along = dx === 0 && dy === 0 ? 0 : (dx * (x0 - x1) + dy * (y0 - y1)) / (dx * dx + dy * dy || 0);
|
||
let x, y;
|
||
if (along <= 0) {
|
||
x = x1;
|
||
y = y1;
|
||
} else if (along >= 1) {
|
||
x = x2;
|
||
y = y2;
|
||
} else {
|
||
x = x1 + along * dx;
|
||
y = y1 + along * dy;
|
||
}
|
||
return [x, y];
|
||
}
|
||
function degreesToStringHDMS(hemispheres, degrees, fractionDigits) {
|
||
const normalizedDegrees = modulo(degrees + 180, 360) - 180;
|
||
const x = Math.abs(3600 * normalizedDegrees);
|
||
const decimals = fractionDigits || 0;
|
||
let deg = Math.floor(x / 3600);
|
||
let min = Math.floor((x - deg * 3600) / 60);
|
||
let sec = toFixed(x - deg * 3600 - min * 60, decimals);
|
||
if (sec >= 60) {
|
||
sec = 0;
|
||
min += 1;
|
||
}
|
||
if (min >= 60) {
|
||
min = 0;
|
||
deg += 1;
|
||
}
|
||
let hdms = deg + "°";
|
||
if (min !== 0 || sec !== 0) {
|
||
hdms += " " + padNumber(min, 2) + "′";
|
||
}
|
||
if (sec !== 0) {
|
||
hdms += " " + padNumber(sec, 2, decimals) + "″";
|
||
}
|
||
if (normalizedDegrees !== 0) {
|
||
hdms += " " + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);
|
||
}
|
||
return hdms;
|
||
}
|
||
function equals(coordinate1, coordinate2) {
|
||
let equals2 = true;
|
||
for (let i = coordinate1.length - 1; i >= 0; --i) {
|
||
if (coordinate1[i] != coordinate2[i]) {
|
||
equals2 = false;
|
||
break;
|
||
}
|
||
}
|
||
return equals2;
|
||
}
|
||
function rotate(coordinate, angle) {
|
||
const cosAngle = Math.cos(angle);
|
||
const sinAngle = Math.sin(angle);
|
||
const x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;
|
||
const y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;
|
||
coordinate[0] = x;
|
||
coordinate[1] = y;
|
||
return coordinate;
|
||
}
|
||
function scale(coordinate, scale2) {
|
||
coordinate[0] *= scale2;
|
||
coordinate[1] *= scale2;
|
||
return coordinate;
|
||
}
|
||
function squaredDistance(coord1, coord2) {
|
||
const dx = coord1[0] - coord2[0];
|
||
const dy = coord1[1] - coord2[1];
|
||
return dx * dx + dy * dy;
|
||
}
|
||
function distance(coord1, coord2) {
|
||
return Math.sqrt(squaredDistance(coord1, coord2));
|
||
}
|
||
function squaredDistanceToSegment(coordinate, segment) {
|
||
return squaredDistance(coordinate, closestOnSegment(coordinate, segment));
|
||
}
|
||
function wrapX(coordinate, projection) {
|
||
if (projection.canWrapX()) {
|
||
const worldWidth = getWidth(projection.getExtent());
|
||
const worldsAway = getWorldsAway(coordinate, projection, worldWidth);
|
||
if (worldsAway) {
|
||
coordinate[0] -= worldsAway * worldWidth;
|
||
}
|
||
}
|
||
return coordinate;
|
||
}
|
||
function getWorldsAway(coordinate, projection, sourceExtentWidth) {
|
||
const projectionExtent = projection.getExtent();
|
||
let worldsAway = 0;
|
||
if (projection.canWrapX() && (coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])) {
|
||
sourceExtentWidth = sourceExtentWidth || getWidth(projectionExtent);
|
||
worldsAway = Math.floor(
|
||
(coordinate[0] - projectionExtent[0]) / sourceExtentWidth
|
||
);
|
||
}
|
||
return worldsAway;
|
||
}
|
||
|
||
// node_modules/ol/proj/Units.js
|
||
var unitByCode = {
|
||
"9001": "m",
|
||
"9002": "ft",
|
||
"9003": "us-ft",
|
||
"9101": "radians",
|
||
"9102": "degrees"
|
||
};
|
||
function fromCode(code) {
|
||
return unitByCode[code];
|
||
}
|
||
var METERS_PER_UNIT = {
|
||
// use the radius of the Normal sphere
|
||
"radians": 6370997 / (2 * Math.PI),
|
||
"degrees": 2 * Math.PI * 6370997 / 360,
|
||
"ft": 0.3048,
|
||
"m": 1,
|
||
"us-ft": 1200 / 3937
|
||
};
|
||
|
||
// node_modules/ol/proj/Projection.js
|
||
var Projection = class {
|
||
/**
|
||
* @param {Options} options Projection options.
|
||
*/
|
||
constructor(options) {
|
||
this.code_ = options.code;
|
||
this.units_ = /** @type {import("./Units.js").Units} */
|
||
options.units;
|
||
this.extent_ = options.extent !== void 0 ? options.extent : null;
|
||
this.worldExtent_ = options.worldExtent !== void 0 ? options.worldExtent : null;
|
||
this.axisOrientation_ = options.axisOrientation !== void 0 ? options.axisOrientation : "enu";
|
||
this.global_ = options.global !== void 0 ? options.global : false;
|
||
this.canWrapX_ = !!(this.global_ && this.extent_);
|
||
this.getPointResolutionFunc_ = options.getPointResolution;
|
||
this.defaultTileGrid_ = null;
|
||
this.metersPerUnit_ = options.metersPerUnit;
|
||
}
|
||
/**
|
||
* @return {boolean} The projection is suitable for wrapping the x-axis
|
||
*/
|
||
canWrapX() {
|
||
return this.canWrapX_;
|
||
}
|
||
/**
|
||
* Get the code for this projection, e.g. 'EPSG:4326'.
|
||
* @return {string} Code.
|
||
* @api
|
||
*/
|
||
getCode() {
|
||
return this.code_;
|
||
}
|
||
/**
|
||
* Get the validity extent for this projection.
|
||
* @return {import("../extent.js").Extent} Extent.
|
||
* @api
|
||
*/
|
||
getExtent() {
|
||
return this.extent_;
|
||
}
|
||
/**
|
||
* Get the units of this projection.
|
||
* @return {import("./Units.js").Units} Units.
|
||
* @api
|
||
*/
|
||
getUnits() {
|
||
return this.units_;
|
||
}
|
||
/**
|
||
* Get the amount of meters per unit of this projection. If the projection is
|
||
* not configured with `metersPerUnit` or a units identifier, the return is
|
||
* `undefined`.
|
||
* @return {number|undefined} Meters.
|
||
* @api
|
||
*/
|
||
getMetersPerUnit() {
|
||
return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];
|
||
}
|
||
/**
|
||
* Get the world extent for this projection.
|
||
* @return {import("../extent.js").Extent} Extent.
|
||
* @api
|
||
*/
|
||
getWorldExtent() {
|
||
return this.worldExtent_;
|
||
}
|
||
/**
|
||
* Get the axis orientation of this projection.
|
||
* Example values are:
|
||
* enu - the default easting, northing, elevation.
|
||
* neu - northing, easting, up - useful for "lat/long" geographic coordinates,
|
||
* or south orientated transverse mercator.
|
||
* wnu - westing, northing, up - some planetary coordinate systems have
|
||
* "west positive" coordinate systems
|
||
* @return {string} Axis orientation.
|
||
* @api
|
||
*/
|
||
getAxisOrientation() {
|
||
return this.axisOrientation_;
|
||
}
|
||
/**
|
||
* Is this projection a global projection which spans the whole world?
|
||
* @return {boolean} Whether the projection is global.
|
||
* @api
|
||
*/
|
||
isGlobal() {
|
||
return this.global_;
|
||
}
|
||
/**
|
||
* Set if the projection is a global projection which spans the whole world
|
||
* @param {boolean} global Whether the projection is global.
|
||
* @api
|
||
*/
|
||
setGlobal(global) {
|
||
this.global_ = global;
|
||
this.canWrapX_ = !!(global && this.extent_);
|
||
}
|
||
/**
|
||
* @return {import("../tilegrid/TileGrid.js").default} The default tile grid.
|
||
*/
|
||
getDefaultTileGrid() {
|
||
return this.defaultTileGrid_;
|
||
}
|
||
/**
|
||
* @param {import("../tilegrid/TileGrid.js").default} tileGrid The default tile grid.
|
||
*/
|
||
setDefaultTileGrid(tileGrid) {
|
||
this.defaultTileGrid_ = tileGrid;
|
||
}
|
||
/**
|
||
* Set the validity extent for this projection.
|
||
* @param {import("../extent.js").Extent} extent Extent.
|
||
* @api
|
||
*/
|
||
setExtent(extent) {
|
||
this.extent_ = extent;
|
||
this.canWrapX_ = !!(this.global_ && extent);
|
||
}
|
||
/**
|
||
* Set the world extent for this projection.
|
||
* @param {import("../extent.js").Extent} worldExtent World extent
|
||
* [minlon, minlat, maxlon, maxlat].
|
||
* @api
|
||
*/
|
||
setWorldExtent(worldExtent) {
|
||
this.worldExtent_ = worldExtent;
|
||
}
|
||
/**
|
||
* Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}
|
||
* for this projection.
|
||
* @param {function(number, import("../coordinate.js").Coordinate):number} func Function
|
||
* @api
|
||
*/
|
||
setGetPointResolution(func) {
|
||
this.getPointResolutionFunc_ = func;
|
||
}
|
||
/**
|
||
* Get the custom point resolution function for this projection (if set).
|
||
* @return {GetPointResolution|undefined} The custom point
|
||
* resolution function (if set).
|
||
*/
|
||
getPointResolutionFunc() {
|
||
return this.getPointResolutionFunc_;
|
||
}
|
||
};
|
||
var Projection_default = Projection;
|
||
|
||
// node_modules/ol/proj/epsg3857.js
|
||
var RADIUS = 6378137;
|
||
var HALF_SIZE = Math.PI * RADIUS;
|
||
var EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];
|
||
var WORLD_EXTENT = [-180, -85, 180, 85];
|
||
var MAX_SAFE_Y = RADIUS * Math.log(Math.tan(Math.PI / 2));
|
||
var EPSG3857Projection = class extends Projection_default {
|
||
/**
|
||
* @param {string} code Code.
|
||
*/
|
||
constructor(code) {
|
||
super({
|
||
code,
|
||
units: "m",
|
||
extent: EXTENT,
|
||
global: true,
|
||
worldExtent: WORLD_EXTENT,
|
||
getPointResolution: function(resolution, point) {
|
||
return resolution / Math.cosh(point[1] / RADIUS);
|
||
}
|
||
});
|
||
}
|
||
};
|
||
var PROJECTIONS = [
|
||
new EPSG3857Projection("EPSG:3857"),
|
||
new EPSG3857Projection("EPSG:102100"),
|
||
new EPSG3857Projection("EPSG:102113"),
|
||
new EPSG3857Projection("EPSG:900913"),
|
||
new EPSG3857Projection("http://www.opengis.net/def/crs/EPSG/0/3857"),
|
||
new EPSG3857Projection("http://www.opengis.net/gml/srs/epsg.xml#3857")
|
||
];
|
||
function fromEPSG4326(input, output, dimension, stride) {
|
||
const length = input.length;
|
||
dimension = dimension > 1 ? dimension : 2;
|
||
stride = stride ?? dimension;
|
||
if (output === void 0) {
|
||
if (dimension > 2) {
|
||
output = input.slice();
|
||
} else {
|
||
output = new Array(length);
|
||
}
|
||
}
|
||
for (let i = 0; i < length; i += stride) {
|
||
output[i] = HALF_SIZE * input[i] / 180;
|
||
let y = RADIUS * Math.log(Math.tan(Math.PI * (+input[i + 1] + 90) / 360));
|
||
if (y > MAX_SAFE_Y) {
|
||
y = MAX_SAFE_Y;
|
||
} else if (y < -MAX_SAFE_Y) {
|
||
y = -MAX_SAFE_Y;
|
||
}
|
||
output[i + 1] = y;
|
||
}
|
||
return output;
|
||
}
|
||
function toEPSG4326(input, output, dimension, stride) {
|
||
const length = input.length;
|
||
dimension = dimension > 1 ? dimension : 2;
|
||
stride = stride ?? dimension;
|
||
if (output === void 0) {
|
||
if (dimension > 2) {
|
||
output = input.slice();
|
||
} else {
|
||
output = new Array(length);
|
||
}
|
||
}
|
||
for (let i = 0; i < length; i += stride) {
|
||
output[i] = 180 * input[i] / HALF_SIZE;
|
||
output[i + 1] = 360 * Math.atan(Math.exp(input[i + 1] / RADIUS)) / Math.PI - 90;
|
||
}
|
||
return output;
|
||
}
|
||
|
||
// node_modules/ol/proj/epsg4326.js
|
||
var RADIUS2 = 6378137;
|
||
var EXTENT2 = [-180, -90, 180, 90];
|
||
var METERS_PER_UNIT2 = Math.PI * RADIUS2 / 180;
|
||
var EPSG4326Projection = class extends Projection_default {
|
||
/**
|
||
* @param {string} code Code.
|
||
* @param {string} [axisOrientation] Axis orientation.
|
||
*/
|
||
constructor(code, axisOrientation) {
|
||
super({
|
||
code,
|
||
units: "degrees",
|
||
extent: EXTENT2,
|
||
axisOrientation,
|
||
global: true,
|
||
metersPerUnit: METERS_PER_UNIT2,
|
||
worldExtent: EXTENT2
|
||
});
|
||
}
|
||
};
|
||
var PROJECTIONS2 = [
|
||
new EPSG4326Projection("CRS:84"),
|
||
new EPSG4326Projection("EPSG:4326", "neu"),
|
||
new EPSG4326Projection("urn:ogc:def:crs:OGC:1.3:CRS84"),
|
||
new EPSG4326Projection("urn:ogc:def:crs:OGC:2:84"),
|
||
new EPSG4326Projection("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),
|
||
new EPSG4326Projection("http://www.opengis.net/gml/srs/epsg.xml#4326", "neu"),
|
||
new EPSG4326Projection("http://www.opengis.net/def/crs/EPSG/0/4326", "neu")
|
||
];
|
||
|
||
// node_modules/ol/proj/projections.js
|
||
var cache = {};
|
||
function clear() {
|
||
cache = {};
|
||
}
|
||
function get(code) {
|
||
return cache[code] || cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/, "EPSG:$3")] || null;
|
||
}
|
||
function add2(code, projection) {
|
||
cache[code] = projection;
|
||
}
|
||
|
||
// node_modules/ol/proj/transforms.js
|
||
var transforms = {};
|
||
function clear2() {
|
||
transforms = {};
|
||
}
|
||
function add3(source, destination, transformFn) {
|
||
const sourceCode = source.getCode();
|
||
const destinationCode = destination.getCode();
|
||
if (!(sourceCode in transforms)) {
|
||
transforms[sourceCode] = {};
|
||
}
|
||
transforms[sourceCode][destinationCode] = transformFn;
|
||
}
|
||
function get2(sourceCode, destinationCode) {
|
||
if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {
|
||
return transforms[sourceCode][destinationCode];
|
||
}
|
||
return null;
|
||
}
|
||
|
||
// node_modules/ol/proj/utm.js
|
||
var K0 = 0.9996;
|
||
var E = 669438e-8;
|
||
var E2 = E * E;
|
||
var E3 = E2 * E;
|
||
var E_P2 = E / (1 - E);
|
||
var SQRT_E = Math.sqrt(1 - E);
|
||
var _E = (1 - SQRT_E) / (1 + SQRT_E);
|
||
var _E2 = _E * _E;
|
||
var _E3 = _E2 * _E;
|
||
var _E4 = _E3 * _E;
|
||
var _E5 = _E4 * _E;
|
||
var M1 = 1 - E / 4 - 3 * E2 / 64 - 5 * E3 / 256;
|
||
var M2 = 3 * E / 8 + 3 * E2 / 32 + 45 * E3 / 1024;
|
||
var M3 = 15 * E2 / 256 + 45 * E3 / 1024;
|
||
var M4 = 35 * E3 / 3072;
|
||
var P2 = 3 / 2 * _E - 27 / 32 * _E3 + 269 / 512 * _E5;
|
||
var P3 = 21 / 16 * _E2 - 55 / 32 * _E4;
|
||
var P4 = 151 / 96 * _E3 - 417 / 128 * _E5;
|
||
var P5 = 1097 / 512 * _E4;
|
||
var R = 6378137;
|
||
function toLonLat(easting, northing, zone) {
|
||
const x = easting - 5e5;
|
||
const y = zone.north ? northing : northing - 1e7;
|
||
const m = y / K0;
|
||
const mu = m / (R * M1);
|
||
const pRad = mu + P2 * Math.sin(2 * mu) + P3 * Math.sin(4 * mu) + P4 * Math.sin(6 * mu) + P5 * Math.sin(8 * mu);
|
||
const pSin = Math.sin(pRad);
|
||
const pSin2 = pSin * pSin;
|
||
const pCos = Math.cos(pRad);
|
||
const pTan = pSin / pCos;
|
||
const pTan2 = pTan * pTan;
|
||
const pTan4 = pTan2 * pTan2;
|
||
const epSin = 1 - E * pSin2;
|
||
const epSinSqrt = Math.sqrt(1 - E * pSin2);
|
||
const n = R / epSinSqrt;
|
||
const r = (1 - E) / epSin;
|
||
const c = E_P2 * pCos ** 2;
|
||
const c2 = c * c;
|
||
const d = x / (n * K0);
|
||
const d2 = d * d;
|
||
const d3 = d2 * d;
|
||
const d4 = d3 * d;
|
||
const d5 = d4 * d;
|
||
const d6 = d5 * d;
|
||
const latitude = pRad - pTan / r * (d2 / 2 - d4 / 24 * (5 + 3 * pTan2 + 10 * c - 4 * c2 - 9 * E_P2)) + d6 / 720 * (61 + 90 * pTan2 + 298 * c + 45 * pTan4 - 252 * E_P2 - 3 * c2);
|
||
let longitude = (d - d3 / 6 * (1 + 2 * pTan2 + c) + d5 / 120 * (5 - 2 * c + 28 * pTan2 - 3 * c2 + 8 * E_P2 + 24 * pTan4)) / pCos;
|
||
longitude = wrap(
|
||
longitude + toRadians(zoneToCentralLongitude(zone.number)),
|
||
-Math.PI,
|
||
Math.PI
|
||
);
|
||
return [toDegrees(longitude), toDegrees(latitude)];
|
||
}
|
||
var MIN_LATITUDE = -80;
|
||
var MAX_LATITUDE = 84;
|
||
var MIN_LONGITUDE = -180;
|
||
var MAX_LONGITUDE = 180;
|
||
function fromLonLat(longitude, latitude, zone) {
|
||
longitude = wrap(longitude, MIN_LONGITUDE, MAX_LONGITUDE);
|
||
if (latitude < MIN_LATITUDE) {
|
||
latitude = MIN_LATITUDE;
|
||
} else if (latitude > MAX_LATITUDE) {
|
||
latitude = MAX_LATITUDE;
|
||
}
|
||
const latRad = toRadians(latitude);
|
||
const latSin = Math.sin(latRad);
|
||
const latCos = Math.cos(latRad);
|
||
const latTan = latSin / latCos;
|
||
const latTan2 = latTan * latTan;
|
||
const latTan4 = latTan2 * latTan2;
|
||
const lonRad = toRadians(longitude);
|
||
const centralLon = zoneToCentralLongitude(zone.number);
|
||
const centralLonRad = toRadians(centralLon);
|
||
const n = R / Math.sqrt(1 - E * latSin ** 2);
|
||
const c = E_P2 * latCos ** 2;
|
||
const a = latCos * wrap(lonRad - centralLonRad, -Math.PI, Math.PI);
|
||
const a2 = a * a;
|
||
const a3 = a2 * a;
|
||
const a4 = a3 * a;
|
||
const a5 = a4 * a;
|
||
const a6 = a5 * a;
|
||
const m = R * (M1 * latRad - M2 * Math.sin(2 * latRad) + M3 * Math.sin(4 * latRad) - M4 * Math.sin(6 * latRad));
|
||
const easting = K0 * n * (a + a3 / 6 * (1 - latTan2 + c) + a5 / 120 * (5 - 18 * latTan2 + latTan4 + 72 * c - 58 * E_P2)) + 5e5;
|
||
let northing = K0 * (m + n * latTan * (a2 / 2 + a4 / 24 * (5 - latTan2 + 9 * c + 4 * c ** 2) + a6 / 720 * (61 - 58 * latTan2 + latTan4 + 600 * c - 330 * E_P2)));
|
||
if (!zone.north) {
|
||
northing += 1e7;
|
||
}
|
||
return [easting, northing];
|
||
}
|
||
function zoneToCentralLongitude(zone) {
|
||
return (zone - 1) * 6 - 180 + 3;
|
||
}
|
||
var epsgRegExes = [
|
||
/^EPSG:(\d+)$/,
|
||
/^urn:ogc:def:crs:EPSG::(\d+)$/,
|
||
/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/
|
||
];
|
||
function zoneFromCode(code) {
|
||
let epsgId = 0;
|
||
for (const re of epsgRegExes) {
|
||
const match = code.match(re);
|
||
if (match) {
|
||
epsgId = parseInt(match[1]);
|
||
break;
|
||
}
|
||
}
|
||
if (!epsgId) {
|
||
return null;
|
||
}
|
||
let number = 0;
|
||
let north = false;
|
||
if (epsgId > 32700 && epsgId < 32761) {
|
||
number = epsgId - 32700;
|
||
} else if (epsgId > 32600 && epsgId < 32661) {
|
||
north = true;
|
||
number = epsgId - 32600;
|
||
}
|
||
if (!number) {
|
||
return null;
|
||
}
|
||
return { number, north };
|
||
}
|
||
function makeTransformFunction(transformer, zone) {
|
||
return function(input, output, dimension, stride) {
|
||
const length = input.length;
|
||
dimension = dimension > 1 ? dimension : 2;
|
||
stride = stride ?? dimension;
|
||
if (!output) {
|
||
if (dimension > 2) {
|
||
output = input.slice();
|
||
} else {
|
||
output = new Array(length);
|
||
}
|
||
}
|
||
for (let i = 0; i < length; i += stride) {
|
||
const x = input[i];
|
||
const y = input[i + 1];
|
||
const coord = transformer(x, y, zone);
|
||
output[i] = coord[0];
|
||
output[i + 1] = coord[1];
|
||
}
|
||
return output;
|
||
};
|
||
}
|
||
function makeProjection(code) {
|
||
const zone = zoneFromCode(code);
|
||
if (!zone) {
|
||
return null;
|
||
}
|
||
return new Projection_default({ code, units: "m" });
|
||
}
|
||
function makeTransforms(projection) {
|
||
const zone = zoneFromCode(projection.getCode());
|
||
if (!zone) {
|
||
return null;
|
||
}
|
||
return {
|
||
forward: makeTransformFunction(fromLonLat, zone),
|
||
inverse: makeTransformFunction(toLonLat, zone)
|
||
};
|
||
}
|
||
|
||
// node_modules/ol/proj.js
|
||
var transformFactories = [makeTransforms];
|
||
var projectionFactories = [makeProjection];
|
||
var showCoordinateWarning = true;
|
||
function disableCoordinateWarning(disable) {
|
||
const hide = disable === void 0 ? true : disable;
|
||
showCoordinateWarning = !hide;
|
||
}
|
||
function cloneTransform(input, output) {
|
||
if (output !== void 0) {
|
||
for (let i = 0, ii = input.length; i < ii; ++i) {
|
||
output[i] = input[i];
|
||
}
|
||
output = output;
|
||
} else {
|
||
output = input.slice();
|
||
}
|
||
return output;
|
||
}
|
||
function identityTransform(input, output) {
|
||
if (output !== void 0 && input !== output) {
|
||
for (let i = 0, ii = input.length; i < ii; ++i) {
|
||
output[i] = input[i];
|
||
}
|
||
input = output;
|
||
}
|
||
return input;
|
||
}
|
||
function addProjection(projection) {
|
||
add2(projection.getCode(), projection);
|
||
add3(projection, projection, cloneTransform);
|
||
}
|
||
function addProjections(projections) {
|
||
projections.forEach(addProjection);
|
||
}
|
||
function get3(projectionLike) {
|
||
if (!(typeof projectionLike === "string")) {
|
||
return projectionLike;
|
||
}
|
||
const projection = get(projectionLike);
|
||
if (projection) {
|
||
return projection;
|
||
}
|
||
for (const makeProjection2 of projectionFactories) {
|
||
const projection2 = makeProjection2(projectionLike);
|
||
if (projection2) {
|
||
return projection2;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
function getPointResolution(projection, resolution, point, units) {
|
||
projection = get3(projection);
|
||
let pointResolution;
|
||
const getter = projection.getPointResolutionFunc();
|
||
if (getter) {
|
||
pointResolution = getter(resolution, point);
|
||
if (units && units !== projection.getUnits()) {
|
||
const metersPerUnit = projection.getMetersPerUnit();
|
||
if (metersPerUnit) {
|
||
pointResolution = pointResolution * metersPerUnit / METERS_PER_UNIT[units];
|
||
}
|
||
}
|
||
} else {
|
||
const projUnits = projection.getUnits();
|
||
if (projUnits == "degrees" && !units || units == "degrees") {
|
||
pointResolution = resolution;
|
||
} else {
|
||
const toEPSG43262 = getTransformFromProjections(
|
||
projection,
|
||
get3("EPSG:4326")
|
||
);
|
||
if (!toEPSG43262 && projUnits !== "degrees") {
|
||
pointResolution = resolution * projection.getMetersPerUnit();
|
||
} else {
|
||
let vertices = [
|
||
point[0] - resolution / 2,
|
||
point[1],
|
||
point[0] + resolution / 2,
|
||
point[1],
|
||
point[0],
|
||
point[1] - resolution / 2,
|
||
point[0],
|
||
point[1] + resolution / 2
|
||
];
|
||
vertices = toEPSG43262(vertices, vertices, 2);
|
||
const width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));
|
||
const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));
|
||
pointResolution = (width + height) / 2;
|
||
}
|
||
const metersPerUnit = units ? METERS_PER_UNIT[units] : projection.getMetersPerUnit();
|
||
if (metersPerUnit !== void 0) {
|
||
pointResolution /= metersPerUnit;
|
||
}
|
||
}
|
||
}
|
||
return pointResolution;
|
||
}
|
||
function addEquivalentProjections(projections) {
|
||
addProjections(projections);
|
||
projections.forEach(function(source) {
|
||
projections.forEach(function(destination) {
|
||
if (source !== destination) {
|
||
add3(source, destination, cloneTransform);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
function addEquivalentTransforms(projections1, projections2, forwardTransform, inverseTransform) {
|
||
projections1.forEach(function(projection1) {
|
||
projections2.forEach(function(projection2) {
|
||
add3(projection1, projection2, forwardTransform);
|
||
add3(projection2, projection1, inverseTransform);
|
||
});
|
||
});
|
||
}
|
||
function clearAllProjections() {
|
||
clear();
|
||
clear2();
|
||
}
|
||
function createProjection(projection, defaultCode) {
|
||
if (!projection) {
|
||
return get3(defaultCode);
|
||
}
|
||
if (typeof projection === "string") {
|
||
return get3(projection);
|
||
}
|
||
return (
|
||
/** @type {Projection} */
|
||
projection
|
||
);
|
||
}
|
||
function createTransformFromCoordinateTransform(coordTransform) {
|
||
return (
|
||
/**
|
||
* @param {Array<number>} input Input.
|
||
* @param {Array<number>} [output] Output.
|
||
* @param {number} [dimension] Dimensions that should be transformed.
|
||
* @param {number} [stride] Stride.
|
||
* @return {Array<number>} Output.
|
||
*/
|
||
(function(input, output, dimension, stride) {
|
||
const length = input.length;
|
||
dimension = dimension !== void 0 ? dimension : 2;
|
||
stride = stride ?? dimension;
|
||
output = output !== void 0 ? output : new Array(length);
|
||
for (let i = 0; i < length; i += stride) {
|
||
const point = coordTransform(input.slice(i, i + dimension));
|
||
const pointLength = point.length;
|
||
for (let j = 0, jj = stride; j < jj; ++j) {
|
||
output[i + j] = j >= pointLength ? input[i + j] : point[j];
|
||
}
|
||
}
|
||
return output;
|
||
})
|
||
);
|
||
}
|
||
function addCoordinateTransforms(source, destination, forward, inverse) {
|
||
const sourceProj = get3(source);
|
||
const destProj = get3(destination);
|
||
add3(
|
||
sourceProj,
|
||
destProj,
|
||
createTransformFromCoordinateTransform(forward)
|
||
);
|
||
add3(
|
||
destProj,
|
||
sourceProj,
|
||
createTransformFromCoordinateTransform(inverse)
|
||
);
|
||
}
|
||
function fromLonLat2(coordinate, projection) {
|
||
disableCoordinateWarning();
|
||
return transform(
|
||
coordinate,
|
||
"EPSG:4326",
|
||
projection !== void 0 ? projection : "EPSG:3857"
|
||
);
|
||
}
|
||
function toLonLat2(coordinate, projection) {
|
||
const lonLat = transform(
|
||
coordinate,
|
||
projection !== void 0 ? projection : "EPSG:3857",
|
||
"EPSG:4326"
|
||
);
|
||
const lon = lonLat[0];
|
||
if (lon < -180 || lon > 180) {
|
||
lonLat[0] = modulo(lon + 180, 360) - 180;
|
||
}
|
||
return lonLat;
|
||
}
|
||
function equivalent(projection1, projection2) {
|
||
if (projection1 === projection2) {
|
||
return true;
|
||
}
|
||
const equalUnits = projection1.getUnits() === projection2.getUnits();
|
||
if (projection1.getCode() === projection2.getCode()) {
|
||
return equalUnits;
|
||
}
|
||
const transformFunc = getTransformFromProjections(projection1, projection2);
|
||
return transformFunc === cloneTransform && equalUnits;
|
||
}
|
||
function getTransformFromProjections(source, destination) {
|
||
const sourceCode = source.getCode();
|
||
const destinationCode = destination.getCode();
|
||
let transformFunc = get2(sourceCode, destinationCode);
|
||
if (transformFunc) {
|
||
return transformFunc;
|
||
}
|
||
let sourceTransforms = null;
|
||
let destinationTransforms = null;
|
||
for (const makeTransforms2 of transformFactories) {
|
||
if (!sourceTransforms) {
|
||
sourceTransforms = makeTransforms2(source);
|
||
}
|
||
if (!destinationTransforms) {
|
||
destinationTransforms = makeTransforms2(destination);
|
||
}
|
||
}
|
||
if (!sourceTransforms && !destinationTransforms) {
|
||
return null;
|
||
}
|
||
const intermediateCode = "EPSG:4326";
|
||
if (!destinationTransforms) {
|
||
const toDestination = get2(intermediateCode, destinationCode);
|
||
if (toDestination) {
|
||
transformFunc = composeTransformFuncs(
|
||
sourceTransforms.inverse,
|
||
toDestination
|
||
);
|
||
}
|
||
} else if (!sourceTransforms) {
|
||
const fromSource = get2(sourceCode, intermediateCode);
|
||
if (fromSource) {
|
||
transformFunc = composeTransformFuncs(
|
||
fromSource,
|
||
destinationTransforms.forward
|
||
);
|
||
}
|
||
} else {
|
||
transformFunc = composeTransformFuncs(
|
||
sourceTransforms.inverse,
|
||
destinationTransforms.forward
|
||
);
|
||
}
|
||
if (transformFunc) {
|
||
addProjection(source);
|
||
addProjection(destination);
|
||
add3(source, destination, transformFunc);
|
||
}
|
||
return transformFunc;
|
||
}
|
||
function composeTransformFuncs(t1, t2) {
|
||
return function(input, output, dimensions, stride) {
|
||
output = t1(input, output, dimensions, stride);
|
||
return t2(output, output, dimensions, stride);
|
||
};
|
||
}
|
||
function getTransform(source, destination) {
|
||
const sourceProjection = get3(source);
|
||
const destinationProjection = get3(destination);
|
||
return getTransformFromProjections(sourceProjection, destinationProjection);
|
||
}
|
||
function transform(coordinate, source, destination) {
|
||
const transformFunc = getTransform(source, destination);
|
||
if (!transformFunc) {
|
||
const sourceCode = get3(source).getCode();
|
||
const destinationCode = get3(destination).getCode();
|
||
throw new Error(
|
||
`No transform available between ${sourceCode} and ${destinationCode}`
|
||
);
|
||
}
|
||
return transformFunc(coordinate, void 0, coordinate.length);
|
||
}
|
||
function transformExtent(extent, source, destination, stops) {
|
||
const transformFunc = getTransform(source, destination);
|
||
return applyTransform(extent, transformFunc, void 0, stops);
|
||
}
|
||
function transformWithProjections(point, sourceProjection, destinationProjection) {
|
||
const transformFunc = getTransformFromProjections(
|
||
sourceProjection,
|
||
destinationProjection
|
||
);
|
||
return transformFunc(point);
|
||
}
|
||
var userProjection = null;
|
||
function setUserProjection(projection) {
|
||
userProjection = get3(projection);
|
||
}
|
||
function clearUserProjection() {
|
||
userProjection = null;
|
||
}
|
||
function getUserProjection() {
|
||
return userProjection;
|
||
}
|
||
function useGeographic() {
|
||
setUserProjection("EPSG:4326");
|
||
}
|
||
function toUserCoordinate(coordinate, sourceProjection) {
|
||
if (!userProjection) {
|
||
return coordinate;
|
||
}
|
||
return transform(coordinate, sourceProjection, userProjection);
|
||
}
|
||
function fromUserCoordinate(coordinate, destProjection) {
|
||
if (!userProjection) {
|
||
if (showCoordinateWarning && !equals(coordinate, [0, 0]) && coordinate[0] >= -180 && coordinate[0] <= 180 && coordinate[1] >= -90 && coordinate[1] <= 90) {
|
||
showCoordinateWarning = false;
|
||
warn(
|
||
"Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates."
|
||
);
|
||
}
|
||
return coordinate;
|
||
}
|
||
return transform(coordinate, userProjection, destProjection);
|
||
}
|
||
function toUserExtent(extent, sourceProjection) {
|
||
if (!userProjection) {
|
||
return extent;
|
||
}
|
||
return transformExtent(extent, sourceProjection, userProjection);
|
||
}
|
||
function fromUserExtent(extent, destProjection) {
|
||
if (!userProjection) {
|
||
return extent;
|
||
}
|
||
return transformExtent(extent, userProjection, destProjection);
|
||
}
|
||
function toUserResolution(resolution, sourceProjection) {
|
||
if (!userProjection) {
|
||
return resolution;
|
||
}
|
||
const sourceMetersPerUnit = get3(sourceProjection).getMetersPerUnit();
|
||
const userMetersPerUnit = userProjection.getMetersPerUnit();
|
||
return sourceMetersPerUnit && userMetersPerUnit ? resolution * sourceMetersPerUnit / userMetersPerUnit : resolution;
|
||
}
|
||
function fromUserResolution(resolution, destProjection) {
|
||
if (!userProjection) {
|
||
return resolution;
|
||
}
|
||
const destMetersPerUnit = get3(destProjection).getMetersPerUnit();
|
||
const userMetersPerUnit = userProjection.getMetersPerUnit();
|
||
return destMetersPerUnit && userMetersPerUnit ? resolution * userMetersPerUnit / destMetersPerUnit : resolution;
|
||
}
|
||
function createSafeCoordinateTransform(sourceProj, destProj, transform2) {
|
||
return function(coord) {
|
||
let transformed, worldsAway;
|
||
if (sourceProj.canWrapX()) {
|
||
const sourceExtent = sourceProj.getExtent();
|
||
const sourceExtentWidth = getWidth(sourceExtent);
|
||
coord = coord.slice(0);
|
||
worldsAway = getWorldsAway(coord, sourceProj, sourceExtentWidth);
|
||
if (worldsAway) {
|
||
coord[0] = coord[0] - worldsAway * sourceExtentWidth;
|
||
}
|
||
coord[0] = clamp(coord[0], sourceExtent[0], sourceExtent[2]);
|
||
coord[1] = clamp(coord[1], sourceExtent[1], sourceExtent[3]);
|
||
transformed = transform2(coord);
|
||
} else {
|
||
transformed = transform2(coord);
|
||
}
|
||
if (worldsAway && destProj.canWrapX()) {
|
||
transformed[0] += worldsAway * getWidth(destProj.getExtent());
|
||
}
|
||
return transformed;
|
||
};
|
||
}
|
||
function addCommon() {
|
||
addEquivalentProjections(PROJECTIONS);
|
||
addEquivalentProjections(PROJECTIONS2);
|
||
addEquivalentTransforms(
|
||
PROJECTIONS2,
|
||
PROJECTIONS,
|
||
fromEPSG4326,
|
||
toEPSG4326
|
||
);
|
||
}
|
||
addCommon();
|
||
|
||
export {
|
||
warn,
|
||
error,
|
||
compareVersions,
|
||
add,
|
||
closestOnCircle,
|
||
closestOnSegment,
|
||
degreesToStringHDMS,
|
||
equals,
|
||
rotate,
|
||
scale,
|
||
squaredDistance,
|
||
distance,
|
||
squaredDistanceToSegment,
|
||
wrapX,
|
||
fromCode,
|
||
METERS_PER_UNIT,
|
||
Projection_default,
|
||
disableCoordinateWarning,
|
||
cloneTransform,
|
||
identityTransform,
|
||
addProjection,
|
||
addProjections,
|
||
get3 as get,
|
||
getPointResolution,
|
||
addEquivalentProjections,
|
||
addEquivalentTransforms,
|
||
clearAllProjections,
|
||
createProjection,
|
||
createTransformFromCoordinateTransform,
|
||
addCoordinateTransforms,
|
||
fromLonLat2 as fromLonLat,
|
||
toLonLat2 as toLonLat,
|
||
equivalent,
|
||
getTransformFromProjections,
|
||
getTransform,
|
||
transform,
|
||
transformExtent,
|
||
transformWithProjections,
|
||
setUserProjection,
|
||
clearUserProjection,
|
||
getUserProjection,
|
||
useGeographic,
|
||
toUserCoordinate,
|
||
fromUserCoordinate,
|
||
toUserExtent,
|
||
fromUserExtent,
|
||
toUserResolution,
|
||
fromUserResolution,
|
||
createSafeCoordinateTransform,
|
||
addCommon
|
||
};
|
||
//# sourceMappingURL=chunk-A3RXLHYB.js.map
|