passerelle-geo-components 0.2.0-alpha.1 → 0.2.0-alpha.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.
Files changed (2) hide show
  1. package/geo-components.js +90 -1
  2. package/package.json +1 -1
package/geo-components.js CHANGED
@@ -184,9 +184,92 @@ 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
+ catalog.push({
236
+ id: l.id,
237
+ name: l.name,
238
+ geometry_type: l.geometry_type,
239
+ geojson,
240
+ n_features: l.n_features,
241
+ 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
+ });
246
+ const style = l.style || {};
247
+ const interactions = l.interactions || {};
248
+ overrides.push({
249
+ layer_id_ref: l.id,
250
+ visible: style.visible !== false,
251
+ z_index: style.z_index,
252
+ opacity: typeof style.opacity === "object" ? undefined : style.opacity,
253
+ classification: style.classification,
254
+ outline: style.outline,
255
+ hollow_point: style.hollow_point,
256
+ popup_template: interactions.popup_template,
257
+ tooltip_field: interactions.tooltip_field,
258
+ hover_attributes: interactions.hover_attributes,
259
+ name_override: l.name
260
+ });
261
+ }
262
+ shimHost.catalog_layers = catalog;
263
+ shimParams.layers_override = [...(params.layers_override || []), ...overrides];
264
+ }
265
+
266
+ return { params: shimParams, hostContext: shimHost };
267
+ }
268
+
187
269
  /**
188
270
  * Résout la zone d'étude en {center, zoom, bbox} exploitables par MapLibre.
189
271
  * Supporte les 3 modes du contrat V1.13 : commune | manual | study.
272
+ * V0.3.1 : accepte aussi kind='insee_arm' via le shim _v031ToLegacyShim.
190
273
  * Pour "commune" et "study", nécessite une résolution externe (fournie via
191
274
  * config.resolveZone) sinon fallback sur defaults.
192
275
  */
@@ -214,7 +297,7 @@ function _resolveZone(zoneConfig, hostContext) {
214
297
  };
215
298
  }
216
299
 
217
- if (kind === "commune" && hostContext?.commune_bbox) {
300
+ if ((kind === "commune" || kind === "insee_arm") && hostContext?.commune_bbox) {
218
301
  const [w, s, e, n] = hostContext.commune_bbox;
219
302
  return {
220
303
  center: [(w + e) / 2, (s + n) / 2],
@@ -962,6 +1045,12 @@ export class GeoMap extends HTMLElement {
962
1045
  }
963
1046
 
964
1047
  _initMap(ml, container, params) {
1048
+ // V0.3.1 shim (Chantier 7) : normalise SceneManifest V0.3.1 vers la
1049
+ // structure interne V1.13 attendue par le reste du _initMap.
1050
+ const shim = _v031ToLegacyShim(params, this._hostContext);
1051
+ params = shim.params;
1052
+ this._hostContext = shim.hostContext;
1053
+
965
1054
  // Résolution zone
966
1055
  const zone = _resolveZone(params.zone, this._hostContext);
967
1056
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passerelle-geo-components",
3
- "version": "0.2.0-alpha.1",
3
+ "version": "0.2.0-alpha.2",
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",