|
| 1 | +import React from 'react'; |
| 2 | +import { Source, Layer } from 'react-map-gl'; |
| 3 | + |
| 4 | +function Panels() { |
| 5 | + const blueprintPrefix = ''; |
| 6 | + const filter = [ |
| 7 | + 'all', |
| 8 | + ['in', 'type_if', 'CHEVRON', 'R', 'TIV D FIXE', 'TIVD C FIX', 'TIVD B FIX', 'Z'], |
| 9 | + ]; |
| 10 | + |
| 11 | + const panelParams = { |
| 12 | + id: 'panelParams', |
| 13 | + type: 'symbol', |
| 14 | + source: 'signalisation', |
| 15 | + 'source-layer': 'signalisation_angles', |
| 16 | + minzoom: 10, |
| 17 | + filter, |
| 18 | + layout: { |
| 19 | + 'text-font': ['Open Sans Regular'], |
| 20 | + 'text-size': 9, |
| 21 | + 'icon-image': [ |
| 22 | + 'case', |
| 23 | + ['==', ['get', 'type_if'], 'CHEVRON'], |
| 24 | + ['concat', blueprintPrefix, 'CHEVRON BAS'], |
| 25 | + ['==', ['get', 'type_if'], 'DESTI'], |
| 26 | + ['concat', blueprintPrefix, 'VIDE'], |
| 27 | + ['==', ['get', 'type_if'], 'DIVERS'], |
| 28 | + ['concat', blueprintPrefix, 'VIDE'], |
| 29 | + ['==', ['get', 'type_if'], 'IDD'], |
| 30 | + ['case', ['==', ['get', 'position'], 'D'], 'IDD GAUCHE', 'IDD DROIT'], |
| 31 | + ['==', ['get', 'type_if'], 'JAL ARRET'], |
| 32 | + ['concat', blueprintPrefix, 'JAL ARR'], |
| 33 | + ['==', ['get', 'type_if'], 'TECS'], |
| 34 | + [ |
| 35 | + 'case', |
| 36 | + ['==', ['get', 'position'], 'D'], |
| 37 | + ['concat', blueprintPrefix, 'TECS G'], |
| 38 | + ['concat', blueprintPrefix, 'TECS D'], |
| 39 | + ], |
| 40 | + ['==', ['get', 'type_if'], 'TSCS'], |
| 41 | + [ |
| 42 | + 'case', |
| 43 | + ['==', ['get', 'position'], 'D'], |
| 44 | + ['concat', blueprintPrefix, 'TSCS G'], |
| 45 | + ['concat', blueprintPrefix, 'TSCS D'], |
| 46 | + ], |
| 47 | + ['==', ['get', 'type_if'], 'TIV D FIXE'], |
| 48 | + ['concat', blueprintPrefix, 'TIV D FIXE 60'], |
| 49 | + ['==', ['get', 'type_if'], 'TIV R FIXE'], |
| 50 | + ['concat', blueprintPrefix, 'TIV R FIXE 60'], |
| 51 | + ['==', ['get', 'type_if'], 'TIV D MOB'], |
| 52 | + ['concat', blueprintPrefix, 'TIV D MOB 60'], |
| 53 | + ['==', ['get', 'type_if'], 'TIV R MOB'], |
| 54 | + ['concat', blueprintPrefix, 'TIV R MOB 60'], |
| 55 | + ['==', ['get', 'type_if'], 'TIVD B FIX'], |
| 56 | + ['concat', blueprintPrefix, 'TIVD B FIX 60'], |
| 57 | + ['==', ['get', 'type_if'], 'ARRET VOY'], |
| 58 | + ['concat', blueprintPrefix, 'ARRET VOY TT'], |
| 59 | + ['==', ['get', 'type_if'], 'GARE'], |
| 60 | + 'GARE', |
| 61 | + ['==', ['get', 'type_if'], 'SECT'], |
| 62 | + 'SECT', |
| 63 | + ['==', ['get', 'type_if'], 'ARRET'], |
| 64 | + 'ARRET', |
| 65 | + ['==', ['get', 'type_if'], 'ARRET A'], |
| 66 | + 'ARRET A', |
| 67 | + ['==', ['get', 'type_if'], 'IMP'], |
| 68 | + 'IMP', |
| 69 | + ['==', ['get', 'type_if'], 'BP EXE'], |
| 70 | + 'BP EXE', |
| 71 | + ['==', ['get', 'type_if'], 'BP FIN'], |
| 72 | + 'BP FIN', |
| 73 | + ['==', ['get', 'type_if'], 'APPROETSA'], |
| 74 | + 'APPROETSA', |
| 75 | + ['==', ['get', 'type_if'], 'P'], |
| 76 | + 'P', |
| 77 | + ['==', ['get', 'type_if'], 'PN'], |
| 78 | + 'PN', |
| 79 | + ['==', ['get', 'type_if'], 'PN...'], |
| 80 | + 'PN...', |
| 81 | + ['concat', blueprintPrefix, ['get', 'type_if']], |
| 82 | + ], |
| 83 | + 'icon-size': ['step', ['zoom'], 0.3, 15, 0.4], |
| 84 | + 'text-offset': [ |
| 85 | + 'step', |
| 86 | + ['zoom'], |
| 87 | + ['literal', [1.5, 0]], |
| 88 | + 15, |
| 89 | + [ |
| 90 | + 'case', |
| 91 | + ['==', ['get', 'position'], 'D'], |
| 92 | + ['literal', [4, -1]], |
| 93 | + ['==', ['get', 'position'], 'G'], |
| 94 | + ['literal', [-4, -1]], |
| 95 | + ['literal', [4, 0]], |
| 96 | + ], |
| 97 | + ], |
| 98 | + 'icon-offset': [ |
| 99 | + 'step', |
| 100 | + ['zoom'], |
| 101 | + ['literal', [1.5, 0]], |
| 102 | + 15, |
| 103 | + [ |
| 104 | + 'case', |
| 105 | + ['==', ['get', 'position'], 'D'], |
| 106 | + ['literal', [80, -100]], |
| 107 | + ['==', ['get', 'position'], 'G'], |
| 108 | + ['literal', [-80, -100]], |
| 109 | + ['literal', [0, 0]], |
| 110 | + ], |
| 111 | + ], |
| 112 | + 'icon-rotation-alignment': 'map', |
| 113 | + 'text-rotation-alignment': 'map', |
| 114 | + 'icon-rotate': ['get', 'angle'], |
| 115 | + 'text-rotate': ['get', 'angle'], |
| 116 | + 'icon-allow-overlap': true, |
| 117 | + 'text-allow-overlap': true, |
| 118 | + 'icon-ignore-placement': false, |
| 119 | + 'text-justify': [ |
| 120 | + 'case', |
| 121 | + ['==', ['get', 'position'], 'D'], |
| 122 | + 'left', |
| 123 | + ['==', ['get', 'position'], 'G'], |
| 124 | + 'right', |
| 125 | + 'center', |
| 126 | + ], |
| 127 | + 'text-anchor': [ |
| 128 | + 'case', |
| 129 | + ['==', ['get', 'position'], 'D'], |
| 130 | + 'left', |
| 131 | + ['==', ['get', 'position'], 'G'], |
| 132 | + 'right', |
| 133 | + 'center', |
| 134 | + ], |
| 135 | + }, |
| 136 | + }; |
| 137 | + |
| 138 | + const mastParams = { |
| 139 | + id: 'mast2', |
| 140 | + type: 'symbol', |
| 141 | + source: 'signalisation', |
| 142 | + 'source-layer': 'signalisation_angles', |
| 143 | + minzoom: 15, |
| 144 | + filter, |
| 145 | + layout: { |
| 146 | + 'text-font': ['Open Sans Regular'], |
| 147 | + 'text-size': 8, |
| 148 | + 'text-field': '', |
| 149 | + 'text-allow-overlap': true, |
| 150 | + 'text-ignore-placement': true, |
| 151 | + 'icon-image': [ |
| 152 | + 'case', |
| 153 | + ['==', ['get', 'position'], 'D'], |
| 154 | + 'MATD', |
| 155 | + ['==', ['get', 'position'], 'G'], |
| 156 | + 'MATG', |
| 157 | + '', |
| 158 | + ], |
| 159 | + 'icon-size': 1, |
| 160 | + 'icon-rotation-alignment': 'map', |
| 161 | + 'icon-rotate': ['get', 'angle'], |
| 162 | + 'icon-allow-overlap': true, |
| 163 | + 'icon-ignore-placement': true, |
| 164 | + }, |
| 165 | + }; |
| 166 | + |
| 167 | + return ( |
| 168 | + <Source |
| 169 | + id="panel" |
| 170 | + type="vector" |
| 171 | + url="https://osm.osrd.fr/data/signalisation.json" |
| 172 | + source-layer="signalisation_angles" |
| 173 | + > |
| 174 | + <Layer {...mastParams} /> |
| 175 | + <Layer {...panelParams} /> |
| 176 | + </Source> |
| 177 | + ); |
| 178 | +} |
| 179 | + |
| 180 | +export default Panels; |
0 commit comments