@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/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;
|
|
@@ -47165,19 +47178,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47165
47178
|
const text = labelText(p);
|
|
47166
47179
|
return { text, w: measureLegendText(text, FONT) };
|
|
47167
47180
|
};
|
|
47181
|
+
const GAP = 3;
|
|
47182
|
+
const inlineRect = (p, w, side) => {
|
|
47183
|
+
switch (side) {
|
|
47184
|
+
case "right":
|
|
47185
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
47186
|
+
case "left":
|
|
47187
|
+
return {
|
|
47188
|
+
x: p.cx - p.r - GAP - w,
|
|
47189
|
+
y: p.cy - poiLabH / 2,
|
|
47190
|
+
w,
|
|
47191
|
+
h: poiLabH
|
|
47192
|
+
};
|
|
47193
|
+
case "above":
|
|
47194
|
+
return {
|
|
47195
|
+
x: p.cx - w / 2,
|
|
47196
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
47197
|
+
w,
|
|
47198
|
+
h: poiLabH
|
|
47199
|
+
};
|
|
47200
|
+
case "below":
|
|
47201
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
47202
|
+
}
|
|
47203
|
+
};
|
|
47168
47204
|
const pushInline = (p, text, w, side) => {
|
|
47169
|
-
const
|
|
47170
|
-
obstacles.push(
|
|
47171
|
-
|
|
47172
|
-
|
|
47173
|
-
w,
|
|
47174
|
-
h: poiLabH
|
|
47175
|
-
});
|
|
47205
|
+
const rect = inlineRect(p, w, side);
|
|
47206
|
+
obstacles.push(rect);
|
|
47207
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
47208
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
47176
47209
|
labels.push({
|
|
47177
|
-
x
|
|
47178
|
-
y:
|
|
47210
|
+
x,
|
|
47211
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
47179
47212
|
text,
|
|
47180
|
-
anchor
|
|
47213
|
+
anchor,
|
|
47181
47214
|
color: palette.text,
|
|
47182
47215
|
halo: true,
|
|
47183
47216
|
haloColor: palette.bg,
|
|
@@ -47186,14 +47219,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47186
47219
|
});
|
|
47187
47220
|
};
|
|
47188
47221
|
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);
|
|
47222
|
+
const rect = inlineRect(p, w, side);
|
|
47223
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
47197
47224
|
};
|
|
47198
47225
|
const GROUP_R = 30;
|
|
47199
47226
|
const groups = [];
|
|
@@ -47250,12 +47277,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47250
47277
|
if (g.length === 1) {
|
|
47251
47278
|
const p = g[0];
|
|
47252
47279
|
const { text, w } = labelInfo(p);
|
|
47253
|
-
|
|
47254
|
-
|
|
47255
|
-
|
|
47256
|
-
|
|
47257
|
-
|
|
47258
|
-
pushInline(p, text, w, "left");
|
|
47280
|
+
const side = ["right", "left", "above", "below"].find(
|
|
47281
|
+
(s) => inlineFits(p, w, s)
|
|
47282
|
+
);
|
|
47283
|
+
if (side) {
|
|
47284
|
+
pushInline(p, text, w, side);
|
|
47259
47285
|
continue;
|
|
47260
47286
|
}
|
|
47261
47287
|
}
|
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;
|
|
@@ -47190,19 +47203,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47190
47203
|
const text = labelText(p);
|
|
47191
47204
|
return { text, w: measureLegendText(text, FONT) };
|
|
47192
47205
|
};
|
|
47206
|
+
const GAP = 3;
|
|
47207
|
+
const inlineRect = (p, w, side) => {
|
|
47208
|
+
switch (side) {
|
|
47209
|
+
case "right":
|
|
47210
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
47211
|
+
case "left":
|
|
47212
|
+
return {
|
|
47213
|
+
x: p.cx - p.r - GAP - w,
|
|
47214
|
+
y: p.cy - poiLabH / 2,
|
|
47215
|
+
w,
|
|
47216
|
+
h: poiLabH
|
|
47217
|
+
};
|
|
47218
|
+
case "above":
|
|
47219
|
+
return {
|
|
47220
|
+
x: p.cx - w / 2,
|
|
47221
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
47222
|
+
w,
|
|
47223
|
+
h: poiLabH
|
|
47224
|
+
};
|
|
47225
|
+
case "below":
|
|
47226
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
47227
|
+
}
|
|
47228
|
+
};
|
|
47193
47229
|
const pushInline = (p, text, w, side) => {
|
|
47194
|
-
const
|
|
47195
|
-
obstacles.push(
|
|
47196
|
-
|
|
47197
|
-
|
|
47198
|
-
w,
|
|
47199
|
-
h: poiLabH
|
|
47200
|
-
});
|
|
47230
|
+
const rect = inlineRect(p, w, side);
|
|
47231
|
+
obstacles.push(rect);
|
|
47232
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
47233
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
47201
47234
|
labels.push({
|
|
47202
|
-
x
|
|
47203
|
-
y:
|
|
47235
|
+
x,
|
|
47236
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
47204
47237
|
text,
|
|
47205
|
-
anchor
|
|
47238
|
+
anchor,
|
|
47206
47239
|
color: palette.text,
|
|
47207
47240
|
halo: true,
|
|
47208
47241
|
haloColor: palette.bg,
|
|
@@ -47211,14 +47244,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47211
47244
|
});
|
|
47212
47245
|
};
|
|
47213
47246
|
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);
|
|
47247
|
+
const rect = inlineRect(p, w, side);
|
|
47248
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
47222
47249
|
};
|
|
47223
47250
|
const GROUP_R = 30;
|
|
47224
47251
|
const groups = [];
|
|
@@ -47275,12 +47302,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47275
47302
|
if (g.length === 1) {
|
|
47276
47303
|
const p = g[0];
|
|
47277
47304
|
const { text, w } = labelInfo(p);
|
|
47278
|
-
|
|
47279
|
-
|
|
47280
|
-
|
|
47281
|
-
|
|
47282
|
-
|
|
47283
|
-
pushInline(p, text, w, "left");
|
|
47305
|
+
const side = ["right", "left", "above", "below"].find(
|
|
47306
|
+
(s) => inlineFits(p, w, s)
|
|
47307
|
+
);
|
|
47308
|
+
if (side) {
|
|
47309
|
+
pushInline(p, text, w, side);
|
|
47284
47310
|
continue;
|
|
47285
47311
|
}
|
|
47286
47312
|
}
|
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;
|
|
@@ -46796,19 +46809,39 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46796
46809
|
const text = labelText(p);
|
|
46797
46810
|
return { text, w: measureLegendText(text, FONT) };
|
|
46798
46811
|
};
|
|
46812
|
+
const GAP = 3;
|
|
46813
|
+
const inlineRect = (p, w, side) => {
|
|
46814
|
+
switch (side) {
|
|
46815
|
+
case "right":
|
|
46816
|
+
return { x: p.cx + p.r + GAP, y: p.cy - poiLabH / 2, w, h: poiLabH };
|
|
46817
|
+
case "left":
|
|
46818
|
+
return {
|
|
46819
|
+
x: p.cx - p.r - GAP - w,
|
|
46820
|
+
y: p.cy - poiLabH / 2,
|
|
46821
|
+
w,
|
|
46822
|
+
h: poiLabH
|
|
46823
|
+
};
|
|
46824
|
+
case "above":
|
|
46825
|
+
return {
|
|
46826
|
+
x: p.cx - w / 2,
|
|
46827
|
+
y: p.cy - p.r - GAP - poiLabH,
|
|
46828
|
+
w,
|
|
46829
|
+
h: poiLabH
|
|
46830
|
+
};
|
|
46831
|
+
case "below":
|
|
46832
|
+
return { x: p.cx - w / 2, y: p.cy + p.r + GAP, w, h: poiLabH };
|
|
46833
|
+
}
|
|
46834
|
+
};
|
|
46799
46835
|
const pushInline = (p, text, w, side) => {
|
|
46800
|
-
const
|
|
46801
|
-
obstacles.push(
|
|
46802
|
-
|
|
46803
|
-
|
|
46804
|
-
w,
|
|
46805
|
-
h: poiLabH
|
|
46806
|
-
});
|
|
46836
|
+
const rect = inlineRect(p, w, side);
|
|
46837
|
+
obstacles.push(rect);
|
|
46838
|
+
const anchor = side === "right" ? "start" : side === "left" ? "end" : "middle";
|
|
46839
|
+
const x = side === "right" ? rect.x : side === "left" ? rect.x + w : p.cx;
|
|
46807
46840
|
labels.push({
|
|
46808
|
-
x
|
|
46809
|
-
y:
|
|
46841
|
+
x,
|
|
46842
|
+
y: rect.y + poiLabH / 2 + FONT / 3,
|
|
46810
46843
|
text,
|
|
46811
|
-
anchor
|
|
46844
|
+
anchor,
|
|
46812
46845
|
color: palette.text,
|
|
46813
46846
|
halo: true,
|
|
46814
46847
|
haloColor: palette.bg,
|
|
@@ -46817,14 +46850,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46817
46850
|
});
|
|
46818
46851
|
};
|
|
46819
46852
|
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);
|
|
46853
|
+
const rect = inlineRect(p, w, side);
|
|
46854
|
+
return rect.x >= 0 && rect.x + rect.w <= width && rect.y >= 0 && rect.y + rect.h <= height && !collides(rect);
|
|
46828
46855
|
};
|
|
46829
46856
|
const GROUP_R = 30;
|
|
46830
46857
|
const groups = [];
|
|
@@ -46881,12 +46908,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46881
46908
|
if (g.length === 1) {
|
|
46882
46909
|
const p = g[0];
|
|
46883
46910
|
const { text, w } = labelInfo(p);
|
|
46884
|
-
|
|
46885
|
-
|
|
46886
|
-
|
|
46887
|
-
|
|
46888
|
-
|
|
46889
|
-
pushInline(p, text, w, "left");
|
|
46911
|
+
const side = ["right", "left", "above", "below"].find(
|
|
46912
|
+
(s) => inlineFits(p, w, s)
|
|
46913
|
+
);
|
|
46914
|
+
if (side) {
|
|
46915
|
+
pushInline(p, text, w, side);
|
|
46890
46916
|
continue;
|
|
46891
46917
|
}
|
|
46892
46918
|
}
|
|
@@ -57042,7 +57068,7 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
57042
57068
|
|
|
57043
57069
|
// src/auto/index.ts
|
|
57044
57070
|
init_safe_href();
|
|
57045
|
-
var VERSION = "0.20.
|
|
57071
|
+
var VERSION = "0.20.2";
|
|
57046
57072
|
var DEFAULTS = {
|
|
57047
57073
|
theme: "auto",
|
|
57048
57074
|
palette: "nord",
|