@diagrammo/dgmo 0.20.1 → 0.20.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/advanced.cjs +73 -47
- package/dist/advanced.js +73 -47
- package/dist/auto.cjs +74 -48
- package/dist/auto.js +102 -102
- package/dist/auto.mjs +74 -48
- package/dist/cli.cjs +134 -134
- package/dist/index.cjs +73 -47
- package/dist/index.js +73 -47
- package/dist/internal.cjs +73 -47
- package/dist/internal.js +73 -47
- package/docs/language-reference.md +4 -4
- package/package.json +1 -1
- package/src/map/layout.ts +134 -72
- package/src/map/resolver.ts +8 -1
package/dist/auto.mjs
CHANGED
|
@@ -45851,7 +45851,7 @@ function resolveMap(parsed, data) {
|
|
|
45851
45851
|
const lonSpan = extent2[1][0] - extent2[0][0];
|
|
45852
45852
|
const latSpan = extent2[1][1] - extent2[0][1];
|
|
45853
45853
|
const span = Math.max(lonSpan, latSpan);
|
|
45854
|
-
const usDominant = (
|
|
45854
|
+
const usDominant = (subdivisions.includes("us-states") || regions.some((r) => r.layer === "us-state")) && !regions.some((r) => r.layer === "country" && r.iso !== "US") && !anyNonUsPoi;
|
|
45855
45855
|
let projection;
|
|
45856
45856
|
const override = parsed.directives.projection;
|
|
45857
45857
|
if (override === "equirectangular" || override === "natural-earth" || override === "albers-usa" || override === "mercator") {
|
|
@@ -46104,8 +46104,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46104
46104
|
const { width, height } = size;
|
|
46105
46105
|
const wantsUsStates = resolved.basemaps.subdivisions.includes("us-states");
|
|
46106
46106
|
const usCrisp = resolved.projection === "albers-usa" && wantsUsStates && !!data.naLand;
|
|
46107
|
-
const worldTopo = usCrisp ? data.
|
|
46107
|
+
const worldTopo = usCrisp ? data.worldDetail : resolved.basemaps.world === "detail" ? data.worldDetail : data.worldCoarse;
|
|
46108
46108
|
const worldLayer = decodeLayer(worldTopo);
|
|
46109
|
+
if (usCrisp && data.naLand) {
|
|
46110
|
+
const [nbW, nbS, nbE, nbN] = [-140, 10, -52, 66];
|
|
46111
|
+
const crisp = decodeLayer(data.naLand);
|
|
46112
|
+
for (const [iso, cf] of crisp) {
|
|
46113
|
+
const base = worldLayer.get(iso);
|
|
46114
|
+
if (!base) continue;
|
|
46115
|
+
const [[bw, bs], [be, bn]] = geoBounds2(base);
|
|
46116
|
+
if (bw >= nbW && be <= nbE && bs >= nbS && bn <= nbN)
|
|
46117
|
+
worldLayer.set(iso, cf);
|
|
46118
|
+
}
|
|
46119
|
+
}
|
|
46109
46120
|
const usLayer = wantsUsStates ? decodeLayer(data.usStates) : null;
|
|
46110
46121
|
const landTint = isDark ? LAND_TINT_DARK : LAND_TINT_LIGHT;
|
|
46111
46122
|
const neutralFill = mix(palette.colors.green, palette.bg, landTint);
|
|
@@ -46251,6 +46262,10 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46251
46262
|
return p ? stretch(p[0], p[1]) : null;
|
|
46252
46263
|
};
|
|
46253
46264
|
} else {
|
|
46265
|
+
projection.clipExtent([
|
|
46266
|
+
[0, 0],
|
|
46267
|
+
[width, height]
|
|
46268
|
+
]);
|
|
46254
46269
|
path = geoPath(projection);
|
|
46255
46270
|
project = (lon, lat) => projection([lon, lat]) ?? null;
|
|
46256
46271
|
}
|
|
@@ -46395,18 +46410,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46395
46410
|
placeInset("US-HI", hawaiiProjection(), akRight + 24, width * 0.1);
|
|
46396
46411
|
}
|
|
46397
46412
|
const conusFit = resolved.projection === "albers-usa" && !!usLayer;
|
|
46398
|
-
const
|
|
46399
|
-
const [[
|
|
46400
|
-
const
|
|
46401
|
-
const
|
|
46402
|
-
const
|
|
46403
|
-
const padLon = Math.max(8, lonSpan * 0.35);
|
|
46404
|
-
const padLat = Math.max(8, latSpan * 0.35);
|
|
46405
|
-
const vW = exW - padLon;
|
|
46406
|
-
const vE = exE + padLon;
|
|
46407
|
-
const vS = exS - padLat;
|
|
46408
|
-
const vN = exN + padLat;
|
|
46409
|
-
const vLonCenter = (exW + exE) / 2;
|
|
46413
|
+
const classifyExtent = conusFit ? geoBounds2(fitTarget) : resolved.extent;
|
|
46414
|
+
const dLonSpan = classifyExtent[1][0] - classifyExtent[0][0];
|
|
46415
|
+
const dLatSpan = classifyExtent[1][1] - classifyExtent[0][1];
|
|
46416
|
+
const isGlobalView = dLonSpan >= 270 || dLatSpan >= 130;
|
|
46417
|
+
const vLonCenter = (classifyExtent[0][0] + classifyExtent[1][0]) / 2;
|
|
46410
46418
|
const normLon = (lon) => {
|
|
46411
46419
|
let L = lon;
|
|
46412
46420
|
while (L < vLonCenter - 180) L += 360;
|
|
@@ -46414,23 +46422,28 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46414
46422
|
return L;
|
|
46415
46423
|
};
|
|
46416
46424
|
const ringOverlapsView = (ring) => {
|
|
46417
|
-
let
|
|
46418
|
-
|
|
46419
|
-
for (const [rawLon, lat] of ring) {
|
|
46425
|
+
let loMin = Infinity, loMax = -Infinity, rawMin = Infinity, rawMax = -Infinity;
|
|
46426
|
+
for (const [rawLon] of ring) {
|
|
46420
46427
|
const lon = normLon(rawLon);
|
|
46421
|
-
if (lon >= vW && lon <= vE && lat >= vS && lat <= vN) anyIn = true;
|
|
46422
46428
|
if (lon < loMin) loMin = lon;
|
|
46423
46429
|
if (lon > loMax) loMax = lon;
|
|
46424
46430
|
if (rawLon < rawMin) rawMin = rawLon;
|
|
46425
46431
|
if (rawLon > rawMax) rawMax = rawLon;
|
|
46426
|
-
if (lat < laMin) laMin = lat;
|
|
46427
|
-
if (lat > laMax) laMax = lat;
|
|
46428
46432
|
}
|
|
46429
46433
|
if (loMax - loMin > 270) return false;
|
|
46430
46434
|
if (rawMax - rawMin > 180 && loMax - loMin < 90) return false;
|
|
46431
|
-
|
|
46432
|
-
|
|
46433
|
-
|
|
46435
|
+
let px0 = Infinity, py0 = Infinity, px1 = -Infinity, py1 = -Infinity, anyFinite = false;
|
|
46436
|
+
for (const [lon, lat] of ring) {
|
|
46437
|
+
const p = project(lon, lat);
|
|
46438
|
+
if (!p || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) continue;
|
|
46439
|
+
anyFinite = true;
|
|
46440
|
+
if (p[0] < px0) px0 = p[0];
|
|
46441
|
+
if (p[0] > px1) px1 = p[0];
|
|
46442
|
+
if (p[1] < py0) py0 = p[1];
|
|
46443
|
+
if (p[1] > py1) py1 = p[1];
|
|
46444
|
+
}
|
|
46445
|
+
if (!anyFinite) return false;
|
|
46446
|
+
return !(px1 < 0 || px0 > width || py1 < 0 || py0 > height);
|
|
46434
46447
|
};
|
|
46435
46448
|
const cullFeatureToView = (f) => {
|
|
46436
46449
|
if (isGlobalView) return f;
|
|
@@ -46821,19 +46834,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46821
46834
|
const text = labelText(p);
|
|
46822
46835
|
return { text, w: measureLegendText(text, FONT) };
|
|
46823
46836
|
};
|
|
46837
|
+
const GAP = 3;
|
|
46838
|
+
const inlineRect = (p, w, side) => {
|
|
46839
|
+
switch (side) {
|
|
46840
|
+
case "right":
|
|
46841
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
46842
|
+
case "left":
|
|
46843
|
+
return {
|
|
46844
|
+
x: p.cx - p.r - GAP - w,
|
|
46845
|
+
y: p.cy - poiLabH / 2,
|
|
46846
|
+
w,
|
|
46847
|
+
h: poiLabH
|
|
46848
|
+
};
|
|
46849
|
+
case "above":
|
|
46850
|
+
return {
|
|
46851
|
+
x: p.cx - w / 2,
|
|
46852
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
46853
|
+
w,
|
|
46854
|
+
h: poiLabH
|
|
46855
|
+
};
|
|
46856
|
+
case "below":
|
|
46857
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
46858
|
+
}
|
|
46859
|
+
};
|
|
46824
46860
|
const pushInline = (p, text, w, side) => {
|
|
46825
|
-
const
|
|
46826
|
-
obstacles.push(
|
|
46827
|
-
|
|
46828
|
-
|
|
46829
|
-
w,
|
|
46830
|
-
h: poiLabH
|
|
46831
|
-
});
|
|
46861
|
+
const rect = inlineRect(p, w, side);
|
|
46862
|
+
obstacles.push(rect);
|
|
46863
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
46864
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
46832
46865
|
labels.push({
|
|
46833
|
-
x
|
|
46834
|
-
y:
|
|
46866
|
+
x,
|
|
46867
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
46835
46868
|
text,
|
|
46836
|
-
anchor
|
|
46869
|
+
anchor,
|
|
46837
46870
|
color: palette.text,
|
|
46838
46871
|
halo: true,
|
|
46839
46872
|
haloColor: palette.bg,
|
|
@@ -46842,14 +46875,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46842
46875
|
});
|
|
46843
46876
|
};
|
|
46844
46877
|
const inlineFits = (p, w, side) => {
|
|
46845
|
-
const
|
|
46846
|
-
|
|
46847
|
-
x: side === "right" ? tx : tx - w,
|
|
46848
|
-
y: p.cy - poiLabH / 2,
|
|
46849
|
-
w,
|
|
46850
|
-
h: poiLabH
|
|
46851
|
-
};
|
|
46852
|
-
return rect.x >= 0 && rect.x + rect.w <= width && !collides(rect);
|
|
46878
|
+
const rect = inlineRect(p, w, side);
|
|
46879
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
46853
46880
|
};
|
|
46854
46881
|
const GROUP_R = 30;
|
|
46855
46882
|
const groups = [];
|
|
@@ -46906,12 +46933,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46906
46933
|
if (g.length === 1) {
|
|
46907
46934
|
const p = g[0];
|
|
46908
46935
|
const { text, w } = labelInfo(p);
|
|
46909
|
-
|
|
46910
|
-
|
|
46911
|
-
|
|
46912
|
-
|
|
46913
|
-
|
|
46914
|
-
pushInline(p, text, w, "left");
|
|
46936
|
+
const side = ["right", "left", "above", "below"].find(
|
|
46937
|
+
(s) => inlineFits(p, w, s)
|
|
46938
|
+
);
|
|
46939
|
+
if (side) {
|
|
46940
|
+
pushInline(p, text, w, side);
|
|
46915
46941
|
continue;
|
|
46916
46942
|
}
|
|
46917
46943
|
}
|
|
@@ -57051,7 +57077,7 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
57051
57077
|
|
|
57052
57078
|
// src/auto/index.ts
|
|
57053
57079
|
init_safe_href();
|
|
57054
|
-
var VERSION = "0.20.
|
|
57080
|
+
var VERSION = "0.20.2";
|
|
57055
57081
|
var DEFAULTS = {
|
|
57056
57082
|
theme: "auto",
|
|
57057
57083
|
palette: "nord",
|