@diagrammo/dgmo 0.20.1 → 0.20.3
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 +75 -47
- package/dist/advanced.js +75 -47
- package/dist/auto.cjs +76 -48
- package/dist/auto.js +102 -102
- package/dist/auto.mjs +76 -48
- package/dist/cli.cjs +134 -134
- package/dist/index.cjs +75 -47
- package/dist/index.js +75 -47
- package/dist/internal.cjs +75 -47
- package/dist/internal.js +75 -47
- package/docs/language-reference.md +4 -4
- package/package.json +1 -1
- package/src/map/layout.ts +141 -72
- package/src/map/resolver.ts +8 -1
package/dist/advanced.cjs
CHANGED
|
@@ -46197,7 +46197,7 @@ function resolveMap(parsed, data) {
|
|
|
46197
46197
|
const lonSpan = extent2[1][0] - extent2[0][0];
|
|
46198
46198
|
const latSpan = extent2[1][1] - extent2[0][1];
|
|
46199
46199
|
const span = Math.max(lonSpan, latSpan);
|
|
46200
|
-
const usDominant = (
|
|
46200
|
+
const usDominant = (subdivisions.includes("us-states") || regions.some((r) => r.layer === "us-state")) && !regions.some((r) => r.layer === "country" && r.iso !== "US") && !anyNonUsPoi;
|
|
46201
46201
|
let projection;
|
|
46202
46202
|
const override = parsed.directives.projection;
|
|
46203
46203
|
if (override === "equirectangular" || override === "natural-earth" || override === "albers-usa" || override === "mercator") {
|
|
@@ -46448,8 +46448,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46448
46448
|
const { width, height } = size;
|
|
46449
46449
|
const wantsUsStates = resolved.basemaps.subdivisions.includes("us-states");
|
|
46450
46450
|
const usCrisp = resolved.projection === "albers-usa" && wantsUsStates && !!data.naLand;
|
|
46451
|
-
const worldTopo = usCrisp ? data.
|
|
46451
|
+
const worldTopo = usCrisp ? data.worldDetail : resolved.basemaps.world === "detail" ? data.worldDetail : data.worldCoarse;
|
|
46452
46452
|
const worldLayer = decodeLayer(worldTopo);
|
|
46453
|
+
if (usCrisp && data.naLand) {
|
|
46454
|
+
const [nbW, nbS, nbE, nbN] = [-140, 10, -52, 66];
|
|
46455
|
+
const crisp = decodeLayer(data.naLand);
|
|
46456
|
+
for (const [iso, cf] of crisp) {
|
|
46457
|
+
const base = worldLayer.get(iso);
|
|
46458
|
+
if (!base) continue;
|
|
46459
|
+
const [[bw, bs], [be, bn]] = (0, import_d3_geo2.geoBounds)(base);
|
|
46460
|
+
if (bw >= nbW && be <= nbE && bs >= nbS && bn <= nbN)
|
|
46461
|
+
worldLayer.set(iso, cf);
|
|
46462
|
+
}
|
|
46463
|
+
}
|
|
46453
46464
|
const usLayer = wantsUsStates ? decodeLayer(data.usStates) : null;
|
|
46454
46465
|
const landTint = isDark ? LAND_TINT_DARK : LAND_TINT_LIGHT;
|
|
46455
46466
|
const neutralFill = mix(palette.colors.green, palette.bg, landTint);
|
|
@@ -46595,6 +46606,10 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46595
46606
|
return p ? stretch(p[0], p[1]) : null;
|
|
46596
46607
|
};
|
|
46597
46608
|
} else {
|
|
46609
|
+
projection.clipExtent([
|
|
46610
|
+
[0, 0],
|
|
46611
|
+
[width, height]
|
|
46612
|
+
]);
|
|
46598
46613
|
path = (0, import_d3_geo2.geoPath)(projection);
|
|
46599
46614
|
project = (lon, lat) => projection([lon, lat]) ?? null;
|
|
46600
46615
|
}
|
|
@@ -46739,18 +46754,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46739
46754
|
placeInset("US-HI", hawaiiProjection(), akRight + 24, width * 0.1);
|
|
46740
46755
|
}
|
|
46741
46756
|
const conusFit = resolved.projection === "albers-usa" && !!usLayer;
|
|
46742
|
-
const
|
|
46743
|
-
const [[
|
|
46744
|
-
const
|
|
46745
|
-
const
|
|
46746
|
-
const
|
|
46747
|
-
const padLon = Math.max(8, lonSpan * 0.35);
|
|
46748
|
-
const padLat = Math.max(8, latSpan * 0.35);
|
|
46749
|
-
const vW = exW - padLon;
|
|
46750
|
-
const vE = exE + padLon;
|
|
46751
|
-
const vS = exS - padLat;
|
|
46752
|
-
const vN = exN + padLat;
|
|
46753
|
-
const vLonCenter = (exW + exE) / 2;
|
|
46757
|
+
const classifyExtent = conusFit ? (0, import_d3_geo2.geoBounds)(fitTarget) : resolved.extent;
|
|
46758
|
+
const dLonSpan = classifyExtent[1][0] - classifyExtent[0][0];
|
|
46759
|
+
const dLatSpan = classifyExtent[1][1] - classifyExtent[0][1];
|
|
46760
|
+
const isGlobalView = dLonSpan >= 270 || dLatSpan >= 130;
|
|
46761
|
+
const vLonCenter = (classifyExtent[0][0] + classifyExtent[1][0]) / 2;
|
|
46754
46762
|
const normLon = (lon) => {
|
|
46755
46763
|
let L = lon;
|
|
46756
46764
|
while (L < vLonCenter - 180) L += 360;
|
|
@@ -46758,23 +46766,28 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46758
46766
|
return L;
|
|
46759
46767
|
};
|
|
46760
46768
|
const ringOverlapsView = (ring) => {
|
|
46761
|
-
let
|
|
46762
|
-
|
|
46763
|
-
for (const [rawLon, lat] of ring) {
|
|
46769
|
+
let loMin = Infinity, loMax = -Infinity, rawMin = Infinity, rawMax = -Infinity;
|
|
46770
|
+
for (const [rawLon] of ring) {
|
|
46764
46771
|
const lon = normLon(rawLon);
|
|
46765
|
-
if (lon >= vW && lon <= vE && lat >= vS && lat <= vN) anyIn = true;
|
|
46766
46772
|
if (lon < loMin) loMin = lon;
|
|
46767
46773
|
if (lon > loMax) loMax = lon;
|
|
46768
46774
|
if (rawLon < rawMin) rawMin = rawLon;
|
|
46769
46775
|
if (rawLon > rawMax) rawMax = rawLon;
|
|
46770
|
-
if (lat < laMin) laMin = lat;
|
|
46771
|
-
if (lat > laMax) laMax = lat;
|
|
46772
46776
|
}
|
|
46773
46777
|
if (loMax - loMin > 270) return false;
|
|
46774
46778
|
if (rawMax - rawMin > 180 && loMax - loMin < 90) return false;
|
|
46775
|
-
|
|
46776
|
-
|
|
46777
|
-
|
|
46779
|
+
let px0 = Infinity, py0 = Infinity, px1 = -Infinity, py1 = -Infinity, anyFinite = false;
|
|
46780
|
+
for (const [lon, lat] of ring) {
|
|
46781
|
+
const p = project(lon, lat);
|
|
46782
|
+
if (!p || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) continue;
|
|
46783
|
+
anyFinite = true;
|
|
46784
|
+
if (p[0] < px0) px0 = p[0];
|
|
46785
|
+
if (p[0] > px1) px1 = p[0];
|
|
46786
|
+
if (p[1] < py0) py0 = p[1];
|
|
46787
|
+
if (p[1] > py1) py1 = p[1];
|
|
46788
|
+
}
|
|
46789
|
+
if (!anyFinite) return false;
|
|
46790
|
+
return !(px1 < 0 || px0 > width || py1 < 0 || py0 > height);
|
|
46778
46791
|
};
|
|
46779
46792
|
const cullFeatureToView = (f) => {
|
|
46780
46793
|
if (isGlobalView) return f;
|
|
@@ -46838,6 +46851,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46838
46851
|
if (layerKind === "us-state" && usContext && INSET_STATES.has(iso))
|
|
46839
46852
|
continue;
|
|
46840
46853
|
if (layerKind === "country" && usContext && iso === "US") continue;
|
|
46854
|
+
if (layerKind === "country" && iso === "AQ" && !regionById.has("AQ"))
|
|
46855
|
+
continue;
|
|
46841
46856
|
const r = regionById.get(iso);
|
|
46842
46857
|
const viewF = shouldCull ? cullFeatureToView(f) : dropFrameFillers(f);
|
|
46843
46858
|
if (!viewF) continue;
|
|
@@ -47165,19 +47180,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47165
47180
|
const text = labelText(p);
|
|
47166
47181
|
return { text, w: measureLegendText(text, FONT) };
|
|
47167
47182
|
};
|
|
47183
|
+
const GAP = 3;
|
|
47184
|
+
const inlineRect = (p, w, side) => {
|
|
47185
|
+
switch (side) {
|
|
47186
|
+
case "right":
|
|
47187
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
47188
|
+
case "left":
|
|
47189
|
+
return {
|
|
47190
|
+
x: p.cx - p.r - GAP - w,
|
|
47191
|
+
y: p.cy - poiLabH / 2,
|
|
47192
|
+
w,
|
|
47193
|
+
h: poiLabH
|
|
47194
|
+
};
|
|
47195
|
+
case "above":
|
|
47196
|
+
return {
|
|
47197
|
+
x: p.cx - w / 2,
|
|
47198
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
47199
|
+
w,
|
|
47200
|
+
h: poiLabH
|
|
47201
|
+
};
|
|
47202
|
+
case "below":
|
|
47203
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
47204
|
+
}
|
|
47205
|
+
};
|
|
47168
47206
|
const pushInline = (p, text, w, side) => {
|
|
47169
|
-
const
|
|
47170
|
-
obstacles.push(
|
|
47171
|
-
|
|
47172
|
-
|
|
47173
|
-
w,
|
|
47174
|
-
h: poiLabH
|
|
47175
|
-
});
|
|
47207
|
+
const rect = inlineRect(p, w, side);
|
|
47208
|
+
obstacles.push(rect);
|
|
47209
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
47210
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
47176
47211
|
labels.push({
|
|
47177
|
-
x
|
|
47178
|
-
y:
|
|
47212
|
+
x,
|
|
47213
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
47179
47214
|
text,
|
|
47180
|
-
anchor
|
|
47215
|
+
anchor,
|
|
47181
47216
|
color: palette.text,
|
|
47182
47217
|
halo: true,
|
|
47183
47218
|
haloColor: palette.bg,
|
|
@@ -47186,14 +47221,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47186
47221
|
});
|
|
47187
47222
|
};
|
|
47188
47223
|
const inlineFits = (p, w, side) => {
|
|
47189
|
-
const
|
|
47190
|
-
|
|
47191
|
-
x: side === "right" ? tx : tx - w,
|
|
47192
|
-
y: p.cy - poiLabH / 2,
|
|
47193
|
-
w,
|
|
47194
|
-
h: poiLabH
|
|
47195
|
-
};
|
|
47196
|
-
return rect.x >= 0 && rect.x + rect.w <= width && !collides(rect);
|
|
47224
|
+
const rect = inlineRect(p, w, side);
|
|
47225
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
47197
47226
|
};
|
|
47198
47227
|
const GROUP_R = 30;
|
|
47199
47228
|
const groups = [];
|
|
@@ -47250,12 +47279,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47250
47279
|
if (g.length === 1) {
|
|
47251
47280
|
const p = g[0];
|
|
47252
47281
|
const { text, w } = labelInfo(p);
|
|
47253
|
-
|
|
47254
|
-
|
|
47255
|
-
|
|
47256
|
-
|
|
47257
|
-
|
|
47258
|
-
pushInline(p, text, w, "left");
|
|
47282
|
+
const side = ["right", "left", "above", "below"].find(
|
|
47283
|
+
(s) => inlineFits(p, w, s)
|
|
47284
|
+
);
|
|
47285
|
+
if (side) {
|
|
47286
|
+
pushInline(p, text, w, side);
|
|
47259
47287
|
continue;
|
|
47260
47288
|
}
|
|
47261
47289
|
}
|
package/dist/advanced.js
CHANGED
|
@@ -46213,7 +46213,7 @@ function resolveMap(parsed, data) {
|
|
|
46213
46213
|
const lonSpan = extent2[1][0] - extent2[0][0];
|
|
46214
46214
|
const latSpan = extent2[1][1] - extent2[0][1];
|
|
46215
46215
|
const span = Math.max(lonSpan, latSpan);
|
|
46216
|
-
const usDominant = (
|
|
46216
|
+
const usDominant = (subdivisions.includes("us-states") || regions.some((r) => r.layer === "us-state")) && !regions.some((r) => r.layer === "country" && r.iso !== "US") && !anyNonUsPoi;
|
|
46217
46217
|
let projection;
|
|
46218
46218
|
const override = parsed.directives.projection;
|
|
46219
46219
|
if (override === "equirectangular" || override === "natural-earth" || override === "albers-usa" || override === "mercator") {
|
|
@@ -46473,8 +46473,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46473
46473
|
const { width, height } = size;
|
|
46474
46474
|
const wantsUsStates = resolved.basemaps.subdivisions.includes("us-states");
|
|
46475
46475
|
const usCrisp = resolved.projection === "albers-usa" && wantsUsStates && !!data.naLand;
|
|
46476
|
-
const worldTopo = usCrisp ? data.
|
|
46476
|
+
const worldTopo = usCrisp ? data.worldDetail : resolved.basemaps.world === "detail" ? data.worldDetail : data.worldCoarse;
|
|
46477
46477
|
const worldLayer = decodeLayer(worldTopo);
|
|
46478
|
+
if (usCrisp && data.naLand) {
|
|
46479
|
+
const [nbW, nbS, nbE, nbN] = [-140, 10, -52, 66];
|
|
46480
|
+
const crisp = decodeLayer(data.naLand);
|
|
46481
|
+
for (const [iso, cf] of crisp) {
|
|
46482
|
+
const base = worldLayer.get(iso);
|
|
46483
|
+
if (!base) continue;
|
|
46484
|
+
const [[bw, bs], [be, bn]] = geoBounds2(base);
|
|
46485
|
+
if (bw >= nbW && be <= nbE && bs >= nbS && bn <= nbN)
|
|
46486
|
+
worldLayer.set(iso, cf);
|
|
46487
|
+
}
|
|
46488
|
+
}
|
|
46478
46489
|
const usLayer = wantsUsStates ? decodeLayer(data.usStates) : null;
|
|
46479
46490
|
const landTint = isDark ? LAND_TINT_DARK : LAND_TINT_LIGHT;
|
|
46480
46491
|
const neutralFill = mix(palette.colors.green, palette.bg, landTint);
|
|
@@ -46620,6 +46631,10 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46620
46631
|
return p ? stretch(p[0], p[1]) : null;
|
|
46621
46632
|
};
|
|
46622
46633
|
} else {
|
|
46634
|
+
projection.clipExtent([
|
|
46635
|
+
[0, 0],
|
|
46636
|
+
[width, height]
|
|
46637
|
+
]);
|
|
46623
46638
|
path = geoPath(projection);
|
|
46624
46639
|
project = (lon, lat) => projection([lon, lat]) ?? null;
|
|
46625
46640
|
}
|
|
@@ -46764,18 +46779,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46764
46779
|
placeInset("US-HI", hawaiiProjection(), akRight + 24, width * 0.1);
|
|
46765
46780
|
}
|
|
46766
46781
|
const conusFit = resolved.projection === "albers-usa" && !!usLayer;
|
|
46767
|
-
const
|
|
46768
|
-
const [[
|
|
46769
|
-
const
|
|
46770
|
-
const
|
|
46771
|
-
const
|
|
46772
|
-
const padLon = Math.max(8, lonSpan * 0.35);
|
|
46773
|
-
const padLat = Math.max(8, latSpan * 0.35);
|
|
46774
|
-
const vW = exW - padLon;
|
|
46775
|
-
const vE = exE + padLon;
|
|
46776
|
-
const vS = exS - padLat;
|
|
46777
|
-
const vN = exN + padLat;
|
|
46778
|
-
const vLonCenter = (exW + exE) / 2;
|
|
46782
|
+
const classifyExtent = conusFit ? geoBounds2(fitTarget) : resolved.extent;
|
|
46783
|
+
const dLonSpan = classifyExtent[1][0] - classifyExtent[0][0];
|
|
46784
|
+
const dLatSpan = classifyExtent[1][1] - classifyExtent[0][1];
|
|
46785
|
+
const isGlobalView = dLonSpan >= 270 || dLatSpan >= 130;
|
|
46786
|
+
const vLonCenter = (classifyExtent[0][0] + classifyExtent[1][0]) / 2;
|
|
46779
46787
|
const normLon = (lon) => {
|
|
46780
46788
|
let L = lon;
|
|
46781
46789
|
while (L < vLonCenter - 180) L += 360;
|
|
@@ -46783,23 +46791,28 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46783
46791
|
return L;
|
|
46784
46792
|
};
|
|
46785
46793
|
const ringOverlapsView = (ring) => {
|
|
46786
|
-
let
|
|
46787
|
-
|
|
46788
|
-
for (const [rawLon, lat] of ring) {
|
|
46794
|
+
let loMin = Infinity, loMax = -Infinity, rawMin = Infinity, rawMax = -Infinity;
|
|
46795
|
+
for (const [rawLon] of ring) {
|
|
46789
46796
|
const lon = normLon(rawLon);
|
|
46790
|
-
if (lon >= vW && lon <= vE && lat >= vS && lat <= vN) anyIn = true;
|
|
46791
46797
|
if (lon < loMin) loMin = lon;
|
|
46792
46798
|
if (lon > loMax) loMax = lon;
|
|
46793
46799
|
if (rawLon < rawMin) rawMin = rawLon;
|
|
46794
46800
|
if (rawLon > rawMax) rawMax = rawLon;
|
|
46795
|
-
if (lat < laMin) laMin = lat;
|
|
46796
|
-
if (lat > laMax) laMax = lat;
|
|
46797
46801
|
}
|
|
46798
46802
|
if (loMax - loMin > 270) return false;
|
|
46799
46803
|
if (rawMax - rawMin > 180 && loMax - loMin < 90) return false;
|
|
46800
|
-
|
|
46801
|
-
|
|
46802
|
-
|
|
46804
|
+
let px0 = Infinity, py0 = Infinity, px1 = -Infinity, py1 = -Infinity, anyFinite = false;
|
|
46805
|
+
for (const [lon, lat] of ring) {
|
|
46806
|
+
const p = project(lon, lat);
|
|
46807
|
+
if (!p || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) continue;
|
|
46808
|
+
anyFinite = true;
|
|
46809
|
+
if (p[0] < px0) px0 = p[0];
|
|
46810
|
+
if (p[0] > px1) px1 = p[0];
|
|
46811
|
+
if (p[1] < py0) py0 = p[1];
|
|
46812
|
+
if (p[1] > py1) py1 = p[1];
|
|
46813
|
+
}
|
|
46814
|
+
if (!anyFinite) return false;
|
|
46815
|
+
return !(px1 < 0 || px0 > width || py1 < 0 || py0 > height);
|
|
46803
46816
|
};
|
|
46804
46817
|
const cullFeatureToView = (f) => {
|
|
46805
46818
|
if (isGlobalView) return f;
|
|
@@ -46863,6 +46876,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46863
46876
|
if (layerKind === "us-state" && usContext && INSET_STATES.has(iso))
|
|
46864
46877
|
continue;
|
|
46865
46878
|
if (layerKind === "country" && usContext && iso === "US") continue;
|
|
46879
|
+
if (layerKind === "country" && iso === "AQ" && !regionById.has("AQ"))
|
|
46880
|
+
continue;
|
|
46866
46881
|
const r = regionById.get(iso);
|
|
46867
46882
|
const viewF = shouldCull ? cullFeatureToView(f) : dropFrameFillers(f);
|
|
46868
46883
|
if (!viewF) continue;
|
|
@@ -47190,19 +47205,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47190
47205
|
const text = labelText(p);
|
|
47191
47206
|
return { text, w: measureLegendText(text, FONT) };
|
|
47192
47207
|
};
|
|
47208
|
+
const GAP = 3;
|
|
47209
|
+
const inlineRect = (p, w, side) => {
|
|
47210
|
+
switch (side) {
|
|
47211
|
+
case "right":
|
|
47212
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
47213
|
+
case "left":
|
|
47214
|
+
return {
|
|
47215
|
+
x: p.cx - p.r - GAP - w,
|
|
47216
|
+
y: p.cy - poiLabH / 2,
|
|
47217
|
+
w,
|
|
47218
|
+
h: poiLabH
|
|
47219
|
+
};
|
|
47220
|
+
case "above":
|
|
47221
|
+
return {
|
|
47222
|
+
x: p.cx - w / 2,
|
|
47223
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
47224
|
+
w,
|
|
47225
|
+
h: poiLabH
|
|
47226
|
+
};
|
|
47227
|
+
case "below":
|
|
47228
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
47229
|
+
}
|
|
47230
|
+
};
|
|
47193
47231
|
const pushInline = (p, text, w, side) => {
|
|
47194
|
-
const
|
|
47195
|
-
obstacles.push(
|
|
47196
|
-
|
|
47197
|
-
|
|
47198
|
-
w,
|
|
47199
|
-
h: poiLabH
|
|
47200
|
-
});
|
|
47232
|
+
const rect = inlineRect(p, w, side);
|
|
47233
|
+
obstacles.push(rect);
|
|
47234
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
47235
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
47201
47236
|
labels.push({
|
|
47202
|
-
x
|
|
47203
|
-
y:
|
|
47237
|
+
x,
|
|
47238
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
47204
47239
|
text,
|
|
47205
|
-
anchor
|
|
47240
|
+
anchor,
|
|
47206
47241
|
color: palette.text,
|
|
47207
47242
|
halo: true,
|
|
47208
47243
|
haloColor: palette.bg,
|
|
@@ -47211,14 +47246,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47211
47246
|
});
|
|
47212
47247
|
};
|
|
47213
47248
|
const inlineFits = (p, w, side) => {
|
|
47214
|
-
const
|
|
47215
|
-
|
|
47216
|
-
x: side === "right" ? tx : tx - w,
|
|
47217
|
-
y: p.cy - poiLabH / 2,
|
|
47218
|
-
w,
|
|
47219
|
-
h: poiLabH
|
|
47220
|
-
};
|
|
47221
|
-
return rect.x >= 0 && rect.x + rect.w <= width && !collides(rect);
|
|
47249
|
+
const rect = inlineRect(p, w, side);
|
|
47250
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
47222
47251
|
};
|
|
47223
47252
|
const GROUP_R = 30;
|
|
47224
47253
|
const groups = [];
|
|
@@ -47275,12 +47304,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47275
47304
|
if (g.length === 1) {
|
|
47276
47305
|
const p = g[0];
|
|
47277
47306
|
const { text, w } = labelInfo(p);
|
|
47278
|
-
|
|
47279
|
-
|
|
47280
|
-
|
|
47281
|
-
|
|
47282
|
-
|
|
47283
|
-
pushInline(p, text, w, "left");
|
|
47307
|
+
const side = ["right", "left", "above", "below"].find(
|
|
47308
|
+
(s) => inlineFits(p, w, s)
|
|
47309
|
+
);
|
|
47310
|
+
if (side) {
|
|
47311
|
+
pushInline(p, text, w, side);
|
|
47284
47312
|
continue;
|
|
47285
47313
|
}
|
|
47286
47314
|
}
|
package/dist/auto.cjs
CHANGED
|
@@ -45835,7 +45835,7 @@ function resolveMap(parsed, data) {
|
|
|
45835
45835
|
const lonSpan = extent2[1][0] - extent2[0][0];
|
|
45836
45836
|
const latSpan = extent2[1][1] - extent2[0][1];
|
|
45837
45837
|
const span = Math.max(lonSpan, latSpan);
|
|
45838
|
-
const usDominant = (
|
|
45838
|
+
const usDominant = (subdivisions.includes("us-states") || regions.some((r) => r.layer === "us-state")) && !regions.some((r) => r.layer === "country" && r.iso !== "US") && !anyNonUsPoi;
|
|
45839
45839
|
let projection;
|
|
45840
45840
|
const override = parsed.directives.projection;
|
|
45841
45841
|
if (override === "equirectangular" || override === "natural-earth" || override === "albers-usa" || override === "mercator") {
|
|
@@ -46079,8 +46079,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46079
46079
|
const { width, height } = size;
|
|
46080
46080
|
const wantsUsStates = resolved.basemaps.subdivisions.includes("us-states");
|
|
46081
46081
|
const usCrisp = resolved.projection === "albers-usa" && wantsUsStates && !!data.naLand;
|
|
46082
|
-
const worldTopo = usCrisp ? data.
|
|
46082
|
+
const worldTopo = usCrisp ? data.worldDetail : resolved.basemaps.world === "detail" ? data.worldDetail : data.worldCoarse;
|
|
46083
46083
|
const worldLayer = decodeLayer(worldTopo);
|
|
46084
|
+
if (usCrisp && data.naLand) {
|
|
46085
|
+
const [nbW, nbS, nbE, nbN] = [-140, 10, -52, 66];
|
|
46086
|
+
const crisp = decodeLayer(data.naLand);
|
|
46087
|
+
for (const [iso, cf] of crisp) {
|
|
46088
|
+
const base = worldLayer.get(iso);
|
|
46089
|
+
if (!base) continue;
|
|
46090
|
+
const [[bw, bs], [be, bn]] = (0, import_d3_geo2.geoBounds)(base);
|
|
46091
|
+
if (bw >= nbW && be <= nbE && bs >= nbS && bn <= nbN)
|
|
46092
|
+
worldLayer.set(iso, cf);
|
|
46093
|
+
}
|
|
46094
|
+
}
|
|
46084
46095
|
const usLayer = wantsUsStates ? decodeLayer(data.usStates) : null;
|
|
46085
46096
|
const landTint = isDark ? LAND_TINT_DARK : LAND_TINT_LIGHT;
|
|
46086
46097
|
const neutralFill = mix(palette.colors.green, palette.bg, landTint);
|
|
@@ -46226,6 +46237,10 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46226
46237
|
return p ? stretch(p[0], p[1]) : null;
|
|
46227
46238
|
};
|
|
46228
46239
|
} else {
|
|
46240
|
+
projection.clipExtent([
|
|
46241
|
+
[0, 0],
|
|
46242
|
+
[width, height]
|
|
46243
|
+
]);
|
|
46229
46244
|
path = (0, import_d3_geo2.geoPath)(projection);
|
|
46230
46245
|
project = (lon, lat) => projection([lon, lat]) ?? null;
|
|
46231
46246
|
}
|
|
@@ -46370,18 +46385,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46370
46385
|
placeInset("US-HI", hawaiiProjection(), akRight + 24, width * 0.1);
|
|
46371
46386
|
}
|
|
46372
46387
|
const conusFit = resolved.projection === "albers-usa" && !!usLayer;
|
|
46373
|
-
const
|
|
46374
|
-
const [[
|
|
46375
|
-
const
|
|
46376
|
-
const
|
|
46377
|
-
const
|
|
46378
|
-
const padLon = Math.max(8, lonSpan * 0.35);
|
|
46379
|
-
const padLat = Math.max(8, latSpan * 0.35);
|
|
46380
|
-
const vW = exW - padLon;
|
|
46381
|
-
const vE = exE + padLon;
|
|
46382
|
-
const vS = exS - padLat;
|
|
46383
|
-
const vN = exN + padLat;
|
|
46384
|
-
const vLonCenter = (exW + exE) / 2;
|
|
46388
|
+
const classifyExtent = conusFit ? (0, import_d3_geo2.geoBounds)(fitTarget) : resolved.extent;
|
|
46389
|
+
const dLonSpan = classifyExtent[1][0] - classifyExtent[0][0];
|
|
46390
|
+
const dLatSpan = classifyExtent[1][1] - classifyExtent[0][1];
|
|
46391
|
+
const isGlobalView = dLonSpan >= 270 || dLatSpan >= 130;
|
|
46392
|
+
const vLonCenter = (classifyExtent[0][0] + classifyExtent[1][0]) / 2;
|
|
46385
46393
|
const normLon = (lon) => {
|
|
46386
46394
|
let L = lon;
|
|
46387
46395
|
while (L < vLonCenter - 180) L += 360;
|
|
@@ -46389,23 +46397,28 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46389
46397
|
return L;
|
|
46390
46398
|
};
|
|
46391
46399
|
const ringOverlapsView = (ring) => {
|
|
46392
|
-
let
|
|
46393
|
-
|
|
46394
|
-
for (const [rawLon, lat] of ring) {
|
|
46400
|
+
let loMin = Infinity, loMax = -Infinity, rawMin = Infinity, rawMax = -Infinity;
|
|
46401
|
+
for (const [rawLon] of ring) {
|
|
46395
46402
|
const lon = normLon(rawLon);
|
|
46396
|
-
if (lon >= vW && lon <= vE && lat >= vS && lat <= vN) anyIn = true;
|
|
46397
46403
|
if (lon < loMin) loMin = lon;
|
|
46398
46404
|
if (lon > loMax) loMax = lon;
|
|
46399
46405
|
if (rawLon < rawMin) rawMin = rawLon;
|
|
46400
46406
|
if (rawLon > rawMax) rawMax = rawLon;
|
|
46401
|
-
if (lat < laMin) laMin = lat;
|
|
46402
|
-
if (lat > laMax) laMax = lat;
|
|
46403
46407
|
}
|
|
46404
46408
|
if (loMax - loMin > 270) return false;
|
|
46405
46409
|
if (rawMax - rawMin > 180 && loMax - loMin < 90) return false;
|
|
46406
|
-
|
|
46407
|
-
|
|
46408
|
-
|
|
46410
|
+
let px0 = Infinity, py0 = Infinity, px1 = -Infinity, py1 = -Infinity, anyFinite = false;
|
|
46411
|
+
for (const [lon, lat] of ring) {
|
|
46412
|
+
const p = project(lon, lat);
|
|
46413
|
+
if (!p || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) continue;
|
|
46414
|
+
anyFinite = true;
|
|
46415
|
+
if (p[0] < px0) px0 = p[0];
|
|
46416
|
+
if (p[0] > px1) px1 = p[0];
|
|
46417
|
+
if (p[1] < py0) py0 = p[1];
|
|
46418
|
+
if (p[1] > py1) py1 = p[1];
|
|
46419
|
+
}
|
|
46420
|
+
if (!anyFinite) return false;
|
|
46421
|
+
return !(px1 < 0 || px0 > width || py1 < 0 || py0 > height);
|
|
46409
46422
|
};
|
|
46410
46423
|
const cullFeatureToView = (f) => {
|
|
46411
46424
|
if (isGlobalView) return f;
|
|
@@ -46469,6 +46482,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46469
46482
|
if (layerKind === "us-state" && usContext && INSET_STATES.has(iso))
|
|
46470
46483
|
continue;
|
|
46471
46484
|
if (layerKind === "country" && usContext && iso === "US") continue;
|
|
46485
|
+
if (layerKind === "country" && iso === "AQ" && !regionById.has("AQ"))
|
|
46486
|
+
continue;
|
|
46472
46487
|
const r = regionById.get(iso);
|
|
46473
46488
|
const viewF = shouldCull ? cullFeatureToView(f) : dropFrameFillers(f);
|
|
46474
46489
|
if (!viewF) continue;
|
|
@@ -46796,19 +46811,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46796
46811
|
const text = labelText(p);
|
|
46797
46812
|
return { text, w: measureLegendText(text, FONT) };
|
|
46798
46813
|
};
|
|
46814
|
+
const GAP = 3;
|
|
46815
|
+
const inlineRect = (p, w, side) => {
|
|
46816
|
+
switch (side) {
|
|
46817
|
+
case "right":
|
|
46818
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
46819
|
+
case "left":
|
|
46820
|
+
return {
|
|
46821
|
+
x: p.cx - p.r - GAP - w,
|
|
46822
|
+
y: p.cy - poiLabH / 2,
|
|
46823
|
+
w,
|
|
46824
|
+
h: poiLabH
|
|
46825
|
+
};
|
|
46826
|
+
case "above":
|
|
46827
|
+
return {
|
|
46828
|
+
x: p.cx - w / 2,
|
|
46829
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
46830
|
+
w,
|
|
46831
|
+
h: poiLabH
|
|
46832
|
+
};
|
|
46833
|
+
case "below":
|
|
46834
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
46835
|
+
}
|
|
46836
|
+
};
|
|
46799
46837
|
const pushInline = (p, text, w, side) => {
|
|
46800
|
-
const
|
|
46801
|
-
obstacles.push(
|
|
46802
|
-
|
|
46803
|
-
|
|
46804
|
-
w,
|
|
46805
|
-
h: poiLabH
|
|
46806
|
-
});
|
|
46838
|
+
const rect = inlineRect(p, w, side);
|
|
46839
|
+
obstacles.push(rect);
|
|
46840
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
46841
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
46807
46842
|
labels.push({
|
|
46808
|
-
x
|
|
46809
|
-
y:
|
|
46843
|
+
x,
|
|
46844
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
46810
46845
|
text,
|
|
46811
|
-
anchor
|
|
46846
|
+
anchor,
|
|
46812
46847
|
color: palette.text,
|
|
46813
46848
|
halo: true,
|
|
46814
46849
|
haloColor: palette.bg,
|
|
@@ -46817,14 +46852,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46817
46852
|
});
|
|
46818
46853
|
};
|
|
46819
46854
|
const inlineFits = (p, w, side) => {
|
|
46820
|
-
const
|
|
46821
|
-
|
|
46822
|
-
x: side === "right" ? tx : tx - w,
|
|
46823
|
-
y: p.cy - poiLabH / 2,
|
|
46824
|
-
w,
|
|
46825
|
-
h: poiLabH
|
|
46826
|
-
};
|
|
46827
|
-
return rect.x >= 0 && rect.x + rect.w <= width && !collides(rect);
|
|
46855
|
+
const rect = inlineRect(p, w, side);
|
|
46856
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
46828
46857
|
};
|
|
46829
46858
|
const GROUP_R = 30;
|
|
46830
46859
|
const groups = [];
|
|
@@ -46881,12 +46910,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46881
46910
|
if (g.length === 1) {
|
|
46882
46911
|
const p = g[0];
|
|
46883
46912
|
const { text, w } = labelInfo(p);
|
|
46884
|
-
|
|
46885
|
-
|
|
46886
|
-
|
|
46887
|
-
|
|
46888
|
-
|
|
46889
|
-
pushInline(p, text, w, "left");
|
|
46913
|
+
const side = ["right", "left", "above", "below"].find(
|
|
46914
|
+
(s) => inlineFits(p, w, s)
|
|
46915
|
+
);
|
|
46916
|
+
if (side) {
|
|
46917
|
+
pushInline(p, text, w, side);
|
|
46890
46918
|
continue;
|
|
46891
46919
|
}
|
|
46892
46920
|
}
|
|
@@ -57042,7 +57070,7 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
57042
57070
|
|
|
57043
57071
|
// src/auto/index.ts
|
|
57044
57072
|
init_safe_href();
|
|
57045
|
-
var VERSION = "0.20.
|
|
57073
|
+
var VERSION = "0.20.3";
|
|
57046
57074
|
var DEFAULTS = {
|
|
57047
57075
|
theme: "auto",
|
|
57048
57076
|
palette: "nord",
|