@diagrammo/dgmo 0.20.3 → 0.21.0
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 +329 -109
- package/dist/advanced.d.cts +66 -25
- package/dist/advanced.d.ts +66 -25
- package/dist/advanced.js +329 -109
- package/dist/auto.cjs +332 -107
- package/dist/auto.js +109 -109
- package/dist/auto.mjs +332 -107
- package/dist/cli.cjs +151 -151
- package/dist/editor.cjs +5 -2
- package/dist/editor.js +5 -2
- package/dist/highlight.cjs +5 -2
- package/dist/highlight.js +5 -2
- package/dist/index.cjs +326 -104
- package/dist/index.js +326 -104
- package/dist/internal.cjs +329 -109
- package/dist/internal.d.cts +66 -25
- package/dist/internal.d.ts +66 -25
- package/dist/internal.js +329 -109
- package/gallery/fixtures/map-choropleth.dgmo +7 -7
- package/gallery/fixtures/map-pois.dgmo +4 -4
- package/gallery/fixtures/map-region-scope.dgmo +8 -8
- package/gallery/fixtures/map-route.dgmo +5 -6
- package/package.json +1 -1
- package/src/completion.ts +9 -4
- package/src/editor/keywords.ts +5 -2
- package/src/map/layout.ts +141 -67
- package/src/map/parser.ts +122 -33
- package/src/map/renderer.ts +13 -6
- package/src/map/resolved-types.ts +13 -2
- package/src/map/resolver.ts +179 -34
- package/src/map/types.ts +39 -14
- package/src/utils/reserved-key-registry.ts +7 -7
package/dist/internal.js
CHANGED
|
@@ -855,13 +855,9 @@ var init_reserved_key_registry = __esm({
|
|
|
855
855
|
"icon"
|
|
856
856
|
]);
|
|
857
857
|
MAP_REGISTRY = staticRegistry([
|
|
858
|
-
"
|
|
858
|
+
"value",
|
|
859
859
|
"label",
|
|
860
|
-
"
|
|
861
|
-
"description",
|
|
862
|
-
"weight",
|
|
863
|
-
"style",
|
|
864
|
-
"date"
|
|
860
|
+
"style"
|
|
865
861
|
]);
|
|
866
862
|
ORG_REGISTRY = staticRegistry([
|
|
867
863
|
"color",
|
|
@@ -15844,7 +15840,8 @@ function parseMap(content) {
|
|
|
15844
15840
|
continue;
|
|
15845
15841
|
}
|
|
15846
15842
|
if (open.route && indent > open.route.indent) {
|
|
15847
|
-
open.route.route.
|
|
15843
|
+
const leg = parseLeg(trimmed, lineNumber, open.route.route.style);
|
|
15844
|
+
open.route.route.legs.push(leg);
|
|
15848
15845
|
continue;
|
|
15849
15846
|
}
|
|
15850
15847
|
if (open.poi && indent > open.poi.indent) {
|
|
@@ -15875,6 +15872,10 @@ function parseMap(content) {
|
|
|
15875
15872
|
handleTag(trimmed, lineNumber);
|
|
15876
15873
|
continue;
|
|
15877
15874
|
}
|
|
15875
|
+
if ((firstWord === "muted" || firstWord === "natural") && trimmed === firstWord) {
|
|
15876
|
+
handleDirective(firstWord, "", lineNumber);
|
|
15877
|
+
continue;
|
|
15878
|
+
}
|
|
15878
15879
|
if (DIRECTIVE_SET.has(firstWord) && !trimmed.slice(firstWord.length).trimStart().startsWith(":")) {
|
|
15879
15880
|
handleDirective(
|
|
15880
15881
|
firstWord,
|
|
@@ -15939,13 +15940,17 @@ function parseMap(content) {
|
|
|
15939
15940
|
);
|
|
15940
15941
|
d.projection = value;
|
|
15941
15942
|
break;
|
|
15942
|
-
case "metric":
|
|
15943
|
-
dup(d.
|
|
15944
|
-
d.
|
|
15943
|
+
case "region-metric":
|
|
15944
|
+
dup(d.regionMetric);
|
|
15945
|
+
d.regionMetric = value;
|
|
15946
|
+
break;
|
|
15947
|
+
case "poi-metric":
|
|
15948
|
+
dup(d.poiMetric);
|
|
15949
|
+
d.poiMetric = value;
|
|
15945
15950
|
break;
|
|
15946
|
-
case "
|
|
15947
|
-
dup(d.
|
|
15948
|
-
d.
|
|
15951
|
+
case "flow-metric":
|
|
15952
|
+
dup(d.flowMetric);
|
|
15953
|
+
d.flowMetric = value;
|
|
15949
15954
|
break;
|
|
15950
15955
|
case "scale":
|
|
15951
15956
|
dup(d.scale);
|
|
@@ -15987,6 +15992,15 @@ function parseMap(content) {
|
|
|
15987
15992
|
case "no-legend":
|
|
15988
15993
|
d.noLegend = true;
|
|
15989
15994
|
break;
|
|
15995
|
+
case "muted":
|
|
15996
|
+
case "natural":
|
|
15997
|
+
if (d.basemapStyle !== void 0 && d.basemapStyle !== key)
|
|
15998
|
+
pushWarning(
|
|
15999
|
+
line12,
|
|
16000
|
+
`Conflicting basemap dress \u2014 "${d.basemapStyle}" then "${key}"; last wins.`
|
|
16001
|
+
);
|
|
16002
|
+
d.basemapStyle = key;
|
|
16003
|
+
break;
|
|
15990
16004
|
case "subtitle":
|
|
15991
16005
|
dup(d.subtitle);
|
|
15992
16006
|
d.subtitle = value;
|
|
@@ -16064,14 +16078,14 @@ function parseMap(content) {
|
|
|
16064
16078
|
line12
|
|
16065
16079
|
);
|
|
16066
16080
|
const { tags, meta } = partitionMeta(split.meta, tagGroupNames());
|
|
16067
|
-
let
|
|
16068
|
-
const
|
|
16069
|
-
if (
|
|
16070
|
-
delete meta["
|
|
16071
|
-
|
|
16072
|
-
if (!Number.isFinite(
|
|
16073
|
-
pushError(line12, `
|
|
16074
|
-
|
|
16081
|
+
let valueNum;
|
|
16082
|
+
const value = meta["value"];
|
|
16083
|
+
if (value !== void 0) {
|
|
16084
|
+
delete meta["value"];
|
|
16085
|
+
valueNum = Number(value);
|
|
16086
|
+
if (!Number.isFinite(valueNum)) {
|
|
16087
|
+
pushError(line12, `value must be a number (got "${value}").`);
|
|
16088
|
+
valueNum = void 0;
|
|
16075
16089
|
}
|
|
16076
16090
|
}
|
|
16077
16091
|
let regionName = split.name;
|
|
@@ -16089,7 +16103,7 @@ function parseMap(content) {
|
|
|
16089
16103
|
lineNumber: line12
|
|
16090
16104
|
};
|
|
16091
16105
|
if (regionScope !== void 0) region.scope = regionScope;
|
|
16092
|
-
if (
|
|
16106
|
+
if (valueNum !== void 0) region.value = valueNum;
|
|
16093
16107
|
regions.push(region);
|
|
16094
16108
|
}
|
|
16095
16109
|
function handlePoi(rest, line12, indent) {
|
|
@@ -16118,24 +16132,76 @@ function parseMap(content) {
|
|
|
16118
16132
|
open.poi = { poi, indent };
|
|
16119
16133
|
}
|
|
16120
16134
|
function handleRoute(rest, line12, indent) {
|
|
16121
|
-
const
|
|
16122
|
-
|
|
16135
|
+
const split = rest ? splitNameAndMeta(
|
|
16136
|
+
rest,
|
|
16137
|
+
registry(),
|
|
16138
|
+
aliasMap,
|
|
16139
|
+
void 0,
|
|
16140
|
+
diagnostics,
|
|
16141
|
+
line12
|
|
16142
|
+
) : { name: "", meta: {}, alias: void 0 };
|
|
16143
|
+
const pos = parsePos(split.name, line12);
|
|
16144
|
+
if (!pos || pos.kind === "name" && !pos.name) {
|
|
16145
|
+
pushError(
|
|
16146
|
+
line12,
|
|
16147
|
+
"route requires an origin: `route <origin> [style: arc]`."
|
|
16148
|
+
);
|
|
16149
|
+
return;
|
|
16150
|
+
}
|
|
16151
|
+
const { tags, meta } = partitionMeta(split.meta, tagGroupNames());
|
|
16152
|
+
const originLabel = meta["label"];
|
|
16153
|
+
const originValue = meta["value"];
|
|
16154
|
+
const style = meta["style"] === "arc" ? "arc" : "straight";
|
|
16155
|
+
const route = {
|
|
16156
|
+
origin: pos,
|
|
16157
|
+
...split.alias !== void 0 && { originAlias: split.alias },
|
|
16158
|
+
...originLabel !== void 0 && { originLabel },
|
|
16159
|
+
...originValue !== void 0 && { originValue },
|
|
16160
|
+
originTags: tags,
|
|
16161
|
+
style,
|
|
16162
|
+
legs: [],
|
|
16163
|
+
lineNumber: line12
|
|
16164
|
+
};
|
|
16123
16165
|
routes.push(route);
|
|
16124
16166
|
open.route = { route, indent };
|
|
16125
16167
|
}
|
|
16126
|
-
function
|
|
16127
|
-
|
|
16128
|
-
|
|
16168
|
+
function parseLeg(trimmed, line12, headerStyle) {
|
|
16169
|
+
let arrowStyle = "straight";
|
|
16170
|
+
let label;
|
|
16171
|
+
let rest = trimmed;
|
|
16172
|
+
const m = trimmed.match(LEG_ARROW_RE);
|
|
16173
|
+
if (m) {
|
|
16174
|
+
const arr = classifyArrow(m[1], line12);
|
|
16175
|
+
arrowStyle = arr.style;
|
|
16176
|
+
label = arr.label;
|
|
16177
|
+
rest = m[2];
|
|
16178
|
+
}
|
|
16179
|
+
const split = splitNameAndMeta(
|
|
16180
|
+
rest,
|
|
16181
|
+
registry(),
|
|
16182
|
+
aliasMap,
|
|
16183
|
+
void 0,
|
|
16184
|
+
diagnostics,
|
|
16185
|
+
line12
|
|
16186
|
+
);
|
|
16187
|
+
const pos = parsePos(split.name, line12) ?? {
|
|
16129
16188
|
kind: "name",
|
|
16130
16189
|
name: split.name
|
|
16131
16190
|
};
|
|
16132
|
-
const
|
|
16133
|
-
|
|
16134
|
-
|
|
16191
|
+
const { tags, meta } = partitionMeta(split.meta, tagGroupNames());
|
|
16192
|
+
const value = meta["value"];
|
|
16193
|
+
const destLabel = meta["label"];
|
|
16194
|
+
const style = arrowStyle === "arc" || headerStyle === "arc" ? "arc" : "straight";
|
|
16195
|
+
return {
|
|
16196
|
+
...label !== void 0 && { label },
|
|
16197
|
+
style,
|
|
16198
|
+
...value !== void 0 && { value },
|
|
16199
|
+
dest: pos,
|
|
16200
|
+
...split.alias !== void 0 && { destAlias: split.alias },
|
|
16201
|
+
...destLabel !== void 0 && { destLabel },
|
|
16202
|
+
destTags: tags,
|
|
16135
16203
|
lineNumber: line12
|
|
16136
16204
|
};
|
|
16137
|
-
if (split.alias) stop.alias = split.alias;
|
|
16138
|
-
return stop;
|
|
16139
16205
|
}
|
|
16140
16206
|
function handleEdges(trimmed, line12) {
|
|
16141
16207
|
const parts = trimmed.split(ARROW_SPLIT);
|
|
@@ -16237,7 +16303,7 @@ function partitionMeta(meta, tagGroupNames) {
|
|
|
16237
16303
|
function poiName(pos) {
|
|
16238
16304
|
return pos.kind === "name" ? pos.name : void 0;
|
|
16239
16305
|
}
|
|
16240
|
-
var COORD_RE, NUMERIC_LEAD_RE, SCOPE_RE, ARROW_SPLIT, HUB_RE, AT_RE, DIRECTIVE_SET;
|
|
16306
|
+
var COORD_RE, NUMERIC_LEAD_RE, SCOPE_RE, ARROW_SPLIT, HUB_RE, LEG_ARROW_RE, AT_RE, DIRECTIVE_SET;
|
|
16241
16307
|
var init_parser12 = __esm({
|
|
16242
16308
|
"src/map/parser.ts"() {
|
|
16243
16309
|
"use strict";
|
|
@@ -16251,12 +16317,14 @@ var init_parser12 = __esm({
|
|
|
16251
16317
|
SCOPE_RE = /^[A-Z]{2}(?:-[A-Z0-9]{1,3})?$/;
|
|
16252
16318
|
ARROW_SPLIT = /\s+(-[^>]*?->|->|~[^>]*?~>|~>|--)\s+/;
|
|
16253
16319
|
HUB_RE = /^(->|~>)\s+(.+)$/;
|
|
16320
|
+
LEG_ARROW_RE = /^(-[^>]*?->|->|~[^>]*?~>|~>|--)\s+(.+)$/;
|
|
16254
16321
|
AT_RE = /(^|[\s,])at\s*:/i;
|
|
16255
16322
|
DIRECTIVE_SET = /* @__PURE__ */ new Set([
|
|
16256
16323
|
"region",
|
|
16257
16324
|
"projection",
|
|
16258
|
-
"metric",
|
|
16259
|
-
"
|
|
16325
|
+
"region-metric",
|
|
16326
|
+
"poi-metric",
|
|
16327
|
+
"flow-metric",
|
|
16260
16328
|
"scale",
|
|
16261
16329
|
"region-labels",
|
|
16262
16330
|
"poi-labels",
|
|
@@ -45854,6 +45922,11 @@ var resolver_exports = {};
|
|
|
45854
45922
|
__export(resolver_exports, {
|
|
45855
45923
|
resolveMap: () => resolveMap
|
|
45856
45924
|
});
|
|
45925
|
+
function usStateFromBareScope(scope) {
|
|
45926
|
+
if (!scope) return null;
|
|
45927
|
+
const up = scope.toUpperCase();
|
|
45928
|
+
return US_STATE_POSTAL.has(up) ? `US-${up}` : null;
|
|
45929
|
+
}
|
|
45857
45930
|
function looksUS(lat, lon) {
|
|
45858
45931
|
if (lat < 15 || lat > 72) return false;
|
|
45859
45932
|
return lon >= -180 && lon <= -64 || lon >= 172;
|
|
@@ -45903,9 +45976,9 @@ function resolveMap(parsed, data) {
|
|
|
45903
45976
|
const f = fold(r.name);
|
|
45904
45977
|
return usStateIndex.has(f) && !countryIndex.has(f);
|
|
45905
45978
|
}) || parsed.regions.some(
|
|
45906
|
-
(r) => r.scope === "US" || r.scope?.startsWith("US-")
|
|
45979
|
+
(r) => r.scope === "US" || r.scope?.startsWith("US-") || usStateFromBareScope(r.scope) !== null
|
|
45907
45980
|
) || parsed.pois.some(
|
|
45908
|
-
(p) => p.pos.kind === "name" && p.pos.scope?.startsWith("US-")
|
|
45981
|
+
(p) => p.pos.kind === "name" && (p.pos.scope?.startsWith("US-") || usStateFromBareScope(p.pos.scope) !== null)
|
|
45909
45982
|
);
|
|
45910
45983
|
const regions = [];
|
|
45911
45984
|
const seenRegion = /* @__PURE__ */ new Map();
|
|
@@ -45972,7 +46045,7 @@ function resolveMap(parsed, data) {
|
|
|
45972
46045
|
iso: chosen.id,
|
|
45973
46046
|
name: chosen.name,
|
|
45974
46047
|
layer: chosen.layer,
|
|
45975
|
-
...r.
|
|
46048
|
+
...r.value !== void 0 && { value: r.value },
|
|
45976
46049
|
tags: r.tags,
|
|
45977
46050
|
meta: r.meta,
|
|
45978
46051
|
lineNumber: r.lineNumber
|
|
@@ -46030,9 +46103,10 @@ function resolveMap(parsed, data) {
|
|
|
46030
46103
|
let cands = idxs.map((i) => data.gazetteer.cities[i]);
|
|
46031
46104
|
const scopeUse = scope ?? scopeHint;
|
|
46032
46105
|
if (scopeUse) {
|
|
46033
|
-
const
|
|
46106
|
+
const bareState = usStateFromBareScope(scopeUse);
|
|
46107
|
+
const subScope = /^[A-Za-z]{2}-/.test(scopeUse) ? scopeUse : bareState;
|
|
46034
46108
|
const filtered = cands.filter(
|
|
46035
|
-
(c2) =>
|
|
46109
|
+
(c2) => subScope ? c2[5] === subScope : c2[2] === scopeUse
|
|
46036
46110
|
);
|
|
46037
46111
|
if (filtered.length) cands = filtered;
|
|
46038
46112
|
else if (scope) {
|
|
@@ -46161,33 +46235,89 @@ function resolveMap(parsed, data) {
|
|
|
46161
46235
|
lineNumber: e.lineNumber
|
|
46162
46236
|
});
|
|
46163
46237
|
}
|
|
46164
|
-
const
|
|
46165
|
-
|
|
46166
|
-
|
|
46167
|
-
|
|
46168
|
-
|
|
46169
|
-
if (
|
|
46170
|
-
|
|
46171
|
-
|
|
46172
|
-
|
|
46173
|
-
const poi = {
|
|
46238
|
+
const resolveStop = (pos, alias, label, tags, sizeValue, line12) => {
|
|
46239
|
+
const meta = sizeValue !== void 0 ? { value: sizeValue } : {};
|
|
46240
|
+
if (pos.kind === "coords") {
|
|
46241
|
+
const id = alias ? fold(alias) : `@${pos.lat},${pos.lon}`;
|
|
46242
|
+
if (!looksUS(pos.lat, pos.lon)) anyNonUsPoi = true;
|
|
46243
|
+
if (!registry.has(id)) {
|
|
46244
|
+
registerPoi(
|
|
46245
|
+
id,
|
|
46246
|
+
{
|
|
46174
46247
|
id,
|
|
46175
|
-
...
|
|
46176
|
-
lat:
|
|
46177
|
-
lon:
|
|
46178
|
-
|
|
46179
|
-
|
|
46180
|
-
|
|
46181
|
-
|
|
46182
|
-
}
|
|
46183
|
-
|
|
46184
|
-
|
|
46185
|
-
} else {
|
|
46186
|
-
id = stop.alias && registry.has(fold(stop.alias)) ? fold(stop.alias) : resolveEndpoint2(stop.ref.name, stop.lineNumber);
|
|
46248
|
+
...alias !== void 0 && { name: alias },
|
|
46249
|
+
lat: pos.lat,
|
|
46250
|
+
lon: pos.lon,
|
|
46251
|
+
...label !== void 0 && { label },
|
|
46252
|
+
tags,
|
|
46253
|
+
meta,
|
|
46254
|
+
lineNumber: line12
|
|
46255
|
+
},
|
|
46256
|
+
line12
|
|
46257
|
+
);
|
|
46187
46258
|
}
|
|
46188
|
-
|
|
46259
|
+
return id;
|
|
46260
|
+
}
|
|
46261
|
+
const f = fold(pos.name);
|
|
46262
|
+
if (registry.has(f)) return f;
|
|
46263
|
+
const aliased = declaredByName.get(f);
|
|
46264
|
+
if (aliased) return aliased;
|
|
46265
|
+
const got = lookupName(pos.name, pos.scope, line12, inferredCountry, true);
|
|
46266
|
+
if (got.kind !== "ok") return null;
|
|
46267
|
+
noteCountry(got.iso);
|
|
46268
|
+
registerPoi(
|
|
46269
|
+
f,
|
|
46270
|
+
{
|
|
46271
|
+
id: f,
|
|
46272
|
+
name: pos.name,
|
|
46273
|
+
lat: got.lat,
|
|
46274
|
+
lon: got.lon,
|
|
46275
|
+
...label !== void 0 && { label },
|
|
46276
|
+
tags,
|
|
46277
|
+
meta,
|
|
46278
|
+
lineNumber: line12
|
|
46279
|
+
},
|
|
46280
|
+
line12
|
|
46281
|
+
);
|
|
46282
|
+
return f;
|
|
46283
|
+
};
|
|
46284
|
+
const routes = [];
|
|
46285
|
+
for (const rt of parsed.routes) {
|
|
46286
|
+
const originId = resolveStop(
|
|
46287
|
+
rt.origin,
|
|
46288
|
+
rt.originAlias,
|
|
46289
|
+
rt.originLabel,
|
|
46290
|
+
rt.originTags,
|
|
46291
|
+
rt.originValue,
|
|
46292
|
+
rt.lineNumber
|
|
46293
|
+
);
|
|
46294
|
+
if (!originId) continue;
|
|
46295
|
+
const stopIds = [originId];
|
|
46296
|
+
const legs = [];
|
|
46297
|
+
let prevId = originId;
|
|
46298
|
+
for (const leg of rt.legs) {
|
|
46299
|
+
const destId = resolveStop(
|
|
46300
|
+
leg.dest,
|
|
46301
|
+
leg.destAlias,
|
|
46302
|
+
leg.destLabel,
|
|
46303
|
+
leg.destTags,
|
|
46304
|
+
void 0,
|
|
46305
|
+
// a leg's `value:` is leg thickness, not the dest's size
|
|
46306
|
+
leg.lineNumber
|
|
46307
|
+
);
|
|
46308
|
+
if (!destId) continue;
|
|
46309
|
+
legs.push({
|
|
46310
|
+
fromId: prevId,
|
|
46311
|
+
toId: destId,
|
|
46312
|
+
...leg.label !== void 0 && { label: leg.label },
|
|
46313
|
+
style: leg.style,
|
|
46314
|
+
...leg.value !== void 0 && { value: leg.value },
|
|
46315
|
+
lineNumber: leg.lineNumber
|
|
46316
|
+
});
|
|
46317
|
+
if (!stopIds.includes(destId)) stopIds.push(destId);
|
|
46318
|
+
prevId = destId;
|
|
46189
46319
|
}
|
|
46190
|
-
routes.push({ stopIds,
|
|
46320
|
+
routes.push({ stopIds, legs, lineNumber: rt.lineNumber });
|
|
46191
46321
|
}
|
|
46192
46322
|
const subdivisions = [];
|
|
46193
46323
|
if (usSubdivisionReferenced || parsed.directives.region === "us-states")
|
|
@@ -46279,7 +46409,7 @@ function firstError(diags) {
|
|
|
46279
46409
|
const e = diags.find((d) => d.severity === "error");
|
|
46280
46410
|
return e ? formatDgmoError(e) : null;
|
|
46281
46411
|
}
|
|
46282
|
-
var WORLD_SPAN, MERCATOR_MAX_SPAN, PAD_FRACTION, WORLD_LAT_SOUTH, WORLD_LAT_NORTH, REGION_ALIASES;
|
|
46412
|
+
var WORLD_SPAN, MERCATOR_MAX_SPAN, PAD_FRACTION, WORLD_LAT_SOUTH, WORLD_LAT_NORTH, REGION_ALIASES, US_STATE_POSTAL;
|
|
46283
46413
|
var init_resolver2 = __esm({
|
|
46284
46414
|
"src/map/resolver.ts"() {
|
|
46285
46415
|
"use strict";
|
|
@@ -46311,6 +46441,59 @@ var init_resolver2 = __esm({
|
|
|
46311
46441
|
"north macedonia": "macedonia",
|
|
46312
46442
|
"czech republic": "czechia"
|
|
46313
46443
|
};
|
|
46444
|
+
US_STATE_POSTAL = /* @__PURE__ */ new Set([
|
|
46445
|
+
"AL",
|
|
46446
|
+
"AK",
|
|
46447
|
+
"AZ",
|
|
46448
|
+
"AR",
|
|
46449
|
+
"CA",
|
|
46450
|
+
"CO",
|
|
46451
|
+
"CT",
|
|
46452
|
+
"DE",
|
|
46453
|
+
"FL",
|
|
46454
|
+
"GA",
|
|
46455
|
+
"HI",
|
|
46456
|
+
"ID",
|
|
46457
|
+
"IL",
|
|
46458
|
+
"IN",
|
|
46459
|
+
"IA",
|
|
46460
|
+
"KS",
|
|
46461
|
+
"KY",
|
|
46462
|
+
"LA",
|
|
46463
|
+
"ME",
|
|
46464
|
+
"MD",
|
|
46465
|
+
"MA",
|
|
46466
|
+
"MI",
|
|
46467
|
+
"MN",
|
|
46468
|
+
"MS",
|
|
46469
|
+
"MO",
|
|
46470
|
+
"MT",
|
|
46471
|
+
"NE",
|
|
46472
|
+
"NV",
|
|
46473
|
+
"NH",
|
|
46474
|
+
"NJ",
|
|
46475
|
+
"NM",
|
|
46476
|
+
"NY",
|
|
46477
|
+
"NC",
|
|
46478
|
+
"ND",
|
|
46479
|
+
"OH",
|
|
46480
|
+
"OK",
|
|
46481
|
+
"OR",
|
|
46482
|
+
"PA",
|
|
46483
|
+
"RI",
|
|
46484
|
+
"SC",
|
|
46485
|
+
"SD",
|
|
46486
|
+
"TN",
|
|
46487
|
+
"TX",
|
|
46488
|
+
"UT",
|
|
46489
|
+
"VT",
|
|
46490
|
+
"VA",
|
|
46491
|
+
"WA",
|
|
46492
|
+
"WV",
|
|
46493
|
+
"WI",
|
|
46494
|
+
"WY",
|
|
46495
|
+
"DC"
|
|
46496
|
+
]);
|
|
46314
46497
|
}
|
|
46315
46498
|
});
|
|
46316
46499
|
|
|
@@ -46458,10 +46641,18 @@ function projectionFor(family) {
|
|
|
46458
46641
|
return geoEquirectangular();
|
|
46459
46642
|
}
|
|
46460
46643
|
}
|
|
46461
|
-
function mapBackgroundColor(palette) {
|
|
46644
|
+
function mapBackgroundColor(palette, isDark = false, dataActive = false) {
|
|
46645
|
+
if (dataActive)
|
|
46646
|
+
return mix(
|
|
46647
|
+
palette.colors.gray,
|
|
46648
|
+
palette.bg,
|
|
46649
|
+
isDark ? MUTED_WATER_DARK : MUTED_WATER_LIGHT
|
|
46650
|
+
);
|
|
46462
46651
|
return mix(palette.colors.blue, palette.bg, WATER_TINT);
|
|
46463
46652
|
}
|
|
46464
|
-
function mapNeutralLandColor(palette, isDark) {
|
|
46653
|
+
function mapNeutralLandColor(palette, isDark, dataActive = false) {
|
|
46654
|
+
if (dataActive)
|
|
46655
|
+
return isDark ? mix(palette.colors.gray, palette.bg, MUTED_LAND_DARK) : palette.bg;
|
|
46465
46656
|
return mix(
|
|
46466
46657
|
palette.colors.green,
|
|
46467
46658
|
palette.bg,
|
|
@@ -46487,28 +46678,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46487
46678
|
}
|
|
46488
46679
|
}
|
|
46489
46680
|
const usLayer = wantsUsStates ? decodeLayer(data.usStates) : null;
|
|
46490
|
-
const landTint = isDark ? LAND_TINT_DARK : LAND_TINT_LIGHT;
|
|
46491
|
-
const neutralFill = mix(palette.colors.green, palette.bg, landTint);
|
|
46492
|
-
const water = mapBackgroundColor(palette);
|
|
46493
46681
|
const usContext = usLayer !== null;
|
|
46494
|
-
const foreignFill = mix(
|
|
46495
|
-
palette.colors.gray,
|
|
46496
|
-
palette.bg,
|
|
46497
|
-
isDark ? FOREIGN_TINT_DARK : FOREIGN_TINT_LIGHT
|
|
46498
|
-
);
|
|
46499
46682
|
const regionStroke = isDark ? mix(palette.bg, palette.text, 78) : mix(palette.text, palette.bg, 78);
|
|
46500
|
-
const
|
|
46683
|
+
const values = resolved.regions.filter((r) => r.value !== void 0).map((r) => r.value);
|
|
46501
46684
|
const scaleOverride = resolved.directives.scale;
|
|
46502
|
-
const rampMin = scaleOverride ? scaleOverride.min : Math.min(...
|
|
46503
|
-
const rampMax = scaleOverride ? scaleOverride.max : Math.max(...
|
|
46685
|
+
const rampMin = scaleOverride ? scaleOverride.min : Math.min(...values);
|
|
46686
|
+
const rampMax = scaleOverride ? scaleOverride.max : Math.max(...values);
|
|
46504
46687
|
const rampHue = palette.colors.red;
|
|
46505
|
-
const hasRamp =
|
|
46506
|
-
const
|
|
46688
|
+
const hasRamp = values.length > 0;
|
|
46689
|
+
const VALUE_NAME = hasRamp ? resolved.directives.regionMetric?.trim() || "Value" : null;
|
|
46507
46690
|
const matchColorGroup = (v) => {
|
|
46508
46691
|
const lv = v.trim().toLowerCase();
|
|
46509
46692
|
if (lv === "none") return null;
|
|
46510
|
-
if (
|
|
46511
|
-
return SCORE_NAME;
|
|
46693
|
+
if (lv === VALUE_NAME?.toLowerCase()) return VALUE_NAME;
|
|
46512
46694
|
const tg = resolved.tagGroups.find((g) => g.name.toLowerCase() === lv);
|
|
46513
46695
|
return tg ? tg.name : v;
|
|
46514
46696
|
};
|
|
@@ -46519,11 +46701,19 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46519
46701
|
} else if (resolved.directives.activeTag !== void 0) {
|
|
46520
46702
|
activeGroup = matchColorGroup(resolved.directives.activeTag);
|
|
46521
46703
|
} else {
|
|
46522
|
-
activeGroup =
|
|
46704
|
+
activeGroup = VALUE_NAME ?? (resolved.tagGroups.length > 0 ? resolved.tagGroups[0].name : null);
|
|
46523
46705
|
}
|
|
46524
|
-
const activeIsScore =
|
|
46706
|
+
const activeIsScore = VALUE_NAME !== null && activeGroup === VALUE_NAME;
|
|
46707
|
+
const mutedBasemap = resolved.directives.basemapStyle === "muted" ? true : resolved.directives.basemapStyle === "natural" ? false : activeGroup !== null;
|
|
46708
|
+
const neutralFill = mapNeutralLandColor(palette, isDark, mutedBasemap);
|
|
46709
|
+
const water = mapBackgroundColor(palette, isDark, mutedBasemap);
|
|
46710
|
+
const foreignFill = mix(
|
|
46711
|
+
palette.colors.gray,
|
|
46712
|
+
palette.bg,
|
|
46713
|
+
mutedBasemap ? isDark ? MUTED_FOREIGN_DARK : MUTED_FOREIGN_LIGHT : isDark ? FOREIGN_TINT_DARK : FOREIGN_TINT_LIGHT
|
|
46714
|
+
);
|
|
46525
46715
|
const rampBase = isDark ? mix(palette.surface, palette.text, 28) : palette.bg;
|
|
46526
|
-
const
|
|
46716
|
+
const fillForValue = (s) => {
|
|
46527
46717
|
const t = rampMax > rampMin ? (s - rampMin) / (rampMax - rampMin) : 1;
|
|
46528
46718
|
const pct = RAMP_FLOOR + Math.max(0, Math.min(1, t)) * (100 - RAMP_FLOOR);
|
|
46529
46719
|
return mix(rampHue, rampBase, pct);
|
|
@@ -46548,7 +46738,7 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46548
46738
|
};
|
|
46549
46739
|
const regionFill = (r) => {
|
|
46550
46740
|
if (activeIsScore) {
|
|
46551
|
-
return r.
|
|
46741
|
+
return r.value !== void 0 ? fillForValue(r.value) : neutralFill;
|
|
46552
46742
|
}
|
|
46553
46743
|
return tagFill(r.tags, activeGroup) ?? neutralFill;
|
|
46554
46744
|
};
|
|
@@ -46760,7 +46950,7 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46760
46950
|
stroke: regionStroke,
|
|
46761
46951
|
lineNumber,
|
|
46762
46952
|
layer: "us-state",
|
|
46763
|
-
...r?.
|
|
46953
|
+
...r?.value !== void 0 && { value: r.value },
|
|
46764
46954
|
...r && Object.keys(r.tags).length > 0 && { tags: r.tags }
|
|
46765
46955
|
});
|
|
46766
46956
|
const ctr = geoPath(proj).centroid(f);
|
|
@@ -46903,7 +47093,7 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46903
47093
|
lineNumber,
|
|
46904
47094
|
layer,
|
|
46905
47095
|
...label !== void 0 && { label },
|
|
46906
|
-
...isThisLayer && r.
|
|
47096
|
+
...isThisLayer && r.value !== void 0 && { value: r.value },
|
|
46907
47097
|
...isThisLayer && Object.keys(r.tags).length > 0 && { tags: r.tags }
|
|
46908
47098
|
});
|
|
46909
47099
|
}
|
|
@@ -46938,11 +47128,11 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
46938
47128
|
rivers.push({ d, color: riverColor, width: RIVER_WIDTH });
|
|
46939
47129
|
}
|
|
46940
47130
|
}
|
|
46941
|
-
const sizeVals = resolved.pois.map((p) => Number(p.meta["
|
|
47131
|
+
const sizeVals = resolved.pois.map((p) => Number(p.meta["value"])).filter((n) => Number.isFinite(n) && n > 0);
|
|
46942
47132
|
const sizeMin = sizeVals.length ? Math.min(...sizeVals) : 0;
|
|
46943
47133
|
const sizeMax = sizeVals.length ? Math.max(...sizeVals) : 0;
|
|
46944
47134
|
const radiusFor = (p) => {
|
|
46945
|
-
const v = Number(p.meta["
|
|
47135
|
+
const v = Number(p.meta["value"]);
|
|
46946
47136
|
if (!Number.isFinite(v) || v <= 0 || sizeMax <= 0) return R_DEFAULT;
|
|
46947
47137
|
const t = sizeMax > sizeMin ? (Math.sqrt(v) - Math.sqrt(sizeMin)) / (Math.sqrt(sizeMax) - Math.sqrt(sizeMin)) : 1;
|
|
46948
47138
|
return R_MIN + Math.max(0, Math.min(1, t)) * (R_MAX - R_MIN);
|
|
@@ -47009,7 +47199,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47009
47199
|
lineNumber: e.p.lineNumber,
|
|
47010
47200
|
implicit: !!e.p.implicit,
|
|
47011
47201
|
isOrigin: originIds.has(e.p.id),
|
|
47012
|
-
...num !== void 0 && { routeNumber: num }
|
|
47202
|
+
...num !== void 0 && { routeNumber: num },
|
|
47203
|
+
...Object.keys(e.p.tags).length > 0 && { tags: e.p.tags }
|
|
47013
47204
|
});
|
|
47014
47205
|
});
|
|
47015
47206
|
}
|
|
@@ -47045,26 +47236,40 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47045
47236
|
const by = b.cy - (b.cy - py) / tb * trimB;
|
|
47046
47237
|
return `M${ax},${ay}Q${px},${py} ${bx},${by}`;
|
|
47047
47238
|
};
|
|
47239
|
+
const routeLegVals = resolved.routes.flatMap((rt) => rt.legs).map((l) => Number(l.value)).filter((n) => Number.isFinite(n) && n > 0);
|
|
47240
|
+
const rlMin = routeLegVals.length ? Math.min(...routeLegVals) : 0;
|
|
47241
|
+
const rlMax = routeLegVals.length ? Math.max(...routeLegVals) : 0;
|
|
47242
|
+
const routeWidthFor = (v) => {
|
|
47243
|
+
if (!Number.isFinite(v) || v <= 0 || rlMax <= 0) return W_MIN;
|
|
47244
|
+
const t = rlMax > rlMin ? (v - rlMin) / (rlMax - rlMin) : 1;
|
|
47245
|
+
return W_MIN + t * (W_MAX - W_MIN);
|
|
47246
|
+
};
|
|
47048
47247
|
for (const rt of resolved.routes) {
|
|
47049
|
-
const
|
|
47050
|
-
|
|
47051
|
-
const
|
|
47052
|
-
const b = poiScreen.get(rt.stopIds[i]);
|
|
47248
|
+
for (const leg of rt.legs) {
|
|
47249
|
+
const a = poiScreen.get(leg.fromId);
|
|
47250
|
+
const b = poiScreen.get(leg.toId);
|
|
47053
47251
|
if (!a || !b) continue;
|
|
47252
|
+
const mx = (a.cx + b.cx) / 2;
|
|
47253
|
+
const my = (a.cy + b.cy) / 2;
|
|
47054
47254
|
legs.push({
|
|
47055
|
-
d: legPath(a, b,
|
|
47056
|
-
width:
|
|
47255
|
+
d: legPath(a, b, leg.style === "arc", 0),
|
|
47256
|
+
width: routeWidthFor(Number(leg.value)),
|
|
47057
47257
|
color: mix(palette.text, palette.bg, 72),
|
|
47058
47258
|
arrow: true,
|
|
47059
|
-
lineNumber:
|
|
47259
|
+
lineNumber: leg.lineNumber,
|
|
47260
|
+
...leg.label !== void 0 && {
|
|
47261
|
+
label: leg.label,
|
|
47262
|
+
labelX: mx,
|
|
47263
|
+
labelY: my - 4
|
|
47264
|
+
}
|
|
47060
47265
|
});
|
|
47061
47266
|
}
|
|
47062
47267
|
}
|
|
47063
|
-
const weightVals = resolved.edges.map((e) => Number(e.meta["
|
|
47268
|
+
const weightVals = resolved.edges.map((e) => Number(e.meta["value"])).filter((n) => Number.isFinite(n) && n > 0);
|
|
47064
47269
|
const wMin = weightVals.length ? Math.min(...weightVals) : 0;
|
|
47065
47270
|
const wMax = weightVals.length ? Math.max(...weightVals) : 0;
|
|
47066
47271
|
const widthFor = (e) => {
|
|
47067
|
-
const v = Number(e.meta["
|
|
47272
|
+
const v = Number(e.meta["value"]);
|
|
47068
47273
|
if (!Number.isFinite(v) || v <= 0 || wMax <= 0) return W_MIN;
|
|
47069
47274
|
const t = wMax > wMin ? (v - wMin) / (wMax - wMin) : 1;
|
|
47070
47275
|
return W_MIN + t * (W_MAX - W_MIN);
|
|
@@ -47327,8 +47532,8 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47327
47532
|
activeGroup,
|
|
47328
47533
|
...hasRamp && {
|
|
47329
47534
|
ramp: {
|
|
47330
|
-
...resolved.directives.
|
|
47331
|
-
metric: resolved.directives.
|
|
47535
|
+
...resolved.directives.regionMetric !== void 0 && {
|
|
47536
|
+
metric: resolved.directives.regionMetric
|
|
47332
47537
|
},
|
|
47333
47538
|
min: rampMin,
|
|
47334
47539
|
max: rampMax,
|
|
@@ -47356,7 +47561,7 @@ function layoutMap(resolved, data, size, opts) {
|
|
|
47356
47561
|
insetRegions
|
|
47357
47562
|
};
|
|
47358
47563
|
}
|
|
47359
|
-
var FIT_PAD, RAMP_FLOOR, R_DEFAULT, R_MIN, R_MAX, W_MIN, W_MAX, FONT, COLO_EPS, LAND_TINT_LIGHT, LAND_TINT_DARK, TAG_TINT_LIGHT, TAG_TINT_DARK, WATER_TINT, RIVER_WIDTH, FOREIGN_TINT_LIGHT, FOREIGN_TINT_DARK, COLO_R, GOLDEN_ANGLE, FAN_STEP, ARC_CURVE_FRAC, usConusProjection, alaskaProjection, hawaiiProjection, INSET_STATES, US_NON_CONUS;
|
|
47564
|
+
var FIT_PAD, RAMP_FLOOR, R_DEFAULT, R_MIN, R_MAX, W_MIN, W_MAX, FONT, COLO_EPS, LAND_TINT_LIGHT, LAND_TINT_DARK, TAG_TINT_LIGHT, TAG_TINT_DARK, WATER_TINT, RIVER_WIDTH, FOREIGN_TINT_LIGHT, FOREIGN_TINT_DARK, MUTED_WATER_LIGHT, MUTED_WATER_DARK, MUTED_FOREIGN_LIGHT, MUTED_FOREIGN_DARK, MUTED_LAND_DARK, COLO_R, GOLDEN_ANGLE, FAN_STEP, ARC_CURVE_FRAC, usConusProjection, alaskaProjection, hawaiiProjection, INSET_STATES, US_NON_CONUS;
|
|
47360
47565
|
var init_layout15 = __esm({
|
|
47361
47566
|
"src/map/layout.ts"() {
|
|
47362
47567
|
"use strict";
|
|
@@ -47381,6 +47586,11 @@ var init_layout15 = __esm({
|
|
|
47381
47586
|
RIVER_WIDTH = 1.3;
|
|
47382
47587
|
FOREIGN_TINT_LIGHT = 30;
|
|
47383
47588
|
FOREIGN_TINT_DARK = 62;
|
|
47589
|
+
MUTED_WATER_LIGHT = 14;
|
|
47590
|
+
MUTED_WATER_DARK = 10;
|
|
47591
|
+
MUTED_FOREIGN_LIGHT = 28;
|
|
47592
|
+
MUTED_FOREIGN_DARK = 16;
|
|
47593
|
+
MUTED_LAND_DARK = 24;
|
|
47384
47594
|
COLO_R = 9;
|
|
47385
47595
|
GOLDEN_ANGLE = 2.399963229728653;
|
|
47386
47596
|
FAN_STEP = 16;
|
|
@@ -47435,7 +47645,7 @@ function renderMap(container, resolved, data, palette, isDark, onClickItem, expo
|
|
|
47435
47645
|
const p = g.append("path").attr("d", r.d).attr("fill", r.fill).attr("stroke", r.stroke).attr("stroke-width", strokeWidth);
|
|
47436
47646
|
if (r.layer !== "base") {
|
|
47437
47647
|
p.classed("dgmo-map-region", true).attr("data-region", r.id);
|
|
47438
|
-
if (r.
|
|
47648
|
+
if (r.value !== void 0) p.attr("data-value", r.value);
|
|
47439
47649
|
if (r.tags) {
|
|
47440
47650
|
for (const [group, value] of Object.entries(r.tags)) {
|
|
47441
47651
|
p.attr(`data-tag-${group.toLowerCase()}`, value.toLowerCase());
|
|
@@ -47496,6 +47706,11 @@ function renderMap(container, resolved, data, palette, isDark, onClickItem, expo
|
|
|
47496
47706
|
gPois.append("circle").attr("cx", poi.cx).attr("cy", poi.cy).attr("r", poi.r + 3).attr("fill", "none").attr("stroke", poi.stroke).attr("stroke-width", 1.5);
|
|
47497
47707
|
}
|
|
47498
47708
|
const c = gPois.append("circle").attr("cx", poi.cx).attr("cy", poi.cy).attr("r", poi.r).attr("fill", poi.fill).attr("stroke", poi.stroke).attr("stroke-width", 1).attr("data-line-number", poi.lineNumber).attr("data-poi", poi.id);
|
|
47709
|
+
if (poi.tags) {
|
|
47710
|
+
for (const [group, value] of Object.entries(poi.tags)) {
|
|
47711
|
+
c.attr(`data-tag-${group.toLowerCase()}`, value.toLowerCase());
|
|
47712
|
+
}
|
|
47713
|
+
}
|
|
47499
47714
|
if (onClickItem) {
|
|
47500
47715
|
c.style("cursor", "pointer").on(
|
|
47501
47716
|
"click",
|
|
@@ -47545,7 +47760,7 @@ function renderMap(container, resolved, data, palette, isDark, onClickItem, expo
|
|
|
47545
47760
|
const legendG = svg.append("g").attr("class", "dgmo-map-legend").attr("transform", `translate(0, ${legendY})`);
|
|
47546
47761
|
const ramp = layout.legend.ramp;
|
|
47547
47762
|
const scoreGroup = ramp ? {
|
|
47548
|
-
name: ramp.metric?.trim() || "
|
|
47763
|
+
name: ramp.metric?.trim() || "Value",
|
|
47549
47764
|
entries: [],
|
|
47550
47765
|
gradient: {
|
|
47551
47766
|
min: ramp.min,
|
|
@@ -58212,7 +58427,7 @@ var COMPLETION_REGISTRY = /* @__PURE__ */ new Map([
|
|
|
58212
58427
|
[
|
|
58213
58428
|
"map",
|
|
58214
58429
|
// Geographic map directives (§24B.2/.7). `poi`/`route` are content
|
|
58215
|
-
// keywords, not directives; metadata keys (
|
|
58430
|
+
// keywords, not directives; metadata keys (value/label/style) live in the
|
|
58216
58431
|
// reserved-key registry.
|
|
58217
58432
|
withGlobals({
|
|
58218
58433
|
region: {
|
|
@@ -58223,9 +58438,14 @@ var COMPLETION_REGISTRY = /* @__PURE__ */ new Map([
|
|
|
58223
58438
|
description: "Override the auto projection",
|
|
58224
58439
|
values: ["equirectangular", "natural-earth", "albers-usa", "mercator"]
|
|
58225
58440
|
},
|
|
58226
|
-
metric: { description: "Label for the region
|
|
58227
|
-
"
|
|
58228
|
-
|
|
58441
|
+
"region-metric": { description: "Label for the region value ramp" },
|
|
58442
|
+
"poi-metric": {
|
|
58443
|
+
description: "Label for the POI value (marker size) channel"
|
|
58444
|
+
},
|
|
58445
|
+
"flow-metric": {
|
|
58446
|
+
description: "Label for the edge/leg value (thickness) channel"
|
|
58447
|
+
},
|
|
58448
|
+
scale: { description: "Override value ramp anchors: scale <min> <max>" },
|
|
58229
58449
|
"region-labels": {
|
|
58230
58450
|
description: "Subdivision name labels",
|
|
58231
58451
|
values: ["full", "abbrev", "off"]
|