SourceTermAnalysisSystem_vue/node_modules/.vite/deps/chunk-3JZANJYE.js

211 lines
5.5 KiB
JavaScript
Raw Normal View History

2026-05-15 10:22:44 +08:00
import {
modulo,
toFixed
} from "./chunk-54BTDBAD.js";
import {
getWidth
} from "./chunk-CKDBVGKM.js";
// 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 createStringXY(fractionDigits) {
return (
/**
* @param {Coordinate} coordinate Coordinate.
* @return {string} String XY.
*/
(function(coordinate) {
return toStringXY(coordinate, fractionDigits);
})
);
}
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 format(coordinate, template, fractionDigits) {
if (coordinate) {
return template.replace("{x}", coordinate[0].toFixed(fractionDigits)).replace("{y}", coordinate[1].toFixed(fractionDigits));
}
return "";
}
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 toStringHDMS(coordinate, fractionDigits) {
if (coordinate) {
return degreesToStringHDMS("NS", coordinate[1], fractionDigits) + " " + degreesToStringHDMS("EW", coordinate[0], fractionDigits);
}
return "";
}
function toStringXY(coordinate, fractionDigits) {
return format(coordinate, "{x}, {y}", fractionDigits);
}
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;
}
export {
padNumber,
compareVersions,
add,
closestOnCircle,
closestOnSegment,
createStringXY,
degreesToStringHDMS,
format,
equals,
rotate,
scale,
squaredDistance,
distance,
squaredDistanceToSegment,
toStringHDMS,
toStringXY,
wrapX,
getWorldsAway
};
//# sourceMappingURL=chunk-3JZANJYE.js.map