aiflowy-ui-admin/node_modules/.vite/deps/chunk-WUVA3XFM.js

361 lines
10 KiB
JavaScript

import {
BoundingRect_default,
__extends,
applyTransform,
each,
filter,
identity,
invert,
map,
max,
min,
mul,
windingLine
} from "./chunk-ZAVXMU2G.js";
// ../node_modules/.pnpm/zrender@6.0.0/node_modules/zrender/lib/contain/polygon.js
var EPSILON = 1e-8;
function isAroundEqual(a, b) {
return Math.abs(a - b) < EPSILON;
}
function contain(points, x, y) {
var w = 0;
var p = points[0];
if (!p) {
return false;
}
for (var i = 1; i < points.length; i++) {
var p2 = points[i];
w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
p = p2;
}
var p0 = points[0];
if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) {
w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
}
return w !== 0;
}
// ../node_modules/.pnpm/echarts@6.0.0/node_modules/echarts/lib/coord/geo/Region.js
var TMP_TRANSFORM = [];
function transformPoints(points, transform) {
for (var p = 0; p < points.length; p++) {
applyTransform(points[p], points[p], transform);
}
}
function updateBBoxFromPoints(points, min2, max2, projection) {
for (var i = 0; i < points.length; i++) {
var p = points[i];
if (projection) {
p = projection.project(p);
}
if (p && isFinite(p[0]) && isFinite(p[1])) {
min(min2, min2, p);
max(max2, max2, p);
}
}
}
function centroid(points) {
var signedArea = 0;
var cx = 0;
var cy = 0;
var len = points.length;
var x0 = points[len - 1][0];
var y0 = points[len - 1][1];
for (var i = 0; i < len; i++) {
var x1 = points[i][0];
var y1 = points[i][1];
var a = x0 * y1 - x1 * y0;
signedArea += a;
cx += (x0 + x1) * a;
cy += (y0 + y1) * a;
x0 = x1;
y0 = y1;
}
return signedArea ? [cx / signedArea / 3, cy / signedArea / 3, signedArea] : [points[0][0] || 0, points[0][1] || 0];
}
var Region = (
/** @class */
function() {
function Region2(name) {
this.name = name;
}
Region2.prototype.setCenter = function(center) {
this._center = center;
};
Region2.prototype.getCenter = function() {
var center = this._center;
if (!center) {
center = this._center = this.calcCenter();
}
return center;
};
return Region2;
}()
);
var GeoJSONPolygonGeometry = (
/** @class */
/* @__PURE__ */ function() {
function GeoJSONPolygonGeometry2(exterior, interiors) {
this.type = "polygon";
this.exterior = exterior;
this.interiors = interiors;
}
return GeoJSONPolygonGeometry2;
}()
);
var GeoJSONLineStringGeometry = (
/** @class */
/* @__PURE__ */ function() {
function GeoJSONLineStringGeometry2(points) {
this.type = "linestring";
this.points = points;
}
return GeoJSONLineStringGeometry2;
}()
);
var GeoJSONRegion = (
/** @class */
function(_super) {
__extends(GeoJSONRegion2, _super);
function GeoJSONRegion2(name, geometries, cp) {
var _this = _super.call(this, name) || this;
_this.type = "geoJSON";
_this.geometries = geometries;
_this._center = cp && [cp[0], cp[1]];
return _this;
}
GeoJSONRegion2.prototype.calcCenter = function() {
var geometries = this.geometries;
var largestGeo;
var largestGeoSize = 0;
for (var i = 0; i < geometries.length; i++) {
var geo = geometries[i];
var exterior = geo.exterior;
var size = exterior && exterior.length;
if (size > largestGeoSize) {
largestGeo = geo;
largestGeoSize = size;
}
}
if (largestGeo) {
return centroid(largestGeo.exterior);
}
var rect = this.getBoundingRect();
return [rect.x + rect.width / 2, rect.y + rect.height / 2];
};
GeoJSONRegion2.prototype.getBoundingRect = function(projection) {
var rect = this._rect;
if (rect && !projection) {
return rect;
}
var min2 = [Infinity, Infinity];
var max2 = [-Infinity, -Infinity];
var geometries = this.geometries;
each(geometries, function(geo) {
if (geo.type === "polygon") {
updateBBoxFromPoints(geo.exterior, min2, max2, projection);
} else {
each(geo.points, function(points) {
updateBBoxFromPoints(points, min2, max2, projection);
});
}
});
if (!(isFinite(min2[0]) && isFinite(min2[1]) && isFinite(max2[0]) && isFinite(max2[1]))) {
min2[0] = min2[1] = max2[0] = max2[1] = 0;
}
rect = new BoundingRect_default(min2[0], min2[1], max2[0] - min2[0], max2[1] - min2[1]);
if (!projection) {
this._rect = rect;
}
return rect;
};
GeoJSONRegion2.prototype.contain = function(coord) {
var rect = this.getBoundingRect();
var geometries = this.geometries;
if (!rect.contain(coord[0], coord[1])) {
return false;
}
loopGeo: for (var i = 0, len = geometries.length; i < len; i++) {
var geo = geometries[i];
if (geo.type !== "polygon") {
continue;
}
var exterior = geo.exterior;
var interiors = geo.interiors;
if (contain(exterior, coord[0], coord[1])) {
for (var k = 0; k < (interiors ? interiors.length : 0); k++) {
if (contain(interiors[k], coord[0], coord[1])) {
continue loopGeo;
}
}
return true;
}
}
return false;
};
GeoJSONRegion2.prototype.transformTo = function(x, y, width, height) {
var rect = this.getBoundingRect();
var aspect = rect.width / rect.height;
if (!width) {
width = aspect * height;
} else if (!height) {
height = width / aspect;
}
var target = new BoundingRect_default(x, y, width, height);
var transform = rect.calculateTransform(target);
var geometries = this.geometries;
for (var i = 0; i < geometries.length; i++) {
var geo = geometries[i];
if (geo.type === "polygon") {
transformPoints(geo.exterior, transform);
each(geo.interiors, function(interior) {
transformPoints(interior, transform);
});
} else {
each(geo.points, function(points) {
transformPoints(points, transform);
});
}
}
rect = this._rect;
rect.copy(target);
this._center = [rect.x + rect.width / 2, rect.y + rect.height / 2];
};
GeoJSONRegion2.prototype.cloneShallow = function(name) {
name == null && (name = this.name);
var newRegion = new GeoJSONRegion2(name, this.geometries, this._center);
newRegion._rect = this._rect;
newRegion.transformTo = null;
return newRegion;
};
return GeoJSONRegion2;
}(Region)
);
var GeoSVGRegion = (
/** @class */
function(_super) {
__extends(GeoSVGRegion2, _super);
function GeoSVGRegion2(name, elOnlyForCalculate) {
var _this = _super.call(this, name) || this;
_this.type = "geoSVG";
_this._elOnlyForCalculate = elOnlyForCalculate;
return _this;
}
GeoSVGRegion2.prototype.calcCenter = function() {
var el = this._elOnlyForCalculate;
var rect = el.getBoundingRect();
var center = [rect.x + rect.width / 2, rect.y + rect.height / 2];
var mat = identity(TMP_TRANSFORM);
var target = el;
while (target && !target.isGeoSVGGraphicRoot) {
mul(mat, target.getLocalTransform(), mat);
target = target.parent;
}
invert(mat, mat);
applyTransform(center, center, mat);
return center;
};
return GeoSVGRegion2;
}(Region)
);
// ../node_modules/.pnpm/echarts@6.0.0/node_modules/echarts/lib/coord/geo/parseGeoJson.js
function decode(json) {
if (!json.UTF8Encoding) {
return json;
}
var jsonCompressed = json;
var encodeScale = jsonCompressed.UTF8Scale;
if (encodeScale == null) {
encodeScale = 1024;
}
var features = jsonCompressed.features;
each(features, function(feature) {
var geometry = feature.geometry;
var encodeOffsets = geometry.encodeOffsets;
var coordinates = geometry.coordinates;
if (!encodeOffsets) {
return;
}
switch (geometry.type) {
case "LineString":
geometry.coordinates = decodeRing(coordinates, encodeOffsets, encodeScale);
break;
case "Polygon":
decodeRings(coordinates, encodeOffsets, encodeScale);
break;
case "MultiLineString":
decodeRings(coordinates, encodeOffsets, encodeScale);
break;
case "MultiPolygon":
each(coordinates, function(rings, idx) {
return decodeRings(rings, encodeOffsets[idx], encodeScale);
});
}
});
jsonCompressed.UTF8Encoding = false;
return jsonCompressed;
}
function decodeRings(rings, encodeOffsets, encodeScale) {
for (var c = 0; c < rings.length; c++) {
rings[c] = decodeRing(rings[c], encodeOffsets[c], encodeScale);
}
}
function decodeRing(coordinate, encodeOffsets, encodeScale) {
var result = [];
var prevX = encodeOffsets[0];
var prevY = encodeOffsets[1];
for (var i = 0; i < coordinate.length; i += 2) {
var x = coordinate.charCodeAt(i) - 64;
var y = coordinate.charCodeAt(i + 1) - 64;
x = x >> 1 ^ -(x & 1);
y = y >> 1 ^ -(y & 1);
x += prevX;
y += prevY;
prevX = x;
prevY = y;
result.push([x / encodeScale, y / encodeScale]);
}
return result;
}
function parseGeoJSON(geoJson, nameProperty) {
geoJson = decode(geoJson);
return map(filter(geoJson.features, function(featureObj) {
return featureObj.geometry && featureObj.properties && featureObj.geometry.coordinates.length > 0;
}), function(featureObj) {
var properties = featureObj.properties;
var geo = featureObj.geometry;
var geometries = [];
switch (geo.type) {
case "Polygon":
var coordinates = geo.coordinates;
geometries.push(new GeoJSONPolygonGeometry(coordinates[0], coordinates.slice(1)));
break;
case "MultiPolygon":
each(geo.coordinates, function(item) {
if (item[0]) {
geometries.push(new GeoJSONPolygonGeometry(item[0], item.slice(1)));
}
});
break;
case "LineString":
geometries.push(new GeoJSONLineStringGeometry([geo.coordinates]));
break;
case "MultiLineString":
geometries.push(new GeoJSONLineStringGeometry(geo.coordinates));
}
var region = new GeoJSONRegion(properties[nameProperty || "name"], geometries, properties.cp);
region.properties = properties;
return region;
});
}
export {
contain,
GeoJSONRegion,
GeoSVGRegion,
parseGeoJSON
};
//# sourceMappingURL=chunk-WUVA3XFM.js.map