passerelle-geo-components 0.2.0-alpha.1 → 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.
- package/geo-components.js +116 -1
- package/package.json +1 -1
package/geo-components.js
CHANGED
|
@@ -184,9 +184,118 @@ function _detectMapLibre() {
|
|
|
184
184
|
return window.maplibregl || null;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
// V0.3.1 shim (Sprint V0.2 Chantier 7, 2026-07-10) : le contract publie
|
|
188
|
+
// SceneManifest V0.3.1 impose params.layers[] + params.basemap.id + zone
|
|
189
|
+
// discriminee (insee_arm/commune/manual/study). Le composant historique
|
|
190
|
+
// (V1.13) lit params.layers_override + _hostContext.catalog_layers +
|
|
191
|
+
// params.basemap_id. Ce shim normalise V0.3.1 vers la structure legacy
|
|
192
|
+
// interne sans casser les consommateurs V1.13.
|
|
193
|
+
const _V031_INSEE_ARM_BBOX = {
|
|
194
|
+
"13204": [5.379, 43.289, 5.427, 43.334],
|
|
195
|
+
"13201": [5.360, 43.294, 5.394, 43.309],
|
|
196
|
+
"13202": [5.363, 43.309, 5.393, 43.328],
|
|
197
|
+
"13203": [5.374, 43.311, 5.408, 43.335],
|
|
198
|
+
"75104": [2.348, 48.851, 2.365, 48.862],
|
|
199
|
+
"75105": [2.336, 48.840, 2.362, 48.856],
|
|
200
|
+
"69381": [4.827, 45.766, 4.848, 45.780]
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
function _v031ToLegacyShim(params, hostContext) {
|
|
204
|
+
if (!params || typeof params !== "object") return { params, hostContext };
|
|
205
|
+
const isV031 = params.manifest_version === "0.3.1" || Array.isArray(params.layers);
|
|
206
|
+
if (!isV031) return { params, hostContext };
|
|
207
|
+
|
|
208
|
+
const shimParams = { ...params };
|
|
209
|
+
const shimHost = { ...(hostContext || {}) };
|
|
210
|
+
|
|
211
|
+
// basemap.id -> basemap_id
|
|
212
|
+
if (params.basemap && params.basemap.id && !shimParams.basemap_id) {
|
|
213
|
+
shimParams.basemap_id = params.basemap.id;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// zone.insee_arm / zone.commune -> hostContext.commune_bbox (fallback bbox table)
|
|
217
|
+
if (params.zone && (params.zone.kind === "insee_arm" || params.zone.kind === "commune")) {
|
|
218
|
+
const bbox = _V031_INSEE_ARM_BBOX[params.zone.insee];
|
|
219
|
+
if (bbox && !shimHost.commune_bbox) {
|
|
220
|
+
shimHost.commune_bbox = bbox;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// zone.kind bbox custom : mapper en manual
|
|
225
|
+
if (params.zone && params.zone.bbox && !params.zone.kind) {
|
|
226
|
+
shimParams.zone = { ...params.zone, kind: "manual" };
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// layers[] V0.3.1 -> catalog_layers[] + layers_override[]
|
|
230
|
+
if (Array.isArray(params.layers) && !shimHost.catalog_layers && !shimParams._catalog_layers) {
|
|
231
|
+
const catalog = [];
|
|
232
|
+
const overrides = [];
|
|
233
|
+
for (const l of params.layers) {
|
|
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);
|
|
238
|
+
catalog.push({
|
|
239
|
+
id: l.id,
|
|
240
|
+
name: l.name,
|
|
241
|
+
geometry_type: l.geometry_type,
|
|
242
|
+
geojson,
|
|
243
|
+
n_features: l.n_features,
|
|
244
|
+
bbox: l.bbox,
|
|
245
|
+
classification: classifShim,
|
|
246
|
+
outline: style.outline,
|
|
247
|
+
hollow_point: style.hollow_point
|
|
248
|
+
});
|
|
249
|
+
overrides.push({
|
|
250
|
+
layer_id_ref: l.id,
|
|
251
|
+
visible: style.visible !== false,
|
|
252
|
+
z_index: style.z_index,
|
|
253
|
+
opacity: typeof style.opacity === "object" ? undefined : style.opacity,
|
|
254
|
+
classification: classifShim,
|
|
255
|
+
outline: style.outline,
|
|
256
|
+
hollow_point: style.hollow_point,
|
|
257
|
+
popup_template: interactions.popup_template,
|
|
258
|
+
tooltip_field: interactions.tooltip_field,
|
|
259
|
+
hover_attributes: interactions.hover_attributes,
|
|
260
|
+
name_override: l.name
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
shimHost.catalog_layers = catalog;
|
|
264
|
+
shimParams.layers_override = [...(params.layers_override || []), ...overrides];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return { params: shimParams, hostContext: shimHost };
|
|
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
|
+
|
|
187
295
|
/**
|
|
188
296
|
* Résout la zone d'étude en {center, zoom, bbox} exploitables par MapLibre.
|
|
189
297
|
* Supporte les 3 modes du contrat V1.13 : commune | manual | study.
|
|
298
|
+
* V0.3.1 : accepte aussi kind='insee_arm' via le shim _v031ToLegacyShim.
|
|
190
299
|
* Pour "commune" et "study", nécessite une résolution externe (fournie via
|
|
191
300
|
* config.resolveZone) sinon fallback sur defaults.
|
|
192
301
|
*/
|
|
@@ -214,7 +323,7 @@ function _resolveZone(zoneConfig, hostContext) {
|
|
|
214
323
|
};
|
|
215
324
|
}
|
|
216
325
|
|
|
217
|
-
if (kind === "commune" && hostContext?.commune_bbox) {
|
|
326
|
+
if ((kind === "commune" || kind === "insee_arm") && hostContext?.commune_bbox) {
|
|
218
327
|
const [w, s, e, n] = hostContext.commune_bbox;
|
|
219
328
|
return {
|
|
220
329
|
center: [(w + e) / 2, (s + n) / 2],
|
|
@@ -962,6 +1071,12 @@ export class GeoMap extends HTMLElement {
|
|
|
962
1071
|
}
|
|
963
1072
|
|
|
964
1073
|
_initMap(ml, container, params) {
|
|
1074
|
+
// V0.3.1 shim (Chantier 7) : normalise SceneManifest V0.3.1 vers la
|
|
1075
|
+
// structure interne V1.13 attendue par le reste du _initMap.
|
|
1076
|
+
const shim = _v031ToLegacyShim(params, this._hostContext);
|
|
1077
|
+
params = shim.params;
|
|
1078
|
+
this._hostContext = shim.hostContext;
|
|
1079
|
+
|
|
965
1080
|
// Résolution zone
|
|
966
1081
|
const zone = _resolveZone(params.zone, this._hostContext);
|
|
967
1082
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passerelle-geo-components",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
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",
|