@honua/react 0.1.9-beta.0 → 0.1.10-beta.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/control-plane/admin-client.d.ts +2 -0
- package/control-plane/admin-client.d.ts.map +1 -1
- package/control-plane/admin-client.js +32 -1
- package/control-plane/client.d.ts +1 -1
- package/control-plane/client.d.ts.map +1 -1
- package/control-plane/client.js +124 -8
- package/control-plane/commands/catalog.d.ts +7 -7
- package/control-plane/commands/catalog.d.ts.map +1 -1
- package/control-plane/commands/catalog.js +27 -15
- package/control-plane/commands/runtime.d.ts +6 -6
- package/control-plane/commands/runtime.d.ts.map +1 -1
- package/control-plane/commands/runtime.js +26 -14
- package/control-plane/commands/types.d.ts +4 -2
- package/control-plane/commands/types.d.ts.map +1 -1
- package/control-plane/generated/admin-api.d.ts +6 -4
- package/control-plane/generated/admin-api.d.ts.map +1 -1
- package/control-plane/generated/admin-api.js +2 -2
- package/control-plane/generated/admin-operations.d.ts +7 -7
- package/control-plane/generated/admin-operations.d.ts.map +1 -1
- package/control-plane/generated/admin-operations.js +9 -9
- package/control-plane/index.d.ts +1 -1
- package/control-plane/index.d.ts.map +1 -1
- package/control-plane/index.js +1 -1
- package/core/client.d.ts.map +1 -1
- package/core/client.js +28 -30
- package/core/error-envelope.d.ts +31 -0
- package/core/error-envelope.d.ts.map +1 -1
- package/core/error-envelope.js +11 -0
- package/core/errors.d.ts +15 -3
- package/core/errors.d.ts.map +1 -1
- package/core/errors.js +254 -2
- package/core/geometry-input-sr.d.ts +3 -0
- package/core/geometry-input-sr.d.ts.map +1 -0
- package/core/geometry-input-sr.js +28 -0
- package/core/geoservices.d.ts.map +1 -1
- package/core/geoservices.js +33 -6
- package/core/grpc-adapter.d.ts.map +1 -1
- package/core/grpc-adapter.js +11 -3
- package/core/pbf-decoder.d.ts.map +1 -1
- package/core/pbf-decoder.js +16 -4
- package/core/protocol-transport.d.ts +6 -1
- package/core/protocol-transport.d.ts.map +1 -1
- package/core/request-pipeline.d.ts +6 -3
- package/core/request-pipeline.d.ts.map +1 -1
- package/core/request-pipeline.js +28 -11
- package/core/spatial-filter.d.ts +4 -4
- package/core/spatial-filter.d.ts.map +1 -1
- package/core/spatial-filter.js +7 -7
- package/core/types.d.ts +14 -3
- package/core/types.d.ts.map +1 -1
- package/esri-compat/class-breaks-renderer.d.ts +2 -0
- package/esri-compat/class-breaks-renderer.d.ts.map +1 -1
- package/esri-compat/class-breaks-renderer.js +7 -0
- package/esri-compat/controls.d.ts +10 -1
- package/esri-compat/controls.d.ts.map +1 -1
- package/esri-compat/controls.js +86 -2
- package/esri-compat/directions.d.ts +35 -0
- package/esri-compat/directions.d.ts.map +1 -1
- package/esri-compat/directions.js +153 -2
- package/esri-compat/expand.d.ts +1 -0
- package/esri-compat/expand.d.ts.map +1 -1
- package/esri-compat/expand.js +61 -0
- package/esri-compat/feature-layer.d.ts +29 -4
- package/esri-compat/feature-layer.d.ts.map +1 -1
- package/esri-compat/feature-layer.js +335 -13
- package/esri-compat/geometry-engine.d.ts +4 -0
- package/esri-compat/geometry-engine.d.ts.map +1 -1
- package/esri-compat/geometry-engine.js +8 -1
- package/esri-compat/graphic.d.ts +7 -4
- package/esri-compat/graphic.d.ts.map +1 -1
- package/esri-compat/legend.d.ts +2 -1
- package/esri-compat/legend.d.ts.map +1 -1
- package/esri-compat/legend.js +15 -0
- package/esri-compat/map-view-mount.d.ts +48 -0
- package/esri-compat/map-view-mount.d.ts.map +1 -0
- package/esri-compat/map-view-mount.js +344 -0
- package/esri-compat/map-view.d.ts +38 -6
- package/esri-compat/map-view.d.ts.map +1 -1
- package/esri-compat/map-view.js +467 -33
- package/esri-compat/portal.d.ts +2 -0
- package/esri-compat/portal.d.ts.map +1 -1
- package/esri-compat/portal.js +7 -2
- package/esri-compat/renderer-objects.d.ts +7 -2
- package/esri-compat/renderer-objects.d.ts.map +1 -1
- package/esri-compat/renderer-objects.js +16 -5
- package/esri-compat/route-layer.d.ts +8 -0
- package/esri-compat/route-layer.d.ts.map +1 -1
- package/esri-compat/route-layer.js +24 -4
- package/esri-compat/route-task.d.ts +5 -1
- package/esri-compat/route-task.d.ts.map +1 -1
- package/esri-compat/route-task.js +119 -7
- package/esri-compat/scene-view.d.ts.map +1 -1
- package/esri-compat/scene-view.js +1 -0
- package/esri-compat/search.d.ts +2 -1
- package/esri-compat/search.d.ts.map +1 -1
- package/esri-compat/search.js +52 -2
- package/esri-compat/unique-value-renderer.d.ts +2 -0
- package/esri-compat/unique-value-renderer.d.ts.map +1 -1
- package/esri-compat/unique-value-renderer.js +7 -0
- package/esri-compat/web-map.d.ts +10 -0
- package/esri-compat/web-map.d.ts.map +1 -1
- package/esri-compat/web-map.js +102 -0
- package/map/webmap-maplibre.d.ts +2 -1
- package/map/webmap-maplibre.d.ts.map +1 -1
- package/map/webmap-maplibre.js +3 -0
- package/package.json +3 -3
- package/query-planner/geoservices.d.ts.map +1 -1
- package/query-planner/geoservices.js +2 -0
- package/query-planner/types.d.ts +2 -0
- package/query-planner/types.d.ts.map +1 -1
- package/realtime/honua-server.d.ts +4 -0
- package/realtime/honua-server.d.ts.map +1 -1
- package/realtime/honua-server.js +10 -0
- package/realtime/resumable.js +9 -0
- package/realtime/types.d.ts +8 -0
- package/realtime/types.d.ts.map +1 -1
- package/studio/capability-manifest.d.ts +10 -0
- package/studio/capability-manifest.d.ts.map +1 -1
- package/studio/capability-manifest.js +38 -0
- package/studio/command-adapter.d.ts +35 -0
- package/studio/command-adapter.d.ts.map +1 -0
- package/studio/command-adapter.js +36 -0
- package/studio/generated/studio-api.d.ts +1062 -0
- package/studio/generated/studio-api.d.ts.map +1 -0
- package/studio/generated/studio-api.js +4 -0
- package/studio/index.d.ts +8 -6
- package/studio/index.d.ts.map +1 -1
- package/studio/index.js +6 -5
- package/studio/lifecycle-client.d.ts +3 -3
- package/studio/lifecycle-client.d.ts.map +1 -1
- package/studio/lifecycle-client.js +41 -22
- package/studio/lifecycle-types.d.ts +56 -77
- package/studio/lifecycle-types.d.ts.map +1 -1
- package/studio/lifecycle-types.js +5 -12
- package/studio/types.d.ts +37 -7
- package/studio/types.d.ts.map +1 -1
- package/studio/types.js +5 -3
- package/studio/validate.d.ts.map +1 -1
- package/studio/validate.js +104 -7
- package/style/renderers.d.ts +6 -1
- package/style/renderers.d.ts.map +1 -1
- package/style/renderers.js +11 -6
- package/style/visual-variables.d.ts +43 -0
- package/style/visual-variables.d.ts.map +1 -0
- package/style/visual-variables.js +183 -0
- package/webmap/convert-layer.d.ts +2 -1
- package/webmap/convert-layer.d.ts.map +1 -1
- package/webmap/convert-layer.js +20 -3
- package/webmap/convert-renderer.d.ts +10 -3
- package/webmap/convert-renderer.d.ts.map +1 -1
- package/webmap/convert-renderer.js +190 -36
- package/webmap/index.d.ts +1 -0
- package/webmap/index.d.ts.map +1 -1
- package/webmap/parse.d.ts +2 -1
- package/webmap/parse.d.ts.map +1 -1
- package/webmap/parse.js +1 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { Expr, eq, exponential, get, interpolate, linear, rgba, switchCase, toNumber, typeOf, zoom, } from "../expr/expression.js";
|
|
2
|
+
/** Apply only explicit bindings; prototype names are valid source fields. */
|
|
3
|
+
export function bindRendererField(field, options) {
|
|
4
|
+
const bindings = options.fieldMap;
|
|
5
|
+
return bindings && Object.hasOwn(bindings, field) ? (bindings[field] ?? field) : field;
|
|
6
|
+
}
|
|
7
|
+
/** ArcGIS Web Mercator scale at MapLibre zoom zero: 512 CSS pixels, 96 DPI.
|
|
8
|
+
* This is projected scale, so latitude does not change it. Ground resolution
|
|
9
|
+
* differs by cos(latitude); $view.scale is not a ground-distance measurement.
|
|
10
|
+
*/
|
|
11
|
+
export const WEB_MERCATOR_SCALE_AT_ZOOM_ZERO = (2 * Math.PI * 6378137 * 96) / (512 * 0.0254);
|
|
12
|
+
export function webMercatorScaleToZoom(scale) {
|
|
13
|
+
return Math.log2(WEB_MERCATOR_SCALE_AT_ZOOM_ZERO / scale);
|
|
14
|
+
}
|
|
15
|
+
export function compileVisualVariables(variables, layerType, basePaint, warn, options = {}, outlineWidth = 0, outlinePaint = {}) {
|
|
16
|
+
const result = { paint: {}, legends: [] };
|
|
17
|
+
if (variables === undefined)
|
|
18
|
+
return result;
|
|
19
|
+
if (!Array.isArray(variables)) {
|
|
20
|
+
warn.child("visualVariables").warn("unsupported-visual-variable", "Expected a visualVariables array.");
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
const assigned = new Set();
|
|
24
|
+
variables.forEach((input, index) => {
|
|
25
|
+
const at = warn.child(`visualVariables[${index}]`);
|
|
26
|
+
const reject = (message, property) => (property ? at.child(property) : at).warn("unsupported-visual-variable", message);
|
|
27
|
+
if (!isRecord(input))
|
|
28
|
+
return reject("Expected a visual variable object.");
|
|
29
|
+
const color = input.type === "colorInfo";
|
|
30
|
+
if (!color && input.type !== "sizeInfo")
|
|
31
|
+
return reject(`Unsupported visual variable type: ${String(input.type)}. Reauthor this variable.`, "type");
|
|
32
|
+
for (const key of Object.keys(input)) {
|
|
33
|
+
if (!KNOWN_PROPERTIES.has(key))
|
|
34
|
+
return reject(`Unsupported visual variable property '${key}'; this variable was not applied.`, key);
|
|
35
|
+
}
|
|
36
|
+
if (color &&
|
|
37
|
+
["minDataValue", "maxDataValue", "minSize", "maxSize", "valueUnit"].some((key) => input[key] != null)) {
|
|
38
|
+
return reject("Size range properties cannot be applied to a colorInfo variable.");
|
|
39
|
+
}
|
|
40
|
+
const normalization = ["normalizationField", "normalizationType", "normalizationTotal"].find((key) => input[key] != null);
|
|
41
|
+
if (normalization) {
|
|
42
|
+
return reject("Visual variable normalization is unsupported; precompute a numeric field and bind it explicitly.", normalization);
|
|
43
|
+
}
|
|
44
|
+
const expression = input.valueExpression ?? input.expression;
|
|
45
|
+
const scale = !color && (expression === "$view.scale" || expression === "view.scale");
|
|
46
|
+
if (expression != null && !scale)
|
|
47
|
+
return reject("Unsupported visual variable expression; bind a numeric field or use $view.scale for sizeInfo.", input.valueExpression !== undefined ? "valueExpression" : "expression");
|
|
48
|
+
if (input.valueExpression !== undefined &&
|
|
49
|
+
input.expression !== undefined &&
|
|
50
|
+
!["$view.scale", "view.scale"].includes(String(input.expression))) {
|
|
51
|
+
return reject("Conflicting expression and valueExpression properties.", "expression");
|
|
52
|
+
}
|
|
53
|
+
if (!scale && (typeof input.field !== "string" || input.field.length === 0))
|
|
54
|
+
return reject("A numeric field is required.", "field");
|
|
55
|
+
if (input.valueUnit != null && input.valueUnit !== "unknown")
|
|
56
|
+
return reject("Real-world size units are unsupported; provide a screen size ramp in points.", "valueUnit");
|
|
57
|
+
const outline = !color && layerType === "fill" && input.target === "outline";
|
|
58
|
+
if (input.target != null && !outline)
|
|
59
|
+
return reject("Only sizeInfo on polygon outlines supports a target.", "target");
|
|
60
|
+
const property = color
|
|
61
|
+
? { circle: "circle-color", line: "line-color", fill: "fill-color" }[layerType]
|
|
62
|
+
: outline
|
|
63
|
+
? "line-width"
|
|
64
|
+
: { circle: "circle-radius", line: "line-width" }[layerType];
|
|
65
|
+
if (!property)
|
|
66
|
+
return reject(`Unsupported ${String(input.type)} combination with ${layerType} symbols.`);
|
|
67
|
+
if (assigned.has(property))
|
|
68
|
+
return reject(`Multiple variables target ${property}; only the first supported variable is applied.`);
|
|
69
|
+
let rawStops = input.stops;
|
|
70
|
+
const stopPath = (index, property) => input.stops !== undefined
|
|
71
|
+
? `stops[${index}].${property}`
|
|
72
|
+
: `${index === 0 ? "min" : "max"}${property === "value" ? "DataValue" : "Size"}`;
|
|
73
|
+
if (!color && rawStops === undefined)
|
|
74
|
+
rawStops = [
|
|
75
|
+
{ value: input.minDataValue, size: input.minSize },
|
|
76
|
+
{ value: input.maxDataValue, size: input.maxSize },
|
|
77
|
+
];
|
|
78
|
+
if (!Array.isArray(rawStops) || rawStops.length < 2)
|
|
79
|
+
return reject("At least two strictly ascending stops are required.", "stops");
|
|
80
|
+
const stops = [];
|
|
81
|
+
for (let i = 0; i < rawStops.length; i++) {
|
|
82
|
+
const stop = rawStops[i];
|
|
83
|
+
if (!isRecord(stop) ||
|
|
84
|
+
!finite(stop.value) ||
|
|
85
|
+
(scale && stop.value <= 0) ||
|
|
86
|
+
(i > 0 && stop.value <= stops[i - 1].value))
|
|
87
|
+
return reject("Stop values must be finite, strictly ascending, and positive for scale.", stopPath(i, "value"));
|
|
88
|
+
for (const property of Object.keys(stop)) {
|
|
89
|
+
if (!["value", "label", color ? "color" : "size"].includes(property)) {
|
|
90
|
+
return reject(`Unsupported stop property '${property}'; this variable was not applied.`, `stops[${i}].${property}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const label = typeof stop.label === "string" ? stop.label : String(stop.value);
|
|
94
|
+
if (color) {
|
|
95
|
+
const c = stop.color;
|
|
96
|
+
if (!Array.isArray(c) || c.length !== 4 || !c.every((v) => finite(v) && v >= 0 && v <= 255))
|
|
97
|
+
return reject("Color stops require RGBA components in [0,255].", `stops[${i}].color`);
|
|
98
|
+
const css = `rgba(${c[0]},${c[1]},${c[2]},${c[3] / 255})`;
|
|
99
|
+
stops.push({ value: stop.value, output: rgba(c[0], c[1], c[2], c[3] / 255), label, color: css });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
if (!finite(stop.size) || stop.size < 0)
|
|
103
|
+
return reject("Size stops require a finite nonnegative size in points; nested scale ranges are unsupported.", stopPath(i, "size"));
|
|
104
|
+
const size = (stop.size * (96 / 72)) / (layerType === "circle" ? 2 : 1);
|
|
105
|
+
stops.push({ value: stop.value, output: size, label, size });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const field = typeof input.field === "string" ? bindRendererField(input.field, options) : undefined;
|
|
109
|
+
const sourceFallback = missingSafeStyle(outline ? outlineWidth : (basePaint[property] ?? (color ? "transparent" : 0)));
|
|
110
|
+
const fallback = sourceFallback;
|
|
111
|
+
const ramp = scale
|
|
112
|
+
? interpolate(exponential(0.5), zoom(), ...[...stops].reverse().map((s) => [webMercatorScaleToZoom(s.value), s.output]))
|
|
113
|
+
: switchCase([
|
|
114
|
+
eq(typeOf(get(field)), "number"),
|
|
115
|
+
interpolate(linear(), toNumber(get(field)), ...stops.map((s) => [s.value, s.output])),
|
|
116
|
+
], new Expr(fallback));
|
|
117
|
+
if (outline) {
|
|
118
|
+
result.outline = {
|
|
119
|
+
paint: {
|
|
120
|
+
...outlinePaint,
|
|
121
|
+
"line-color": basePaint["fill-outline-color"] ?? "transparent",
|
|
122
|
+
"line-width": ramp.toJSON(),
|
|
123
|
+
},
|
|
124
|
+
layout: {},
|
|
125
|
+
};
|
|
126
|
+
// A separate line layer replaces MapLibre's fixed one-pixel fill outline.
|
|
127
|
+
result.paint["fill-outline-color"] = "transparent";
|
|
128
|
+
}
|
|
129
|
+
else
|
|
130
|
+
result.paint[property] = ramp.toJSON();
|
|
131
|
+
// Symbol alpha is carried by color, never multiplied a second time.
|
|
132
|
+
if (color && layerType === "fill")
|
|
133
|
+
result.paint["fill-opacity"] = 1;
|
|
134
|
+
assigned.add(property);
|
|
135
|
+
const legendOptions = isRecord(input.legendOptions) ? input.legendOptions : undefined;
|
|
136
|
+
if (legendOptions?.showLegend !== false)
|
|
137
|
+
result.legends.push({
|
|
138
|
+
type: color ? "color" : "size",
|
|
139
|
+
...(field ? { field } : {}),
|
|
140
|
+
...(typeof legendOptions?.title === "string" ? { title: legendOptions.title } : {}),
|
|
141
|
+
property,
|
|
142
|
+
input: scale ? "scale" : "field",
|
|
143
|
+
stops: stops.map(({ output: _output, ...stop }) => stop),
|
|
144
|
+
outOfRange: "clamp",
|
|
145
|
+
missingValue: "base-symbol",
|
|
146
|
+
missingValueStyle: fallback,
|
|
147
|
+
...(!color ? { sizeUnit: "css-pixels" } : {}),
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
function finite(value) {
|
|
153
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
154
|
+
}
|
|
155
|
+
function isRecord(value) {
|
|
156
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
157
|
+
}
|
|
158
|
+
// A class-break step requires a number. Missing classification values use its
|
|
159
|
+
// default symbol instead of causing a MapLibre expression evaluation error.
|
|
160
|
+
function missingSafeStyle(style) {
|
|
161
|
+
return Array.isArray(style) && style[0] === "step"
|
|
162
|
+
? ["case", ["==", ["typeof", style[1]], "number"], style, style[2]]
|
|
163
|
+
: style;
|
|
164
|
+
}
|
|
165
|
+
const KNOWN_PROPERTIES = new Set([
|
|
166
|
+
"type",
|
|
167
|
+
"field",
|
|
168
|
+
"stops",
|
|
169
|
+
"valueExpression",
|
|
170
|
+
"expression",
|
|
171
|
+
"valueExpressionTitle",
|
|
172
|
+
"legendOptions",
|
|
173
|
+
"normalizationField",
|
|
174
|
+
"normalizationType",
|
|
175
|
+
"normalizationTotal",
|
|
176
|
+
"target",
|
|
177
|
+
"valueUnit",
|
|
178
|
+
"minDataValue",
|
|
179
|
+
"maxDataValue",
|
|
180
|
+
"minSize",
|
|
181
|
+
"maxSize",
|
|
182
|
+
"authoringInfo",
|
|
183
|
+
]);
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import type { HonuaLayerSpecification, HonuaSourceSpecification } from "../style/specification.js";
|
|
10
|
+
import type { RendererConversionOptions } from "../style/visual-variables.js";
|
|
10
11
|
import { type HonuaPopupConfig } from "./convert-popup.js";
|
|
11
12
|
import type { WebMapOperationalLayer } from "./types.js";
|
|
12
13
|
import { type WarningCollector } from "./warnings.js";
|
|
@@ -18,5 +19,5 @@ export interface LayerConversionResult {
|
|
|
18
19
|
layers: HonuaLayerSpecification[];
|
|
19
20
|
popup?: HonuaPopupConfig;
|
|
20
21
|
}
|
|
21
|
-
export declare function convertOperationalLayer(opLayer: WebMapOperationalLayer, index: number, warn: WarningCollector): LayerConversionResult;
|
|
22
|
+
export declare function convertOperationalLayer(opLayer: WebMapOperationalLayer, index: number, warn: WarningCollector, options?: RendererConversionOptions): LayerConversionResult;
|
|
22
23
|
//# sourceMappingURL=convert-layer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-layer.d.ts","sourceRoot":"","sources":["../../../src/webmap/convert-layer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAEV,uBAAuB,EAEvB,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"convert-layer.d.ts","sourceRoot":"","sources":["../../../src/webmap/convert-layer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAEV,uBAAuB,EAEvB,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAE,KAAK,gBAAgB,EAAoB,MAAM,oBAAoB,CAAC;AAE7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,KAAK,gBAAgB,EAAyB,MAAM,eAAe,CAAC;AAE7E,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,CAAC;IAC7F,MAAM,EAAE,uBAAuB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,sBAAsB,EAC/B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,gBAAgB,EACtB,OAAO,GAAE,yBAA8B,GACtC,qBAAqB,CAkIvB"}
|
package/webmap/convert-layer.js
CHANGED
|
@@ -10,7 +10,7 @@ import { convertLabelingInfo } from "./convert-label.js";
|
|
|
10
10
|
import { convertPopupInfo } from "./convert-popup.js";
|
|
11
11
|
import { convertRenderer } from "./convert-renderer.js";
|
|
12
12
|
import { warnUnknownProperties } from "./warnings.js";
|
|
13
|
-
export function convertOperationalLayer(opLayer, index, warn) {
|
|
13
|
+
export function convertOperationalLayer(opLayer, index, warn, options = {}) {
|
|
14
14
|
const result = { sources: {}, layers: [] };
|
|
15
15
|
const layerWarn = warn.child(`operationalLayers[${index}]`);
|
|
16
16
|
warnUnknownProperties(opLayer, OPERATIONAL_LAYER_PROPERTIES, layerWarn);
|
|
@@ -49,7 +49,7 @@ export function convertOperationalLayer(opLayer, index, warn) {
|
|
|
49
49
|
warnUnknownProperties(opLayer.layerDefinition?.drawingInfo, DRAWING_INFO_PROPERTIES, layerWarn.child("layerDefinition.drawingInfo"));
|
|
50
50
|
// Convert renderer
|
|
51
51
|
const renderer = opLayer.layerDefinition?.drawingInfo?.renderer;
|
|
52
|
-
const rendererResult = convertRenderer(renderer, layerWarn.child("layerDefinition.drawingInfo.renderer"));
|
|
52
|
+
const rendererResult = convertRenderer(renderer, layerWarn.child("layerDefinition.drawingInfo.renderer"), options);
|
|
53
53
|
if (rendererResult) {
|
|
54
54
|
const layer = {
|
|
55
55
|
id: layerId,
|
|
@@ -80,7 +80,24 @@ export function convertOperationalLayer(opLayer, index, warn) {
|
|
|
80
80
|
if (opLayer.title) {
|
|
81
81
|
layer.metadata = { ...layer.metadata, title: opLayer.title };
|
|
82
82
|
}
|
|
83
|
+
if (rendererResult.visualVariableLegends?.length) {
|
|
84
|
+
layer.metadata = { ...layer.metadata, "honua:visual-variable-legends": rendererResult.visualVariableLegends };
|
|
85
|
+
}
|
|
83
86
|
result.layers.push(layer);
|
|
87
|
+
for (const [outlineIndex, extra] of (rendererResult.additionalLayers ?? []).entries()) {
|
|
88
|
+
const outline = {
|
|
89
|
+
...layer,
|
|
90
|
+
id: `${layerId}-outline-${outlineIndex}`,
|
|
91
|
+
type: extra.layerType,
|
|
92
|
+
paint: { ...extra.paint },
|
|
93
|
+
layout: { ...extra.layout, ...(opLayer.visibility === false ? { visibility: "none" } : {}) },
|
|
94
|
+
};
|
|
95
|
+
if (transparency != null && transparency > 0)
|
|
96
|
+
applyTransparency(outline, transparency);
|
|
97
|
+
if (opLayer.opacity != null && opLayer.opacity < 1)
|
|
98
|
+
applyOpacity(outline, opLayer.opacity);
|
|
99
|
+
result.layers.push(outline);
|
|
100
|
+
}
|
|
84
101
|
}
|
|
85
102
|
else if (!renderer) {
|
|
86
103
|
// No renderer — create a default layer so the source is referenced
|
|
@@ -120,7 +137,7 @@ function applyOpacity(layer, opacity) {
|
|
|
120
137
|
paint["fill-opacity"] = opacity;
|
|
121
138
|
break;
|
|
122
139
|
case "line":
|
|
123
|
-
paint["line-opacity"] = opacity;
|
|
140
|
+
paint["line-opacity"] = (typeof paint["line-opacity"] === "number" ? paint["line-opacity"] : 1) * opacity;
|
|
124
141
|
break;
|
|
125
142
|
case "circle":
|
|
126
143
|
paint["circle-opacity"] = opacity;
|
|
@@ -10,14 +10,21 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import type { ClassBreaksRenderer, UniqueValueRenderer } from "../style/renderers.js";
|
|
13
|
+
import { type RendererConversionOptions, type VisualVariableLegend } from "../style/visual-variables.js";
|
|
13
14
|
import type { WebMapClassBreaksRenderer, WebMapRenderer, WebMapUniqueValueRenderer } from "./types.js";
|
|
14
15
|
import type { WarningCollector } from "./warnings.js";
|
|
15
16
|
export interface RendererConversionResult {
|
|
16
17
|
layerType: string;
|
|
17
18
|
paint: Record<string, unknown>;
|
|
18
19
|
layout: Record<string, unknown>;
|
|
20
|
+
additionalLayers?: {
|
|
21
|
+
layerType: string;
|
|
22
|
+
paint: Record<string, unknown>;
|
|
23
|
+
layout: Record<string, unknown>;
|
|
24
|
+
}[];
|
|
25
|
+
visualVariableLegends?: VisualVariableLegend[];
|
|
19
26
|
}
|
|
20
|
-
export declare function convertRenderer(renderer: WebMapRenderer | undefined, warn: WarningCollector): RendererConversionResult | undefined;
|
|
27
|
+
export declare function convertRenderer(renderer: WebMapRenderer | undefined, warn: WarningCollector, options?: RendererConversionOptions): RendererConversionResult | undefined;
|
|
21
28
|
/**
|
|
22
29
|
* Build a first-class unique-value renderer object from WebMap renderer
|
|
23
30
|
* JSON. Returns `undefined` when the renderer has no value infos or the
|
|
@@ -25,7 +32,7 @@ export declare function convertRenderer(renderer: WebMapRenderer | undefined, wa
|
|
|
25
32
|
*
|
|
26
33
|
* @experimental
|
|
27
34
|
*/
|
|
28
|
-
export declare function uniqueValueRendererFromWebMap(renderer: WebMapUniqueValueRenderer, warn: WarningCollector): UniqueValueRenderer | undefined;
|
|
35
|
+
export declare function uniqueValueRendererFromWebMap(renderer: WebMapUniqueValueRenderer, warn: WarningCollector, options?: RendererConversionOptions): UniqueValueRenderer | undefined;
|
|
29
36
|
/**
|
|
30
37
|
* Build a first-class class-breaks renderer object from WebMap renderer
|
|
31
38
|
* JSON. Returns `undefined` when the renderer has no break infos, no field,
|
|
@@ -34,5 +41,5 @@ export declare function uniqueValueRendererFromWebMap(renderer: WebMapUniqueValu
|
|
|
34
41
|
*
|
|
35
42
|
* @experimental
|
|
36
43
|
*/
|
|
37
|
-
export declare function classBreaksRendererFromWebMap(renderer: WebMapClassBreaksRenderer, warn: WarningCollector): ClassBreaksRenderer | undefined;
|
|
44
|
+
export declare function classBreaksRendererFromWebMap(renderer: WebMapClassBreaksRenderer, warn: WarningCollector, options?: RendererConversionOptions): ClassBreaksRenderer | undefined;
|
|
38
45
|
//# sourceMappingURL=convert-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-renderer.d.ts","sourceRoot":"","sources":["../../../src/webmap/convert-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAmC,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"convert-renderer.d.ts","sourceRoot":"","sources":["../../../src/webmap/convert-renderer.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|
@@ -10,41 +10,40 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import { classBreaksRenderer, uniqueValueRenderer } from "../style/renderers.js";
|
|
13
|
-
import {
|
|
14
|
-
|
|
13
|
+
import { bindRendererField, compileVisualVariables, } from "../style/visual-variables.js";
|
|
14
|
+
import { convertSymbol, esriLineStyleToDashArray } from "./convert-symbol.js";
|
|
15
|
+
export function convertRenderer(renderer, warn, options = {}) {
|
|
15
16
|
if (!renderer)
|
|
16
17
|
return undefined;
|
|
17
18
|
switch (renderer.type) {
|
|
18
19
|
case "simple":
|
|
19
|
-
return
|
|
20
|
+
return applyVisualVariables(convertRendererSymbol(renderer.symbol, warn, renderer.visualVariables), renderer, warn, options);
|
|
20
21
|
case "uniqueValue":
|
|
21
|
-
return convertUniqueValueRenderer(renderer, warn);
|
|
22
|
+
return convertUniqueValueRenderer(renderer, warn, options);
|
|
22
23
|
case "classBreaks":
|
|
23
|
-
return convertClassBreaksRenderer(renderer, warn);
|
|
24
|
+
return convertClassBreaksRenderer(renderer, warn, options);
|
|
24
25
|
default:
|
|
25
26
|
warn.warn("unsupported-renderer", `Unsupported renderer type: ${renderer.type}`, { type: renderer.type });
|
|
27
|
+
compileVisualVariables(renderer.visualVariables, "unknown", {}, warn, options);
|
|
26
28
|
return undefined;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
function
|
|
30
|
-
return convertSymbol(symbol, warn);
|
|
31
|
-
}
|
|
32
|
-
function convertUniqueValueRenderer(renderer, warn) {
|
|
31
|
+
function convertUniqueValueRenderer(renderer, warn, options) {
|
|
33
32
|
const infos = renderer.uniqueValueInfos ?? [];
|
|
34
33
|
if (infos.length === 0) {
|
|
35
|
-
return
|
|
34
|
+
return applyVisualVariables(convertRendererSymbol(renderer.defaultSymbol, warn, renderer.visualVariables), renderer, warn, options);
|
|
36
35
|
}
|
|
37
|
-
const rendererObject = uniqueValueRendererFromWebMap(renderer, warn);
|
|
36
|
+
const rendererObject = uniqueValueRendererFromWebMap(renderer, warn, options);
|
|
38
37
|
if (!rendererObject)
|
|
39
38
|
return undefined;
|
|
40
39
|
return compileRendererObject(rendererObject);
|
|
41
40
|
}
|
|
42
|
-
function convertClassBreaksRenderer(renderer, warn) {
|
|
41
|
+
function convertClassBreaksRenderer(renderer, warn, options) {
|
|
43
42
|
const breaks = renderer.classBreakInfos ?? [];
|
|
44
43
|
if (breaks.length === 0) {
|
|
45
|
-
return
|
|
44
|
+
return applyVisualVariables(convertRendererSymbol(renderer.defaultSymbol, warn, renderer.visualVariables), renderer, warn, options);
|
|
46
45
|
}
|
|
47
|
-
const rendererObject = classBreaksRendererFromWebMap(renderer, warn);
|
|
46
|
+
const rendererObject = classBreaksRendererFromWebMap(renderer, warn, options);
|
|
48
47
|
if (!rendererObject)
|
|
49
48
|
return undefined;
|
|
50
49
|
return compileRendererObject(rendererObject);
|
|
@@ -56,17 +55,22 @@ function convertClassBreaksRenderer(renderer, warn) {
|
|
|
56
55
|
*
|
|
57
56
|
* @experimental
|
|
58
57
|
*/
|
|
59
|
-
export function uniqueValueRendererFromWebMap(renderer, warn) {
|
|
58
|
+
export function uniqueValueRendererFromWebMap(renderer, warn, options = {}) {
|
|
59
|
+
warnRendererSemantics(renderer, warn);
|
|
60
60
|
const infos = renderer.uniqueValueInfos ?? [];
|
|
61
|
-
if (infos.length === 0)
|
|
61
|
+
if (infos.length === 0) {
|
|
62
|
+
compileVisualVariables(renderer.visualVariables, "unknown", {}, warn, options);
|
|
62
63
|
return undefined;
|
|
64
|
+
}
|
|
63
65
|
// The first valid symbol determines the layer type.
|
|
64
|
-
const firstResult =
|
|
65
|
-
if (!firstResult)
|
|
66
|
+
const firstResult = convertRendererSymbol(infos[0].symbol, warn, renderer.visualVariables);
|
|
67
|
+
if (!firstResult) {
|
|
68
|
+
compileVisualVariables(renderer.visualVariables, "unknown", {}, warn, options);
|
|
66
69
|
return undefined;
|
|
70
|
+
}
|
|
67
71
|
const values = [];
|
|
68
72
|
for (const info of infos) {
|
|
69
|
-
const symbolResult =
|
|
73
|
+
const symbolResult = convertRendererSymbol(info.symbol, warn, renderer.visualVariables);
|
|
70
74
|
if (!symbolResult)
|
|
71
75
|
continue;
|
|
72
76
|
values.push({
|
|
@@ -75,16 +79,22 @@ export function uniqueValueRendererFromWebMap(renderer, warn) {
|
|
|
75
79
|
style: { paint: symbolResult.paint, layout: symbolResult.layout },
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
|
-
|
|
79
|
-
field: renderer.field1 ?? "",
|
|
80
|
-
...(renderer.field2 !== undefined ? { field2: renderer.field2 } : {}),
|
|
81
|
-
...(renderer.field3 !== undefined ? { field3: renderer.field3 } : {}),
|
|
82
|
+
const base = uniqueValueRenderer({
|
|
83
|
+
field: bindRendererField(renderer.field1 ?? "", options),
|
|
84
|
+
...(renderer.field2 !== undefined ? { field2: bindRendererField(renderer.field2, options) } : {}),
|
|
85
|
+
...(renderer.field3 !== undefined ? { field3: bindRendererField(renderer.field3, options) } : {}),
|
|
82
86
|
...(renderer.fieldDelimiter !== undefined ? { fieldDelimiter: renderer.fieldDelimiter } : {}),
|
|
83
87
|
values,
|
|
84
88
|
...(renderer.defaultLabel !== undefined ? { defaultLabel: renderer.defaultLabel } : {}),
|
|
85
|
-
...defaultStyleFromSymbol(renderer.defaultSymbol, warn),
|
|
89
|
+
...defaultStyleFromSymbol(renderer.defaultSymbol, warn, renderer.visualVariables),
|
|
86
90
|
layerType: firstResult.layerType,
|
|
87
91
|
});
|
|
92
|
+
if (renderer.visualVariables === undefined)
|
|
93
|
+
return base;
|
|
94
|
+
return uniqueValueRenderer({
|
|
95
|
+
...base.toJSON(),
|
|
96
|
+
visualVariableStyle: compileVisualVariables(renderer.visualVariables, firstResult.layerType, base.toMapLibre("polygon")[0].paint, warn, options, ...outlineFromRenderer(renderer, options, warn)),
|
|
97
|
+
});
|
|
88
98
|
}
|
|
89
99
|
/**
|
|
90
100
|
* Build a first-class class-breaks renderer object from WebMap renderer
|
|
@@ -94,21 +104,27 @@ export function uniqueValueRendererFromWebMap(renderer, warn) {
|
|
|
94
104
|
*
|
|
95
105
|
* @experimental
|
|
96
106
|
*/
|
|
97
|
-
export function classBreaksRendererFromWebMap(renderer, warn) {
|
|
107
|
+
export function classBreaksRendererFromWebMap(renderer, warn, options = {}) {
|
|
108
|
+
warnRendererSemantics(renderer, warn);
|
|
98
109
|
const breaks = renderer.classBreakInfos ?? [];
|
|
99
|
-
if (breaks.length === 0)
|
|
110
|
+
if (breaks.length === 0) {
|
|
111
|
+
compileVisualVariables(renderer.visualVariables, "unknown", {}, warn, options);
|
|
100
112
|
return undefined;
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
}
|
|
114
|
+
const firstResult = convertRendererSymbol(breaks[0].symbol, warn, renderer.visualVariables);
|
|
115
|
+
if (!firstResult) {
|
|
116
|
+
compileVisualVariables(renderer.visualVariables, "unknown", {}, warn, options);
|
|
103
117
|
return undefined;
|
|
118
|
+
}
|
|
104
119
|
const field = renderer.field;
|
|
105
120
|
if (!field) {
|
|
106
121
|
warn.warn("missing-field", "classBreaks renderer missing field property");
|
|
122
|
+
compileVisualVariables(renderer.visualVariables, "unknown", {}, warn, options);
|
|
107
123
|
return undefined;
|
|
108
124
|
}
|
|
109
125
|
const entries = [];
|
|
110
126
|
for (const brk of breaks) {
|
|
111
|
-
const symbolResult =
|
|
127
|
+
const symbolResult = convertRendererSymbol(brk.symbol, warn, renderer.visualVariables);
|
|
112
128
|
if (!symbolResult)
|
|
113
129
|
continue;
|
|
114
130
|
entries.push({
|
|
@@ -118,18 +134,24 @@ export function classBreaksRendererFromWebMap(renderer, warn) {
|
|
|
118
134
|
style: { paint: symbolResult.paint, layout: symbolResult.layout },
|
|
119
135
|
});
|
|
120
136
|
}
|
|
121
|
-
|
|
122
|
-
field,
|
|
137
|
+
const base = classBreaksRenderer({
|
|
138
|
+
field: bindRendererField(field, options),
|
|
123
139
|
breaks: entries,
|
|
124
140
|
...(renderer.defaultLabel !== undefined ? { defaultLabel: renderer.defaultLabel } : {}),
|
|
125
|
-
...defaultStyleFromSymbol(renderer.defaultSymbol, warn),
|
|
141
|
+
...defaultStyleFromSymbol(renderer.defaultSymbol, warn, renderer.visualVariables),
|
|
126
142
|
layerType: firstResult.layerType,
|
|
127
143
|
});
|
|
144
|
+
if (renderer.visualVariables === undefined)
|
|
145
|
+
return base;
|
|
146
|
+
return classBreaksRenderer({
|
|
147
|
+
...base.toJSON(),
|
|
148
|
+
visualVariableStyle: compileVisualVariables(renderer.visualVariables, firstResult.layerType, base.toMapLibre("polygon")[0].paint, warn, options, ...outlineFromRenderer(renderer, options, warn)),
|
|
149
|
+
});
|
|
128
150
|
}
|
|
129
|
-
function defaultStyleFromSymbol(defaultSymbol, warn) {
|
|
151
|
+
function defaultStyleFromSymbol(defaultSymbol, warn, variables) {
|
|
130
152
|
if (!defaultSymbol)
|
|
131
153
|
return {};
|
|
132
|
-
const converted =
|
|
154
|
+
const converted = convertRendererSymbol(defaultSymbol, warn, variables);
|
|
133
155
|
// A default symbol that fails conversion still overrides the first-entry
|
|
134
156
|
// fallback: every property defaults to "transparent" (legacy behavior).
|
|
135
157
|
return { defaultStyle: converted ? { paint: converted.paint, layout: converted.layout } : {} };
|
|
@@ -137,6 +159,138 @@ function defaultStyleFromSymbol(defaultSymbol, warn) {
|
|
|
137
159
|
function compileRendererObject(renderer) {
|
|
138
160
|
// The descriptor carries the symbol-derived layer type, so the geometry
|
|
139
161
|
// argument is inert here; "polygon" is an arbitrary stand-in.
|
|
140
|
-
const [fragment] = renderer.toMapLibre("polygon");
|
|
141
|
-
return {
|
|
162
|
+
const [fragment, ...additional] = renderer.toMapLibre("polygon");
|
|
163
|
+
return {
|
|
164
|
+
layerType: fragment.type,
|
|
165
|
+
paint: fragment.paint,
|
|
166
|
+
layout: fragment.layout,
|
|
167
|
+
...(additional.length
|
|
168
|
+
? { additionalLayers: additional.map((f) => ({ layerType: f.type, paint: f.paint, layout: f.layout })) }
|
|
169
|
+
: {}),
|
|
170
|
+
...(renderer.visualVariableLegends?.().length
|
|
171
|
+
? { visualVariableLegends: [...renderer.visualVariableLegends()] }
|
|
172
|
+
: {}),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function applyVisualVariables(base, renderer, warn, options) {
|
|
176
|
+
const variables = compileVisualVariables(renderer.visualVariables, base?.layerType ?? "unknown", base?.paint ?? {}, warn, options, ...outlineFromRenderer(renderer, options, warn));
|
|
177
|
+
if (!base)
|
|
178
|
+
return undefined;
|
|
179
|
+
const paint = { ...base.paint, ...variables.paint };
|
|
180
|
+
return {
|
|
181
|
+
...base,
|
|
182
|
+
paint,
|
|
183
|
+
...(variables.outline ? { additionalLayers: [{ layerType: "line", ...variables.outline }] } : {}),
|
|
184
|
+
...(variables.legends.length ? { visualVariableLegends: variables.legends } : {}),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function warnRendererSemantics(renderer, warn) {
|
|
188
|
+
for (const property of ["valueExpression", "normalizationField", "normalizationType", "normalizationTotal"]) {
|
|
189
|
+
if (renderer[property] != null && renderer[property] !== "")
|
|
190
|
+
warn
|
|
191
|
+
.child(property)
|
|
192
|
+
.warn("unsupported-renderer-semantics", `Renderer ${property} is unsupported; the base field renderer is a fallback that requires review.`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function convertRendererSymbol(symbol, warn, variables) {
|
|
196
|
+
const result = convertSymbol(symbol, warn);
|
|
197
|
+
if (!result || !symbol || !Array.isArray(variables) || variables.length === 0)
|
|
198
|
+
return result;
|
|
199
|
+
const colorProperty = { fill: "fill-color", line: "line-color", circle: "circle-color" }[result.layerType];
|
|
200
|
+
const color = symbol.color;
|
|
201
|
+
if (colorProperty && Array.isArray(color) && color.length === 4) {
|
|
202
|
+
result.paint[colorProperty] = `rgba(${color[0]},${color[1]},${color[2]},${Number(color[3]) / 255})`;
|
|
203
|
+
if (result.layerType === "fill")
|
|
204
|
+
delete result.paint["fill-opacity"];
|
|
205
|
+
}
|
|
206
|
+
for (const property of ["line-width", "circle-radius", "circle-stroke-width"]) {
|
|
207
|
+
if (typeof result.paint[property] === "number")
|
|
208
|
+
result.paint[property] = (result.paint[property] * 96) / 72;
|
|
209
|
+
}
|
|
210
|
+
const outline = symbol.outline;
|
|
211
|
+
const outlineColor = outline?.color;
|
|
212
|
+
if (Array.isArray(outlineColor) && outlineColor.length === 4) {
|
|
213
|
+
const property = result.layerType === "fill" ? "fill-outline-color" : "circle-stroke-color";
|
|
214
|
+
result.paint[property] =
|
|
215
|
+
`rgba(${outlineColor[0]},${outlineColor[1]},${outlineColor[2]},${Number(outlineColor[3]) / 255})`;
|
|
216
|
+
}
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
function outlineFromRenderer(renderer, options, warn) {
|
|
220
|
+
const variables = renderer.visualVariables;
|
|
221
|
+
if (!Array.isArray(variables) || !variables.some((v) => v?.type === "sizeInfo" && v?.target === "outline"))
|
|
222
|
+
return [0, {}];
|
|
223
|
+
const symbols = renderer.type === "simple"
|
|
224
|
+
? [{ symbol: renderer.symbol, path: "symbol" }]
|
|
225
|
+
: renderer.type === "classBreaks"
|
|
226
|
+
? (renderer.classBreakInfos ?? []).map((entry, i) => ({
|
|
227
|
+
symbol: entry.symbol,
|
|
228
|
+
path: `classBreakInfos[${i}].symbol`,
|
|
229
|
+
}))
|
|
230
|
+
: (renderer.uniqueValueInfos ?? []).map((entry, i) => ({
|
|
231
|
+
symbol: entry.symbol,
|
|
232
|
+
path: `uniqueValueInfos[${i}].symbol`,
|
|
233
|
+
}));
|
|
234
|
+
if (renderer.defaultSymbol)
|
|
235
|
+
symbols.push({ symbol: renderer.defaultSymbol, path: "defaultSymbol" });
|
|
236
|
+
const styles = symbols.map(({ symbol, path }) => ({
|
|
237
|
+
style: symbol?.outline?.style ?? "esriSLSSolid",
|
|
238
|
+
path,
|
|
239
|
+
}));
|
|
240
|
+
const firstStyle = styles[0]?.style ?? "esriSLSSolid";
|
|
241
|
+
const paint = {};
|
|
242
|
+
for (const { style, path } of styles) {
|
|
243
|
+
if (style !== firstStyle || (style !== "esriSLSSolid" && !esriLineStyleToDashArray(style))) {
|
|
244
|
+
warn
|
|
245
|
+
.child(`${path}.outline.style`)
|
|
246
|
+
.warn("unsupported-renderer-semantics", "Varying or unknown polygon outline dash styles require separate layers; review the converted outline style.");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (firstStyle === "esriSLSNull")
|
|
250
|
+
paint["line-opacity"] = 0;
|
|
251
|
+
else {
|
|
252
|
+
const dash = esriLineStyleToDashArray(firstStyle);
|
|
253
|
+
if (dash)
|
|
254
|
+
paint["line-dasharray"] = dash;
|
|
255
|
+
}
|
|
256
|
+
const width = (symbol) => {
|
|
257
|
+
const outline = symbol?.outline;
|
|
258
|
+
return typeof outline?.width === "number" ? (outline.width * 96) / 72 : 0;
|
|
259
|
+
};
|
|
260
|
+
if (renderer.type === "simple")
|
|
261
|
+
return [width(renderer.symbol), paint];
|
|
262
|
+
if (renderer.type === "classBreaks") {
|
|
263
|
+
const input = renderer;
|
|
264
|
+
if (!input.field || !input.classBreakInfos?.length)
|
|
265
|
+
return [width(input.defaultSymbol), paint];
|
|
266
|
+
return [
|
|
267
|
+
classBreaksRenderer({
|
|
268
|
+
field: bindRendererField(input.field, options),
|
|
269
|
+
breaks: input.classBreakInfos.map((entry) => ({
|
|
270
|
+
min: entry.classMinValue,
|
|
271
|
+
max: entry.classMaxValue,
|
|
272
|
+
style: { paint: { "line-width": width(entry.symbol) } },
|
|
273
|
+
})),
|
|
274
|
+
...(input.defaultSymbol ? { defaultStyle: { paint: { "line-width": width(input.defaultSymbol) } } } : {}),
|
|
275
|
+
}).toMapLibre("line")[0].paint["line-width"],
|
|
276
|
+
paint,
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
const input = renderer;
|
|
280
|
+
if (!input.uniqueValueInfos?.length)
|
|
281
|
+
return [width(input.defaultSymbol), paint];
|
|
282
|
+
return [
|
|
283
|
+
uniqueValueRenderer({
|
|
284
|
+
field: bindRendererField(input.field1 ?? "", options),
|
|
285
|
+
field2: input.field2 ? bindRendererField(input.field2, options) : undefined,
|
|
286
|
+
field3: input.field3 ? bindRendererField(input.field3, options) : undefined,
|
|
287
|
+
fieldDelimiter: input.fieldDelimiter,
|
|
288
|
+
values: input.uniqueValueInfos.map((entry) => ({
|
|
289
|
+
value: entry.value,
|
|
290
|
+
style: { paint: { "line-width": width(entry.symbol) } },
|
|
291
|
+
})),
|
|
292
|
+
...(input.defaultSymbol ? { defaultStyle: { paint: { "line-width": width(input.defaultSymbol) } } } : {}),
|
|
293
|
+
}).toMapLibre("line")[0].paint["line-width"],
|
|
294
|
+
paint,
|
|
295
|
+
];
|
|
142
296
|
}
|
package/webmap/index.d.ts
CHANGED
|
@@ -41,4 +41,5 @@ export type { ExtentConversionResult } from "./convert-extent.js";
|
|
|
41
41
|
export { convertOperationalLayer } from "./convert-layer.js";
|
|
42
42
|
export type { LayerConversionResult } from "./convert-layer.js";
|
|
43
43
|
export type { WebMapJson, WebMapOperationalLayer, WebMapRenderer, WebMapSimpleRenderer, WebMapUniqueValueRenderer, WebMapClassBreaksRenderer, WebMapSymbol, WebMapSimpleFillSymbol, WebMapSimpleLineSymbol, WebMapSimpleMarkerSymbol, WebMapPictureMarkerSymbol, WebMapTextSymbol, WebMapBaseMap, WebMapBaseMapLayer, WebMapPopupInfo, WebMapFieldInfo, WebMapExtent, WebMapPoint, WebMapViewpoint, WebMapViewpointTargetGeometry, WebMapInitialState, WebMapBookmark, WebMapSpatialReference, WebMapLabelClass, WebMapDrawingInfo, WebMapLayerDefinition, EsriColor, } from "./types.js";
|
|
44
|
+
export type { RendererConversionOptions, VisualVariableLegend } from "../style/visual-variables.js";
|
|
44
45
|
//# sourceMappingURL=index.d.ts.map
|
package/webmap/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/webmap/index.ts"],"names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AACrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EACV,UAAU,EACV,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,WAAW,EACX,eAAe,EACf,6BAA6B,EAC7B,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/webmap/parse.d.ts
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type { HonuaStyleSpecification } from "../style/specification.js";
|
|
7
|
+
import type { RendererConversionOptions } from "../style/visual-variables.js";
|
|
7
8
|
import type { HonuaPopupConfig } from "./convert-popup.js";
|
|
8
9
|
import type { WebMapBookmark, WebMapJson } from "./types.js";
|
|
9
10
|
import { type WebMapWarning } from "./warnings.js";
|
|
10
|
-
export interface ParseWebMapOptions {
|
|
11
|
+
export interface ParseWebMapOptions extends RendererConversionOptions {
|
|
11
12
|
/** If true, include basemap layers. Defaults to true. */
|
|
12
13
|
includeBasemap?: boolean;
|
|
13
14
|
}
|