1// modules/layerregistry.js 2// Registre centralisé des groupes de couches et alias 3 4;(function(win) { 5 'use strict'; 6 7 // Ensemble des couches liées aux Travaux (style + interactions communes) 8 const TravauxLayers = new Set([ 9 'travaux', 10 'city-travaux-chantiers', 11 'open data travaux' 12 ]); 13 14 // Ensemble des couches PLU / Emplacements réservés 15 const PluLayers = new Set([ 16 'emplacementReserve' 17 ]); 18 19 // Ensemble des couches Métro / Funiculaire 20 const MetroLayers = new Set([ 21 'metroFuniculaire' 22 ]); 23 24 const VeloLayers = new Set([ 25 'velo' 26 ]); 27 28 const BusLayers = new Set([ 29 'bus' 30 ]); 31 32 const TramLayers = new Set([ 33 'tramway' 34 ]); 35 36 const PathTooltipDisabledLayers = new Set([ 37 'planVelo', 38 'amenagementCyclable' 39 ]); 40 41 const NoInteractLayers = new Set([ 42 'planVelo', 43 'amenagementCyclable' 44 ]); 45 46 function isTravauxLayer(name) { 47 return !!name && TravauxLayers.has(name); 48 } 49 50 function isPluLayer(name) { 51 return !!name && PluLayers.has(name); 52 } 53 54 function isMetroLayer(name) { 55 return !!name && MetroLayers.has(name); 56 } 57 58 function isVeloLayer(name) { 59 return !!name && VeloLayers.has(name); 60 } 61 62 function isBusLayer(name) { 63 return !!name && BusLayers.has(name); 64 } 65 66 function isTramLayer(name) { 67 return !!name && TramLayers.has(name); 68 } 69 70 function supportsPathTooltip(name) { 71 return !!name && !PathTooltipDisabledLayers.has(name); 72 } 73 74 function isNoInteractLayer(name) { 75 return !!name && NoInteractLayers.has(name); 76 } 77 78 function formatTooltipTitle(layerName, props, title) { 79 if (isVeloLayer(layerName) && props && props.project_name && !String(title || '').startsWith('Voie Lyonnaise')) { 80 return `Voie Lyonnaise ${props.project_name}`; 81 } 82 return title; 83 } 84 85 function getPathTooltipHtml(layerName, props, esc, fallbackTitle, fallbackLayerName) { 86 const safeEsc = typeof esc === 'function' ? esc : ((s) => String(s || '')); 87 const p = props || {}; 88 89 if (isBusLayer(layerName)) { 90 const val = p.bus || p.BUS || p.Bus || ''; 91 return `<div class="gp-tt-body">${safeEsc(`bus ${val}`)}</div>`; 92 } 93 94 if (isMetroLayer(layerName)) { 95 const ligne = p.ligne || p.LIGNE || p.Line || ''; 96 const upper = String(ligne).toUpperCase(); 97 const isFuni = upper === 'F1' || upper === 'F2'; 98 const label = isFuni ? `Funiculaire ${ligne}` : `Métro ${ligne}`; 99 return `<div class="gp-tt-body">${safeEsc(label)}</div>`; 100 } 101 102 if (isTramLayer(layerName)) { 103 const val = p.tramway || p.ligne || p.LIGNE || ''; 104 return `<div class="gp-tt-body">${safeEsc(`Tramway ${val}`)}</div>`; 105 } 106 107 if (isPluLayer(layerName)) { 108 const raw = (p.type ?? p.TYPE ?? p.Type ?? p.libelle ?? p.LIBELLE ?? p.code ?? p.CODE ?? p.typologie ?? '').toString().trim(); 109 const normalizeKey = (s) => s 110 .normalize('NFD').replace(/[\u0300-\u036f]/g, '') 111 .toUpperCase() 112 .replace(/[^A-Z]/g, ''); 113 const key = normalizeKey(raw); 114 const map = { 115 'ELARVOIE': 'Ãlargissement de voirie', 116 'CREAVOIE': 'Création de voirie', 117 'CARREF': 'Aménagement de carrefour', 118 'EQUIPUBL': 'Ãquipements publics', 119 'MAILPLANTE': 'Mail planté / espace vert', 120 'ELARGVOIE': 'Ãlargissement de voirie' 121 }; 122 const label = map[key] || raw || ''; 123 return `<div class="gp-tt-body">${safeEsc(`Objectif : ${label}`)}</div>`; 124 } 125 126 const title = fallbackTitle || ''; 127 return title 128 ? `<div class="gp-tt-title">${safeEsc(title)}</div>` 129 : `<div class="gp-tt-body">${safeEsc(fallbackLayerName || layerName || '')}</div>`; 130 } 131 132 function addTravauxAlias(name) { 133 if (name && typeof name === 'string') { 134 TravauxLayers.add(name); 135 } 136 } 137 138 function addPluAlias(name) { 139 if (name && typeof name === 'string') { 140 PluLayers.add(name); 141 } 142 } 143 144 function addMetroAlias(name) { 145 if (name && typeof name === 'string') { 146 MetroLayers.add(name); 147 } 148 } 149 150 function addVeloAlias(name) { 151 if (name && typeof name === 'string') { 152 VeloLayers.add(name); 153 } 154 } 155 156 function addBusAlias(name) { 157 if (name && typeof name === 'string') { 158 BusLayers.add(name); 159 } 160 } 161 162 function addTramAlias(name) { 163 if (name && typeof name === 'string') { 164 TramLayers.add(name); 165 } 166 } 167 168 function disablePathTooltipForLayer(name) { 169 if (name && typeof name === 'string') { 170 PathTooltipDisabledLayers.add(name); 171 } 172 } 173 174 function addNoInteractAlias(name) { 175 if (name && typeof name === 'string') { 176 NoInteractLayers.add(name); 177 } 178 } 179 180 function listTravaux() { 181 return Array.from(TravauxLayers); 182 } 183 184 function listPlu() { 185 return Array.from(PluLayers); 186 } 187 188 function listMetro() { 189 return Array.from(MetroLayers); 190 } 191 192 function listVelo() { 193 return Array.from(VeloLayers); 194 } 195 196 function listBus() { 197 return Array.from(BusLayers); 198 } 199 200 function listTram() { 201 return Array.from(TramLayers); 202 } 203 204 // Expose API 205 win.LayerRegistry = win.LayerRegistry || {}; 206 win.LayerRegistry.isTravauxLayer = isTravauxLayer; 207 win.LayerRegistry.addTravauxAlias = addTravauxAlias; 208 win.LayerRegistry.listTravaux = listTravaux; 209 210 win.LayerRegistry.isPluLayer = isPluLayer; 211 win.LayerRegistry.addPluAlias = addPluAlias; 212 win.LayerRegistry.listPlu = listPlu; 213 214 win.LayerRegistry.isMetroLayer = isMetroLayer; 215 win.LayerRegistry.addMetroAlias = addMetroAlias; 216 win.LayerRegistry.listMetro = listMetro; 217 218 win.LayerRegistry.isVeloLayer = isVeloLayer; 219 win.LayerRegistry.addVeloAlias = addVeloAlias; 220 win.LayerRegistry.listVelo = listVelo; 221 222 win.LayerRegistry.isBusLayer = isBusLayer;
223 win.LayerRegistry.addBusAlias = addBusAlias; 224 win.LayerRegistry.listBus = listBus; 225 226 win.LayerRegistry.isTramLayer = isTramLayer; 227 win.LayerRegistry.addTramAlias = addTramAlias; 228 win.LayerRegistry.listTram = listTram; 229 230 win.LayerRegistry.supportsPathTooltip = supportsPathTooltip; 231 win.LayerRegistry.disablePathTooltipForLayer = disablePathTooltipForLayer; 232 233 win.LayerRegistry.isNoInteractLayer = isNoInteractLayer; 234 win.LayerRegistry.addNoInteractAlias = addNoInteractAlias; 235 236 win.LayerRegistry.formatTooltipTitle = formatTooltipTitle; 237 win.LayerRegistry.getPathTooltipHtml = getPathTooltipHtml; 238 239})(window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.