123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733 |
- import {
- __commonJS
- } from "./chunk-S5KM4IGW.js";
- // node_modules/earcut/src/earcut.js
- var require_earcut = __commonJS({
- "node_modules/earcut/src/earcut.js"(exports, module) {
- "use strict";
- module.exports = earcut;
- module.exports.default = earcut;
- function earcut(data, holeIndices, dim) {
- dim = dim || 2;
- var hasHoles = holeIndices && holeIndices.length, outerLen = hasHoles ? holeIndices[0] * dim : data.length, outerNode = linkedList(data, 0, outerLen, dim, true), triangles = [];
- if (!outerNode || outerNode.next === outerNode.prev)
- return triangles;
- var minX, minY, maxX, maxY, x, y, invSize;
- if (hasHoles)
- outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
- if (data.length > 80 * dim) {
- minX = maxX = data[0];
- minY = maxY = data[1];
- for (var i = dim; i < outerLen; i += dim) {
- x = data[i];
- y = data[i + 1];
- if (x < minX)
- minX = x;
- if (y < minY)
- minY = y;
- if (x > maxX)
- maxX = x;
- if (y > maxY)
- maxY = y;
- }
- invSize = Math.max(maxX - minX, maxY - minY);
- invSize = invSize !== 0 ? 32767 / invSize : 0;
- }
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
- return triangles;
- }
- function linkedList(data, start, end, dim, clockwise) {
- var i, last;
- if (clockwise === signedArea(data, start, end, dim) > 0) {
- for (i = start; i < end; i += dim)
- last = insertNode(i, data[i], data[i + 1], last);
- } else {
- for (i = end - dim; i >= start; i -= dim)
- last = insertNode(i, data[i], data[i + 1], last);
- }
- if (last && equals(last, last.next)) {
- removeNode(last);
- last = last.next;
- }
- return last;
- }
- function filterPoints(start, end) {
- if (!start)
- return start;
- if (!end)
- end = start;
- var p = start, again;
- do {
- again = false;
- if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
- removeNode(p);
- p = end = p.prev;
- if (p === p.next)
- break;
- again = true;
- } else {
- p = p.next;
- }
- } while (again || p !== end);
- return end;
- }
- function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
- if (!ear)
- return;
- if (!pass && invSize)
- indexCurve(ear, minX, minY, invSize);
- var stop = ear, prev, next;
- while (ear.prev !== ear.next) {
- prev = ear.prev;
- next = ear.next;
- if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
- triangles.push(prev.i / dim | 0);
- triangles.push(ear.i / dim | 0);
- triangles.push(next.i / dim | 0);
- removeNode(ear);
- ear = next.next;
- stop = next.next;
- continue;
- }
- ear = next;
- if (ear === stop) {
- if (!pass) {
- earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
- } else if (pass === 1) {
- ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
- earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
- } else if (pass === 2) {
- splitEarcut(ear, triangles, dim, minX, minY, invSize);
- }
- break;
- }
- }
- }
- function isEar(ear) {
- var a = ear.prev, b = ear, c = ear.next;
- if (area(a, b, c) >= 0)
- return false;
- var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
- var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
- var p = c.next;
- while (p !== a) {
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
- return false;
- p = p.next;
- }
- return true;
- }
- function isEarHashed(ear, minX, minY, invSize) {
- var a = ear.prev, b = ear, c = ear.next;
- if (area(a, b, c) >= 0)
- return false;
- var ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
- var x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx, y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy, x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx, y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
- var minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
- var p = ear.prevZ, n = ear.nextZ;
- while (p && p.z >= minZ && n && n.z <= maxZ) {
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
- return false;
- p = p.prevZ;
- if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
- return false;
- n = n.nextZ;
- }
- while (p && p.z >= minZ) {
- if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
- return false;
- p = p.prevZ;
- }
- while (n && n.z <= maxZ) {
- if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
- return false;
- n = n.nextZ;
- }
- return true;
- }
- function cureLocalIntersections(start, triangles, dim) {
- var p = start;
- do {
- var a = p.prev, b = p.next.next;
- if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
- triangles.push(a.i / dim | 0);
- triangles.push(p.i / dim | 0);
- triangles.push(b.i / dim | 0);
- removeNode(p);
- removeNode(p.next);
- p = start = b;
- }
- p = p.next;
- } while (p !== start);
- return filterPoints(p);
- }
- function splitEarcut(start, triangles, dim, minX, minY, invSize) {
- var a = start;
- do {
- var b = a.next.next;
- while (b !== a.prev) {
- if (a.i !== b.i && isValidDiagonal(a, b)) {
- var c = splitPolygon(a, b);
- a = filterPoints(a, a.next);
- c = filterPoints(c, c.next);
- earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
- earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
- return;
- }
- b = b.next;
- }
- a = a.next;
- } while (a !== start);
- }
- function eliminateHoles(data, holeIndices, outerNode, dim) {
- var queue = [], i, len, start, end, list;
- for (i = 0, len = holeIndices.length; i < len; i++) {
- start = holeIndices[i] * dim;
- end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
- list = linkedList(data, start, end, dim, false);
- if (list === list.next)
- list.steiner = true;
- queue.push(getLeftmost(list));
- }
- queue.sort(compareX);
- for (i = 0; i < queue.length; i++) {
- outerNode = eliminateHole(queue[i], outerNode);
- }
- return outerNode;
- }
- function compareX(a, b) {
- return a.x - b.x;
- }
- function eliminateHole(hole, outerNode) {
- var bridge = findHoleBridge(hole, outerNode);
- if (!bridge) {
- return outerNode;
- }
- var bridgeReverse = splitPolygon(bridge, hole);
- filterPoints(bridgeReverse, bridgeReverse.next);
- return filterPoints(bridge, bridge.next);
- }
- function findHoleBridge(hole, outerNode) {
- var p = outerNode, hx = hole.x, hy = hole.y, qx = -Infinity, m;
- do {
- if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
- var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
- if (x <= hx && x > qx) {
- qx = x;
- m = p.x < p.next.x ? p : p.next;
- if (x === hx)
- return m;
- }
- }
- p = p.next;
- } while (p !== outerNode);
- if (!m)
- return null;
- var stop = m, mx = m.x, my = m.y, tanMin = Infinity, tan;
- p = m;
- do {
- if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
- tan = Math.abs(hy - p.y) / (hx - p.x);
- if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
- m = p;
- tanMin = tan;
- }
- }
- p = p.next;
- } while (p !== stop);
- return m;
- }
- function sectorContainsSector(m, p) {
- return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
- }
- function indexCurve(start, minX, minY, invSize) {
- var p = start;
- do {
- if (p.z === 0)
- p.z = zOrder(p.x, p.y, minX, minY, invSize);
- p.prevZ = p.prev;
- p.nextZ = p.next;
- p = p.next;
- } while (p !== start);
- p.prevZ.nextZ = null;
- p.prevZ = null;
- sortLinked(p);
- }
- function sortLinked(list) {
- var i, p, q, e, tail, numMerges, pSize, qSize, inSize = 1;
- do {
- p = list;
- list = null;
- tail = null;
- numMerges = 0;
- while (p) {
- numMerges++;
- q = p;
- pSize = 0;
- for (i = 0; i < inSize; i++) {
- pSize++;
- q = q.nextZ;
- if (!q)
- break;
- }
- qSize = inSize;
- while (pSize > 0 || qSize > 0 && q) {
- if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
- e = p;
- p = p.nextZ;
- pSize--;
- } else {
- e = q;
- q = q.nextZ;
- qSize--;
- }
- if (tail)
- tail.nextZ = e;
- else
- list = e;
- e.prevZ = tail;
- tail = e;
- }
- p = q;
- }
- tail.nextZ = null;
- inSize *= 2;
- } while (numMerges > 1);
- return list;
- }
- function zOrder(x, y, minX, minY, invSize) {
- x = (x - minX) * invSize | 0;
- y = (y - minY) * invSize | 0;
- x = (x | x << 8) & 16711935;
- x = (x | x << 4) & 252645135;
- x = (x | x << 2) & 858993459;
- x = (x | x << 1) & 1431655765;
- y = (y | y << 8) & 16711935;
- y = (y | y << 4) & 252645135;
- y = (y | y << 2) & 858993459;
- y = (y | y << 1) & 1431655765;
- return x | y << 1;
- }
- function getLeftmost(start) {
- var p = start, leftmost = start;
- do {
- if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
- leftmost = p;
- p = p.next;
- } while (p !== start);
- return leftmost;
- }
- function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
- return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
- }
- function isValidDiagonal(a, b) {
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
- }
- function area(p, q, r) {
- return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
- }
- function equals(p1, p2) {
- return p1.x === p2.x && p1.y === p2.y;
- }
- function intersects(p1, q1, p2, q2) {
- var o1 = sign(area(p1, q1, p2));
- var o2 = sign(area(p1, q1, q2));
- var o3 = sign(area(p2, q2, p1));
- var o4 = sign(area(p2, q2, q1));
- if (o1 !== o2 && o3 !== o4)
- return true;
- if (o1 === 0 && onSegment(p1, p2, q1))
- return true;
- if (o2 === 0 && onSegment(p1, q2, q1))
- return true;
- if (o3 === 0 && onSegment(p2, p1, q2))
- return true;
- if (o4 === 0 && onSegment(p2, q1, q2))
- return true;
- return false;
- }
- function onSegment(p, q, r) {
- return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
- }
- function sign(num) {
- return num > 0 ? 1 : num < 0 ? -1 : 0;
- }
- function intersectsPolygon(a, b) {
- var p = a;
- do {
- if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b))
- return true;
- p = p.next;
- } while (p !== a);
- return false;
- }
- function locallyInside(a, b) {
- return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
- }
- function middleInside(a, b) {
- var p = a, inside = false, px = (a.x + b.x) / 2, py = (a.y + b.y) / 2;
- do {
- if (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)
- inside = !inside;
- p = p.next;
- } while (p !== a);
- return inside;
- }
- function splitPolygon(a, b) {
- var a2 = new Node(a.i, a.x, a.y), b2 = new Node(b.i, b.x, b.y), an = a.next, bp = b.prev;
- a.next = b;
- b.prev = a;
- a2.next = an;
- an.prev = a2;
- b2.next = a2;
- a2.prev = b2;
- bp.next = b2;
- b2.prev = bp;
- return b2;
- }
- function insertNode(i, x, y, last) {
- var p = new Node(i, x, y);
- if (!last) {
- p.prev = p;
- p.next = p;
- } else {
- p.next = last.next;
- p.prev = last;
- last.next.prev = p;
- last.next = p;
- }
- return p;
- }
- function removeNode(p) {
- p.next.prev = p.prev;
- p.prev.next = p.next;
- if (p.prevZ)
- p.prevZ.nextZ = p.nextZ;
- if (p.nextZ)
- p.nextZ.prevZ = p.prevZ;
- }
- function Node(i, x, y) {
- this.i = i;
- this.x = x;
- this.y = y;
- this.prev = null;
- this.next = null;
- this.z = 0;
- this.prevZ = null;
- this.nextZ = null;
- this.steiner = false;
- }
- earcut.deviation = function(data, holeIndices, dim, triangles) {
- var hasHoles = holeIndices && holeIndices.length;
- var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
- var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
- if (hasHoles) {
- for (var i = 0, len = holeIndices.length; i < len; i++) {
- var start = holeIndices[i] * dim;
- var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
- polygonArea -= Math.abs(signedArea(data, start, end, dim));
- }
- }
- var trianglesArea = 0;
- for (i = 0; i < triangles.length; i += 3) {
- var a = triangles[i] * dim;
- var b = triangles[i + 1] * dim;
- var c = triangles[i + 2] * dim;
- trianglesArea += Math.abs(
- (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - (data[a] - data[b]) * (data[c + 1] - data[a + 1])
- );
- }
- return polygonArea === 0 && trianglesArea === 0 ? 0 : Math.abs((trianglesArea - polygonArea) / polygonArea);
- };
- function signedArea(data, start, end, dim) {
- var sum = 0;
- for (var i = start, j = end - dim; i < end; i += dim) {
- sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
- j = i;
- }
- return sum;
- }
- earcut.flatten = function(data) {
- var dim = data[0][0].length, result = { vertices: [], holes: [], dimensions: dim }, holeIndex = 0;
- for (var i = 0; i < data.length; i++) {
- for (var j = 0; j < data[i].length; j++) {
- for (var d = 0; d < dim; d++)
- result.vertices.push(data[i][j][d]);
- }
- if (i > 0) {
- holeIndex += data[i - 1].length;
- result.holes.push(holeIndex);
- }
- }
- return result;
- };
- }
- });
- // node_modules/topojson-client/src/reverse.js
- function reverse_default(array, n) {
- var t, j = array.length, i = j - n;
- while (i < --j)
- t = array[i], array[i++] = array[j], array[j] = t;
- }
- // node_modules/topojson-client/src/identity.js
- function identity_default(x) {
- return x;
- }
- // node_modules/topojson-client/src/transform.js
- function transform_default(transform) {
- if (transform == null)
- return identity_default;
- var x0, y0, kx = transform.scale[0], ky = transform.scale[1], dx = transform.translate[0], dy = transform.translate[1];
- return function(input, i) {
- if (!i)
- x0 = y0 = 0;
- var j = 2, n = input.length, output = new Array(n);
- output[0] = (x0 += input[0]) * kx + dx;
- output[1] = (y0 += input[1]) * ky + dy;
- while (j < n)
- output[j] = input[j], ++j;
- return output;
- };
- }
- // node_modules/topojson-client/src/feature.js
- function feature_default(topology, o) {
- if (typeof o === "string")
- o = topology.objects[o];
- return o.type === "GeometryCollection" ? { type: "FeatureCollection", features: o.geometries.map(function(o2) {
- return feature(topology, o2);
- }) } : feature(topology, o);
- }
- function feature(topology, o) {
- var id = o.id, bbox = o.bbox, properties = o.properties == null ? {} : o.properties, geometry = object(topology, o);
- return id == null && bbox == null ? { type: "Feature", properties, geometry } : bbox == null ? { type: "Feature", id, properties, geometry } : { type: "Feature", id, bbox, properties, geometry };
- }
- function object(topology, o) {
- var transformPoint = transform_default(topology.transform), arcs = topology.arcs;
- function arc(i, points) {
- if (points.length)
- points.pop();
- for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length; k < n; ++k) {
- points.push(transformPoint(a[k], k));
- }
- if (i < 0)
- reverse_default(points, n);
- }
- function point(p) {
- return transformPoint(p);
- }
- function line(arcs2) {
- var points = [];
- for (var i = 0, n = arcs2.length; i < n; ++i)
- arc(arcs2[i], points);
- if (points.length < 2)
- points.push(points[0]);
- return points;
- }
- function ring(arcs2) {
- var points = line(arcs2);
- while (points.length < 4)
- points.push(points[0]);
- return points;
- }
- function polygon(arcs2) {
- return arcs2.map(ring);
- }
- function geometry(o2) {
- var type = o2.type, coordinates;
- switch (type) {
- case "GeometryCollection":
- return { type, geometries: o2.geometries.map(geometry) };
- case "Point":
- coordinates = point(o2.coordinates);
- break;
- case "MultiPoint":
- coordinates = o2.coordinates.map(point);
- break;
- case "LineString":
- coordinates = line(o2.arcs);
- break;
- case "MultiLineString":
- coordinates = o2.arcs.map(line);
- break;
- case "Polygon":
- coordinates = polygon(o2.arcs);
- break;
- case "MultiPolygon":
- coordinates = o2.arcs.map(polygon);
- break;
- default:
- return null;
- }
- return { type, coordinates };
- }
- return geometry(o);
- }
- // node_modules/topojson-client/src/stitch.js
- function stitch_default(topology, arcs) {
- var stitchedArcs = {}, fragmentByStart = {}, fragmentByEnd = {}, fragments = [], emptyIndex = -1;
- arcs.forEach(function(i, j) {
- var arc = topology.arcs[i < 0 ? ~i : i], t;
- if (arc.length < 3 && !arc[1][0] && !arc[1][1]) {
- t = arcs[++emptyIndex], arcs[emptyIndex] = i, arcs[j] = t;
- }
- });
- arcs.forEach(function(i) {
- var e = ends(i), start = e[0], end = e[1], f, g;
- if (f = fragmentByEnd[start]) {
- delete fragmentByEnd[f.end];
- f.push(i);
- f.end = end;
- if (g = fragmentByStart[end]) {
- delete fragmentByStart[g.start];
- var fg = g === f ? f : f.concat(g);
- fragmentByStart[fg.start = f.start] = fragmentByEnd[fg.end = g.end] = fg;
- } else {
- fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
- }
- } else if (f = fragmentByStart[end]) {
- delete fragmentByStart[f.start];
- f.unshift(i);
- f.start = start;
- if (g = fragmentByEnd[start]) {
- delete fragmentByEnd[g.end];
- var gf = g === f ? f : g.concat(f);
- fragmentByStart[gf.start = g.start] = fragmentByEnd[gf.end = f.end] = gf;
- } else {
- fragmentByStart[f.start] = fragmentByEnd[f.end] = f;
- }
- } else {
- f = [i];
- fragmentByStart[f.start = start] = fragmentByEnd[f.end = end] = f;
- }
- });
- function ends(i) {
- var arc = topology.arcs[i < 0 ? ~i : i], p0 = arc[0], p1;
- if (topology.transform)
- p1 = [0, 0], arc.forEach(function(dp) {
- p1[0] += dp[0], p1[1] += dp[1];
- });
- else
- p1 = arc[arc.length - 1];
- return i < 0 ? [p1, p0] : [p0, p1];
- }
- function flush(fragmentByEnd2, fragmentByStart2) {
- for (var k in fragmentByEnd2) {
- var f = fragmentByEnd2[k];
- delete fragmentByStart2[f.start];
- delete f.start;
- delete f.end;
- f.forEach(function(i) {
- stitchedArcs[i < 0 ? ~i : i] = 1;
- });
- fragments.push(f);
- }
- }
- flush(fragmentByEnd, fragmentByStart);
- flush(fragmentByStart, fragmentByEnd);
- arcs.forEach(function(i) {
- if (!stitchedArcs[i < 0 ? ~i : i])
- fragments.push([i]);
- });
- return fragments;
- }
- // node_modules/topojson-client/src/merge.js
- function planarRingArea(ring) {
- var i = -1, n = ring.length, a, b = ring[n - 1], area = 0;
- while (++i < n)
- a = b, b = ring[i], area += a[0] * b[1] - a[1] * b[0];
- return Math.abs(area);
- }
- function merge_default(topology) {
- return object(topology, mergeArcs.apply(this, arguments));
- }
- function mergeArcs(topology, objects) {
- var polygonsByArc = {}, polygons = [], groups = [];
- objects.forEach(geometry);
- function geometry(o) {
- switch (o.type) {
- case "GeometryCollection":
- o.geometries.forEach(geometry);
- break;
- case "Polygon":
- extract(o.arcs);
- break;
- case "MultiPolygon":
- o.arcs.forEach(extract);
- break;
- }
- }
- function extract(polygon) {
- polygon.forEach(function(ring) {
- ring.forEach(function(arc) {
- (polygonsByArc[arc = arc < 0 ? ~arc : arc] || (polygonsByArc[arc] = [])).push(polygon);
- });
- });
- polygons.push(polygon);
- }
- function area(ring) {
- return planarRingArea(object(topology, { type: "Polygon", arcs: [ring] }).coordinates[0]);
- }
- polygons.forEach(function(polygon) {
- if (!polygon._) {
- var group = [], neighbors = [polygon];
- polygon._ = 1;
- groups.push(group);
- while (polygon = neighbors.pop()) {
- group.push(polygon);
- polygon.forEach(function(ring) {
- ring.forEach(function(arc) {
- polygonsByArc[arc < 0 ? ~arc : arc].forEach(function(polygon2) {
- if (!polygon2._) {
- polygon2._ = 1;
- neighbors.push(polygon2);
- }
- });
- });
- });
- }
- }
- });
- polygons.forEach(function(polygon) {
- delete polygon._;
- });
- return {
- type: "MultiPolygon",
- arcs: groups.map(function(polygons2) {
- var arcs = [], n;
- polygons2.forEach(function(polygon) {
- polygon.forEach(function(ring) {
- ring.forEach(function(arc) {
- if (polygonsByArc[arc < 0 ? ~arc : arc].length < 2) {
- arcs.push(arc);
- }
- });
- });
- });
- arcs = stitch_default(topology, arcs);
- if ((n = arcs.length) > 1) {
- for (var i = 1, k = area(arcs[0]), ki, t; i < n; ++i) {
- if ((ki = area(arcs[i])) > k) {
- t = arcs[0], arcs[0] = arcs[i], arcs[i] = t, k = ki;
- }
- }
- }
- return arcs;
- }).filter(function(arcs) {
- return arcs.length > 0;
- })
- };
- }
- export {
- feature_default,
- merge_default,
- require_earcut
- };
- //# sourceMappingURL=chunk-7ANULLBZ.js.map
|