passerelle-geo-components 0.2.0-alpha.2 → 0.2.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/geo-components.js +32 -6
  2. package/package.json +1 -1
package/geo-components.js CHANGED
@@ -232,6 +232,9 @@ function _v031ToLegacyShim(params, hostContext) {
232
232
  const overrides = [];
233
233
  for (const l of params.layers) {
234
234
  const geojson = l.source && l.source.type === "geojson" ? l.source.data : null;
235
+ const style = l.style || {};
236
+ const interactions = l.interactions || {};
237
+ const classifShim = _v031ClassificationShim(style.classification);
235
238
  catalog.push({
236
239
  id: l.id,
237
240
  name: l.name,
@@ -239,18 +242,16 @@ function _v031ToLegacyShim(params, hostContext) {
239
242
  geojson,
240
243
  n_features: l.n_features,
241
244
  bbox: l.bbox,
242
- classification: l.style && l.style.classification,
243
- outline: l.style && l.style.outline,
244
- hollow_point: l.style && l.style.hollow_point
245
+ classification: classifShim,
246
+ outline: style.outline,
247
+ hollow_point: style.hollow_point
245
248
  });
246
- const style = l.style || {};
247
- const interactions = l.interactions || {};
248
249
  overrides.push({
249
250
  layer_id_ref: l.id,
250
251
  visible: style.visible !== false,
251
252
  z_index: style.z_index,
252
253
  opacity: typeof style.opacity === "object" ? undefined : style.opacity,
253
- classification: style.classification,
254
+ classification: classifShim,
254
255
  outline: style.outline,
255
256
  hollow_point: style.hollow_point,
256
257
  popup_template: interactions.popup_template,
@@ -266,6 +267,31 @@ function _v031ToLegacyShim(params, hostContext) {
266
267
  return { params: shimParams, hostContext: shimHost };
267
268
  }
268
269
 
270
+ // V0.3.1 classification : {color: {mode, field, method, breaks, palette,
271
+ // _compiled_expression}, size, label} -> {paint_expression, method, field, ...}
272
+ // attendus par _paintForClassification (V1.13).
273
+ function _v031ClassificationShim(classif) {
274
+ if (!classif) return null;
275
+ // Deja au format V1.13 (paint_expression direct) -> passthrough
276
+ if (classif.paint_expression) return classif;
277
+ // V0.3.1 nested {color: {...}}
278
+ const color = classif.color || classif;
279
+ if (!color || !color.mode) return classif;
280
+ const out = {
281
+ method: color.method || color.mode,
282
+ field: color.field
283
+ };
284
+ // Priorite : expression MapLibre pre-compilee dans _compiled_expression
285
+ if (Array.isArray(color._compiled_expression)) {
286
+ out.paint_expression = color._compiled_expression;
287
+ } else if (color.mode === "single" && color.value) {
288
+ out.paint_expression = color.value;
289
+ } else if (color.mode === "expression" && Array.isArray(color.expression)) {
290
+ out.paint_expression = color.expression;
291
+ }
292
+ return out;
293
+ }
294
+
269
295
  /**
270
296
  * Résout la zone d'étude en {center, zoom, bbox} exploitables par MapLibre.
271
297
  * Supporte les 3 modes du contrat V1.13 : commune | manual | study.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passerelle-geo-components",
3
- "version": "0.2.0-alpha.2",
3
+ "version": "0.2.0-alpha.3",
4
4
  "description": "Web Components pour cartes MapLibre + composants controllers pilotes - brique commune multi-projet avec contract SceneManifest V0.3.1. Zero dependance runtime, ES module, encapsulation Shadow DOM.",
5
5
  "type": "module",
6
6
  "main": "geo-components.js",