@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/index.cjs
CHANGED
|
@@ -45910,7 +45910,7 @@ function resolveMap(parsed, data) {
|
|
|
45910
45910
|
const lonSpan = extent2[1][0] - extent2[0][0];
|
|
45911
45911
|
const latSpan = extent2[1][1] - extent2[0][1];
|
|
45912
45912
|
const span = Math.max(lonSpan, latSpan);
|
|
45913
|
-
const usDominant = (
|
|
45913
|
+
const usDominant = (subdivisions.includes("us-states") || regions.some((r) => r.layer === "us-state")) && !regions.some((r) => r.layer === "country" && r.iso !== "US") && !anyNonUsPoi;
|
|
45914
45914
|
let projection;
|
|
45915
45915
|
const override = parsed.directives.projection;
|
|
45916
45916
|
if (override === "equirectangular" || override === "natural-earth" || override === "albers-usa" || override === "mercator") {
|
|
@@ -46154,8 +46154,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46154
46154
|
const { width, height } = size;
|
|
46155
46155
|
const wantsUsStates = resolved.basemaps.subdivisions.includes("us-states");
|
|
46156
46156
|
const usCrisp = resolved.projection === "albers-usa" && wantsUsStates && !!data.naLand;
|
|
46157
|
-
const worldTopo = usCrisp ? data.
|
|
46157
|
+
const worldTopo = usCrisp ? data.worldDetail : resolved.basemaps.world === "detail" ? data.worldDetail : data.worldCoarse;
|
|
46158
46158
|
const worldLayer = decodeLayer(worldTopo);
|
|
46159
|
+
if (usCrisp && data.naLand) {
|
|
46160
|
+
const [nbW, nbS, nbE, nbN] = [-140, 10, -52, 66];
|
|
46161
|
+
const crisp = decodeLayer(data.naLand);
|
|
46162
|
+
for (const [iso, cf] of crisp) {
|
|
46163
|
+
const base = worldLayer.get(iso);
|
|
46164
|
+
if (!base) continue;
|
|
46165
|
+
const [[bw, bs], [be, bn]] = (0, import_d3_geo2.geoBounds)(base);
|
|
46166
|
+
if (bw >= nbW && be <= nbE && bs >= nbS && bn <= nbN)
|
|
46167
|
+
worldLayer.set(iso, cf);
|
|
46168
|
+
}
|
|
46169
|
+
}
|
|
46159
46170
|
const usLayer = wantsUsStates ? decodeLayer(data.usStates) : null;
|
|
46160
46171
|
const landTint = isDark ? LAND_TINT_DARK : LAND_TINT_LIGHT;
|
|
46161
46172
|
const neutralFill = mix(palette.colors.green, palette.bg, landTint);
|
|
@@ -46301,6 +46312,10 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46301
46312
|
return p ? stretch(p[0], p[1]) : null;
|
|
46302
46313
|
};
|
|
46303
46314
|
} else {
|
|
46315
|
+
projection.clipExtent([
|
|
46316
|
+
[0, 0],
|
|
46317
|
+
[width, height]
|
|
46318
|
+
]);
|
|
46304
46319
|
path = (0, import_d3_geo2.geoPath)(projection);
|
|
46305
46320
|
project = (lon, lat) => projection([lon, lat]) ?? null;
|
|
46306
46321
|
}
|
|
@@ -46445,18 +46460,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46445
46460
|
placeInset("US-HI", hawaiiProjection(), akRight + 24, width * 0.1);
|
|
46446
46461
|
}
|
|
46447
46462
|
const conusFit = resolved.projection === "albers-usa" && !!usLayer;
|
|
46448
|
-
const
|
|
46449
|
-
const [[
|
|
46450
|
-
const
|
|
46451
|
-
const
|
|
46452
|
-
const
|
|
46453
|
-
const padLon = Math.max(8, lonSpan * 0.35);
|
|
46454
|
-
const padLat = Math.max(8, latSpan * 0.35);
|
|
46455
|
-
const vW = exW - padLon;
|
|
46456
|
-
const vE = exE + padLon;
|
|
46457
|
-
const vS = exS - padLat;
|
|
46458
|
-
const vN = exN + padLat;
|
|
46459
|
-
const vLonCenter = (exW + exE) / 2;
|
|
46463
|
+
const classifyExtent = conusFit ? (0, import_d3_geo2.geoBounds)(fitTarget) : resolved.extent;
|
|
46464
|
+
const dLonSpan = classifyExtent[1][0] - classifyExtent[0][0];
|
|
46465
|
+
const dLatSpan = classifyExtent[1][1] - classifyExtent[0][1];
|
|
46466
|
+
const isGlobalView = dLonSpan >= 270 || dLatSpan >= 130;
|
|
46467
|
+
const vLonCenter = (classifyExtent[0][0] + classifyExtent[1][0]) / 2;
|
|
46460
46468
|
const normLon = (lon) => {
|
|
46461
46469
|
let L = lon;
|
|
46462
46470
|
while (L < vLonCenter - 180) L += 360;
|
|
@@ -46464,23 +46472,28 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46464
46472
|
return L;
|
|
46465
46473
|
};
|
|
46466
46474
|
const ringOverlapsView = (ring) => {
|
|
46467
|
-
let
|
|
46468
|
-
|
|
46469
|
-
for (const [rawLon, lat] of ring) {
|
|
46475
|
+
let loMin = Infinity, loMax = -Infinity, rawMin = Infinity, rawMax = -Infinity;
|
|
46476
|
+
for (const [rawLon] of ring) {
|
|
46470
46477
|
const lon = normLon(rawLon);
|
|
46471
|
-
if (lon >= vW && lon <= vE && lat >= vS && lat <= vN) anyIn = true;
|
|
46472
46478
|
if (lon < loMin) loMin = lon;
|
|
46473
46479
|
if (lon > loMax) loMax = lon;
|
|
46474
46480
|
if (rawLon < rawMin) rawMin = rawLon;
|
|
46475
46481
|
if (rawLon > rawMax) rawMax = rawLon;
|
|
46476
|
-
if (lat < laMin) laMin = lat;
|
|
46477
|
-
if (lat > laMax) laMax = lat;
|
|
46478
46482
|
}
|
|
46479
46483
|
if (loMax - loMin > 270) return false;
|
|
46480
46484
|
if (rawMax - rawMin > 180 && loMax - loMin < 90) return false;
|
|
46481
|
-
|
|
46482
|
-
|
|
46483
|
-
|
|
46485
|
+
let px0 = Infinity, py0 = Infinity, px1 = -Infinity, py1 = -Infinity, anyFinite = false;
|
|
46486
|
+
for (const [lon, lat] of ring) {
|
|
46487
|
+
const p = project(lon, lat);
|
|
46488
|
+
if (!p || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) continue;
|
|
46489
|
+
anyFinite = true;
|
|
46490
|
+
if (p[0] < px0) px0 = p[0];
|
|
46491
|
+
if (p[0] > px1) px1 = p[0];
|
|
46492
|
+
if (p[1] < py0) py0 = p[1];
|
|
46493
|
+
if (p[1] > py1) py1 = p[1];
|
|
46494
|
+
}
|
|
46495
|
+
if (!anyFinite) return false;
|
|
46496
|
+
return !(px1 < 0 || px0 > width || py1 < 0 || py0 > height);
|
|
46484
46497
|
};
|
|
46485
46498
|
const cullFeatureToView = (f) => {
|
|
46486
46499
|
if (isGlobalView) return f;
|
|
@@ -46544,6 +46557,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46544
46557
|
if (layerKind === "us-state" && usContext && INSET_STATES.has(iso))
|
|
46545
46558
|
continue;
|
|
46546
46559
|
if (layerKind === "country" && usContext && iso === "US") continue;
|
|
46560
|
+
if (layerKind === "country" && iso === "AQ" && !regionById.has("AQ"))
|
|
46561
|
+
continue;
|
|
46547
46562
|
const r = regionById.get(iso);
|
|
46548
46563
|
const viewF = shouldCull ? cullFeatureToView(f) : dropFrameFillers(f);
|
|
46549
46564
|
if (!viewF) continue;
|
|
@@ -46871,19 +46886,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46871
46886
|
const text = labelText(p);
|
|
46872
46887
|
return { text, w: measureLegendText(text, FONT) };
|
|
46873
46888
|
};
|
|
46889
|
+
const GAP = 3;
|
|
46890
|
+
const inlineRect = (p, w, side) => {
|
|
46891
|
+
switch (side) {
|
|
46892
|
+
case "right":
|
|
46893
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
46894
|
+
case "left":
|
|
46895
|
+
return {
|
|
46896
|
+
x: p.cx - p.r - GAP - w,
|
|
46897
|
+
y: p.cy - poiLabH / 2,
|
|
46898
|
+
w,
|
|
46899
|
+
h: poiLabH
|
|
46900
|
+
};
|
|
46901
|
+
case "above":
|
|
46902
|
+
return {
|
|
46903
|
+
x: p.cx - w / 2,
|
|
46904
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
46905
|
+
w,
|
|
46906
|
+
h: poiLabH
|
|
46907
|
+
};
|
|
46908
|
+
case "below":
|
|
46909
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
46910
|
+
}
|
|
46911
|
+
};
|
|
46874
46912
|
const pushInline = (p, text, w, side) => {
|
|
46875
|
-
const
|
|
46876
|
-
obstacles.push(
|
|
46877
|
-
|
|
46878
|
-
|
|
46879
|
-
w,
|
|
46880
|
-
h: poiLabH
|
|
46881
|
-
});
|
|
46913
|
+
const rect = inlineRect(p, w, side);
|
|
46914
|
+
obstacles.push(rect);
|
|
46915
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
46916
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
46882
46917
|
labels.push({
|
|
46883
|
-
x
|
|
46884
|
-
y:
|
|
46918
|
+
x,
|
|
46919
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
46885
46920
|
text,
|
|
46886
|
-
anchor
|
|
46921
|
+
anchor,
|
|
46887
46922
|
color: palette.text,
|
|
46888
46923
|
halo: true,
|
|
46889
46924
|
haloColor: palette.bg,
|
|
@@ -46892,14 +46927,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46892
46927
|
});
|
|
46893
46928
|
};
|
|
46894
46929
|
const inlineFits = (p, w, side) => {
|
|
46895
|
-
const
|
|
46896
|
-
|
|
46897
|
-
x: side === "right" ? tx : tx - w,
|
|
46898
|
-
y: p.cy - poiLabH / 2,
|
|
46899
|
-
w,
|
|
46900
|
-
h: poiLabH
|
|
46901
|
-
};
|
|
46902
|
-
return rect.x >= 0 && rect.x + rect.w <= width && !collides(rect);
|
|
46930
|
+
const rect = inlineRect(p, w, side);
|
|
46931
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
46903
46932
|
};
|
|
46904
46933
|
const GROUP_R = 30;
|
|
46905
46934
|
const groups = [];
|
|
@@ -46956,12 +46985,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46956
46985
|
if (g.length === 1) {
|
|
46957
46986
|
const p = g[0];
|
|
46958
46987
|
const { text, w } = labelInfo(p);
|
|
46959
|
-
|
|
46960
|
-
|
|
46961
|
-
|
|
46962
|
-
|
|
46963
|
-
|
|
46964
|
-
pushInline(p, text, w, "left");
|
|
46988
|
+
const side = ["right", "left", "above", "below"].find(
|
|
46989
|
+
(s) => inlineFits(p, w, s)
|
|
46990
|
+
);
|
|
46991
|
+
if (side) {
|
|
46992
|
+
pushInline(p, text, w, side);
|
|
46965
46993
|
continue;
|
|
46966
46994
|
}
|
|
46967
46995
|
}
|
package/dist/index.js
CHANGED
|
@@ -45926,7 +45926,7 @@ function resolveMap(parsed, data) {
|
|
|
45926
45926
|
const lonSpan = extent2[1][0] - extent2[0][0];
|
|
45927
45927
|
const latSpan = extent2[1][1] - extent2[0][1];
|
|
45928
45928
|
const span = Math.max(lonSpan, latSpan);
|
|
45929
|
-
const usDominant = (
|
|
45929
|
+
const usDominant = (subdivisions.includes("us-states") || regions.some((r) => r.layer === "us-state")) && !regions.some((r) => r.layer === "country" && r.iso !== "US") && !anyNonUsPoi;
|
|
45930
45930
|
let projection;
|
|
45931
45931
|
const override = parsed.directives.projection;
|
|
45932
45932
|
if (override === "equirectangular" || override === "natural-earth" || override === "albers-usa" || override === "mercator") {
|
|
@@ -46179,8 +46179,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46179
46179
|
const { width, height } = size;
|
|
46180
46180
|
const wantsUsStates = resolved.basemaps.subdivisions.includes("us-states");
|
|
46181
46181
|
const usCrisp = resolved.projection === "albers-usa" && wantsUsStates && !!data.naLand;
|
|
46182
|
-
const worldTopo = usCrisp ? data.
|
|
46182
|
+
const worldTopo = usCrisp ? data.worldDetail : resolved.basemaps.world === "detail" ? data.worldDetail : data.worldCoarse;
|
|
46183
46183
|
const worldLayer = decodeLayer(worldTopo);
|
|
46184
|
+
if (usCrisp && data.naLand) {
|
|
46185
|
+
const [nbW, nbS, nbE, nbN] = [-140, 10, -52, 66];
|
|
46186
|
+
const crisp = decodeLayer(data.naLand);
|
|
46187
|
+
for (const [iso, cf] of crisp) {
|
|
46188
|
+
const base = worldLayer.get(iso);
|
|
46189
|
+
if (!base) continue;
|
|
46190
|
+
const [[bw, bs], [be, bn]] = geoBounds2(base);
|
|
46191
|
+
if (bw >= nbW && be <= nbE && bs >= nbS && bn <= nbN)
|
|
46192
|
+
worldLayer.set(iso, cf);
|
|
46193
|
+
}
|
|
46194
|
+
}
|
|
46184
46195
|
const usLayer = wantsUsStates ? decodeLayer(data.usStates) : null;
|
|
46185
46196
|
const landTint = isDark ? LAND_TINT_DARK : LAND_TINT_LIGHT;
|
|
46186
46197
|
const neutralFill = mix(palette.colors.green, palette.bg, landTint);
|
|
@@ -46326,6 +46337,10 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46326
46337
|
return p ? stretch(p[0], p[1]) : null;
|
|
46327
46338
|
};
|
|
46328
46339
|
} else {
|
|
46340
|
+
projection.clipExtent([
|
|
46341
|
+
[0, 0],
|
|
46342
|
+
[width, height]
|
|
46343
|
+
]);
|
|
46329
46344
|
path = geoPath(projection);
|
|
46330
46345
|
project = (lon, lat) => projection([lon, lat]) ?? null;
|
|
46331
46346
|
}
|
|
@@ -46470,18 +46485,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46470
46485
|
placeInset("US-HI", hawaiiProjection(), akRight + 24, width * 0.1);
|
|
46471
46486
|
}
|
|
46472
46487
|
const conusFit = resolved.projection === "albers-usa" && !!usLayer;
|
|
46473
|
-
const
|
|
46474
|
-
const [[
|
|
46475
|
-
const
|
|
46476
|
-
const
|
|
46477
|
-
const
|
|
46478
|
-
const padLon = Math.max(8, lonSpan * 0.35);
|
|
46479
|
-
const padLat = Math.max(8, latSpan * 0.35);
|
|
46480
|
-
const vW = exW - padLon;
|
|
46481
|
-
const vE = exE + padLon;
|
|
46482
|
-
const vS = exS - padLat;
|
|
46483
|
-
const vN = exN + padLat;
|
|
46484
|
-
const vLonCenter = (exW + exE) / 2;
|
|
46488
|
+
const classifyExtent = conusFit ? geoBounds2(fitTarget) : resolved.extent;
|
|
46489
|
+
const dLonSpan = classifyExtent[1][0] - classifyExtent[0][0];
|
|
46490
|
+
const dLatSpan = classifyExtent[1][1] - classifyExtent[0][1];
|
|
46491
|
+
const isGlobalView = dLonSpan >= 270 || dLatSpan >= 130;
|
|
46492
|
+
const vLonCenter = (classifyExtent[0][0] + classifyExtent[1][0]) / 2;
|
|
46485
46493
|
const normLon = (lon) => {
|
|
46486
46494
|
let L = lon;
|
|
46487
46495
|
while (L < vLonCenter - 180) L += 360;
|
|
@@ -46489,23 +46497,28 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46489
46497
|
return L;
|
|
46490
46498
|
};
|
|
46491
46499
|
const ringOverlapsView = (ring) => {
|
|
46492
|
-
let
|
|
46493
|
-
|
|
46494
|
-
for (const [rawLon, lat] of ring) {
|
|
46500
|
+
let loMin = Infinity, loMax = -Infinity, rawMin = Infinity, rawMax = -Infinity;
|
|
46501
|
+
for (const [rawLon] of ring) {
|
|
46495
46502
|
const lon = normLon(rawLon);
|
|
46496
|
-
if (lon >= vW && lon <= vE && lat >= vS && lat <= vN) anyIn = true;
|
|
46497
46503
|
if (lon < loMin) loMin = lon;
|
|
46498
46504
|
if (lon > loMax) loMax = lon;
|
|
46499
46505
|
if (rawLon < rawMin) rawMin = rawLon;
|
|
46500
46506
|
if (rawLon > rawMax) rawMax = rawLon;
|
|
46501
|
-
if (lat < laMin) laMin = lat;
|
|
46502
|
-
if (lat > laMax) laMax = lat;
|
|
46503
46507
|
}
|
|
46504
46508
|
if (loMax - loMin > 270) return false;
|
|
46505
46509
|
if (rawMax - rawMin > 180 && loMax - loMin < 90) return false;
|
|
46506
|
-
|
|
46507
|
-
|
|
46508
|
-
|
|
46510
|
+
let px0 = Infinity, py0 = Infinity, px1 = -Infinity, py1 = -Infinity, anyFinite = false;
|
|
46511
|
+
for (const [lon, lat] of ring) {
|
|
46512
|
+
const p = project(lon, lat);
|
|
46513
|
+
if (!p || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) continue;
|
|
46514
|
+
anyFinite = true;
|
|
46515
|
+
if (p[0] < px0) px0 = p[0];
|
|
46516
|
+
if (p[0] > px1) px1 = p[0];
|
|
46517
|
+
if (p[1] < py0) py0 = p[1];
|
|
46518
|
+
if (p[1] > py1) py1 = p[1];
|
|
46519
|
+
}
|
|
46520
|
+
if (!anyFinite) return false;
|
|
46521
|
+
return !(px1 < 0 || px0 > width || py1 < 0 || py0 > height);
|
|
46509
46522
|
};
|
|
46510
46523
|
const cullFeatureToView = (f) => {
|
|
46511
46524
|
if (isGlobalView) return f;
|
|
@@ -46569,6 +46582,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46569
46582
|
if (layerKind === "us-state" && usContext && INSET_STATES.has(iso))
|
|
46570
46583
|
continue;
|
|
46571
46584
|
if (layerKind === "country" && usContext && iso === "US") continue;
|
|
46585
|
+
if (layerKind === "country" && iso === "AQ" && !regionById.has("AQ"))
|
|
46586
|
+
continue;
|
|
46572
46587
|
const r = regionById.get(iso);
|
|
46573
46588
|
const viewF = shouldCull ? cullFeatureToView(f) : dropFrameFillers(f);
|
|
46574
46589
|
if (!viewF) continue;
|
|
@@ -46896,19 +46911,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46896
46911
|
const text = labelText(p);
|
|
46897
46912
|
return { text, w: measureLegendText(text, FONT) };
|
|
46898
46913
|
};
|
|
46914
|
+
const GAP = 3;
|
|
46915
|
+
const inlineRect = (p, w, side) => {
|
|
46916
|
+
switch (side) {
|
|
46917
|
+
case "right":
|
|
46918
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
46919
|
+
case "left":
|
|
46920
|
+
return {
|
|
46921
|
+
x: p.cx - p.r - GAP - w,
|
|
46922
|
+
y: p.cy - poiLabH / 2,
|
|
46923
|
+
w,
|
|
46924
|
+
h: poiLabH
|
|
46925
|
+
};
|
|
46926
|
+
case "above":
|
|
46927
|
+
return {
|
|
46928
|
+
x: p.cx - w / 2,
|
|
46929
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
46930
|
+
w,
|
|
46931
|
+
h: poiLabH
|
|
46932
|
+
};
|
|
46933
|
+
case "below":
|
|
46934
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
46935
|
+
}
|
|
46936
|
+
};
|
|
46899
46937
|
const pushInline = (p, text, w, side) => {
|
|
46900
|
-
const
|
|
46901
|
-
obstacles.push(
|
|
46902
|
-
|
|
46903
|
-
|
|
46904
|
-
w,
|
|
46905
|
-
h: poiLabH
|
|
46906
|
-
});
|
|
46938
|
+
const rect = inlineRect(p, w, side);
|
|
46939
|
+
obstacles.push(rect);
|
|
46940
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
46941
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
46907
46942
|
labels.push({
|
|
46908
|
-
x
|
|
46909
|
-
y:
|
|
46943
|
+
x,
|
|
46944
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
46910
46945
|
text,
|
|
46911
|
-
anchor
|
|
46946
|
+
anchor,
|
|
46912
46947
|
color: palette.text,
|
|
46913
46948
|
halo: true,
|
|
46914
46949
|
haloColor: palette.bg,
|
|
@@ -46917,14 +46952,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46917
46952
|
});
|
|
46918
46953
|
};
|
|
46919
46954
|
const inlineFits = (p, w, side) => {
|
|
46920
|
-
const
|
|
46921
|
-
|
|
46922
|
-
x: side === "right" ? tx : tx - w,
|
|
46923
|
-
y: p.cy - poiLabH / 2,
|
|
46924
|
-
w,
|
|
46925
|
-
h: poiLabH
|
|
46926
|
-
};
|
|
46927
|
-
return rect.x >= 0 && rect.x + rect.w <= width && !collides(rect);
|
|
46955
|
+
const rect = inlineRect(p, w, side);
|
|
46956
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
46928
46957
|
};
|
|
46929
46958
|
const GROUP_R = 30;
|
|
46930
46959
|
const groups = [];
|
|
@@ -46981,12 +47010,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46981
47010
|
if (g.length === 1) {
|
|
46982
47011
|
const p = g[0];
|
|
46983
47012
|
const { text, w } = labelInfo(p);
|
|
46984
|
-
|
|
46985
|
-
|
|
46986
|
-
|
|
46987
|
-
|
|
46988
|
-
|
|
46989
|
-
pushInline(p, text, w, "left");
|
|
47013
|
+
const side = ["right", "left", "above", "below"].find(
|
|
47014
|
+
(s) => inlineFits(p, w, s)
|
|
47015
|
+
);
|
|
47016
|
+
if (side) {
|
|
47017
|
+
pushInline(p, text, w, side);
|
|
46990
47018
|
continue;
|
|
46991
47019
|
}
|
|
46992
47020
|
}
|
package/dist/internal.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
|
}
|