|
| 1 | +import React, { useEffect, useState } from "react"; |
| 2 | +import { TopicMapContextProvider } from "../../contexts/TopicMapContextProvider"; |
| 3 | +import FeatureCollection from "../../FeatureCollection"; |
| 4 | +import TopicMapComponent from "../../topicmaps/TopicMapComponent"; |
| 5 | +import MapLibreLayer from "../../vector/MapLibreLayer"; |
| 6 | +import { getGazData } from "./StoriesConf"; |
| 7 | +import { defaultLayerConf } from "../../tools/layerFactory"; |
| 8 | + |
| 9 | +export const TopicMapWithOfflineDataConfiguration = () => { |
| 10 | + const [gazData, setGazData] = useState([]); |
| 11 | + useEffect(() => { |
| 12 | + getGazData(setGazData); |
| 13 | + }, []); |
| 14 | + |
| 15 | + const offlineConfig = { |
| 16 | + rules: [ |
| 17 | + { |
| 18 | + origin: "https://omt.map-hosting.de/fonts/Metropolis Medium Italic,Noto", |
| 19 | + cachePath: "fonts/Open", |
| 20 | + }, |
| 21 | + { |
| 22 | + origin: "https://omt.map-hosting.de/fonts/Klokantech Noto", |
| 23 | + cachePath: "fonts/Open", |
| 24 | + }, |
| 25 | + { |
| 26 | + origin: "https://omt.map-hosting.de/fonts", |
| 27 | + cachePath: "fonts", |
| 28 | + }, |
| 29 | + { |
| 30 | + origin: "https://omt.map-hosting.de/styles", |
| 31 | + cachePath: "styles", |
| 32 | + }, |
| 33 | + |
| 34 | + { |
| 35 | + origin: "https://omt.map-hosting.de/data/v3", |
| 36 | + cachePath: "tiles", |
| 37 | + }, |
| 38 | + |
| 39 | + { |
| 40 | + origin: "https://omt.map-hosting.de/data/gewaesser", |
| 41 | + cachePath: "tiles.gewaesser", |
| 42 | + }, |
| 43 | + |
| 44 | + { |
| 45 | + origin: "https://omt.map-hosting.de/data/kanal", |
| 46 | + cachePath: "tiles.kanal", |
| 47 | + }, |
| 48 | + |
| 49 | + { |
| 50 | + origin: "https://omt.map-hosting.de/data/brunnen", |
| 51 | + cachePath: "tiles.brunnen", |
| 52 | + // realServerFallback: true, //this can override the globalsetting |
| 53 | + }, |
| 54 | + ], |
| 55 | + dataStores: [ |
| 56 | + { |
| 57 | + name: "Vektorkarte für Wuppertal", |
| 58 | + key: "wuppBasemap", |
| 59 | + url: "https://offline-data.cismet.de/offline-data/wupp.zip", |
| 60 | + }, |
| 61 | + |
| 62 | + { |
| 63 | + name: "Gewässer, Kanal und Brunnendaten", |
| 64 | + key: "umweltalarm", |
| 65 | + url: "https://offline-data.cismet.de/offline-data/umweltalarm.zip", |
| 66 | + }, |
| 67 | + ], |
| 68 | + offlineStyles: [ |
| 69 | + "https://omt.map-hosting.de/styles/cismet-light/style.json", |
| 70 | + "https://omt.map-hosting.de/styles/osm-bright-grey/style.json", |
| 71 | + "https://omt.map-hosting.de/styles/brunnen/style.json", |
| 72 | + "https://omt.map-hosting.de/styles/kanal/style.json", |
| 73 | + "https://omt.map-hosting.de/styles/gewaesser/style.json", |
| 74 | + ], |
| 75 | + realServerFallback: true, //should be true in production |
| 76 | + consoleDebug: false, |
| 77 | + optional: true, |
| 78 | + initialActive: true, |
| 79 | + }; |
| 80 | + |
| 81 | + const backgroundConfigurations = { |
| 82 | + lbk: { |
| 83 | + layerkey: "rvrGrau@50|trueOrtho2020@40", |
| 84 | + src: "/images/rain-hazard-map-bg/ortho.png", |
| 85 | + title: "Luftbildkarte", |
| 86 | + }, |
| 87 | + |
| 88 | + vectorCityMap2: { |
| 89 | + layerkey: "cismetLight", |
| 90 | + src: "/images/rain-hazard-map-bg/citymap.png", |
| 91 | + title: "Stadtplan", |
| 92 | + }, |
| 93 | + |
| 94 | + vectorCityMap: { |
| 95 | + layerkey: "osmBrightOffline", |
| 96 | + src: "/images/rain-hazard-map-bg/citymap.png", |
| 97 | + title: "Stadtplan", |
| 98 | + }, |
| 99 | + |
| 100 | + abkg: { |
| 101 | + layerkey: "bplan_abkg@70", |
| 102 | + src: "/images/rain-hazard-map-bg/citymap.png", |
| 103 | + title: "Amtliche Basiskarte", |
| 104 | + }, |
| 105 | + stadtplan: { |
| 106 | + layerkey: "wupp-plan-live@90", |
| 107 | + src: "/images/rain-hazard-map-bg/citymap.png", |
| 108 | + title: "Stadtplan", |
| 109 | + }, |
| 110 | + nix: { |
| 111 | + layerkey: "empty", |
| 112 | + src: "/images/rain-hazard-map-bg/citymap.png", |
| 113 | + title: "Stadtplan", |
| 114 | + }, |
| 115 | + }; |
| 116 | + |
| 117 | + const backgroundModes = [ |
| 118 | + { |
| 119 | + title: "Stadtplan", |
| 120 | + mode: "default", |
| 121 | + layerKey: "stadtplan", |
| 122 | + }, |
| 123 | + { |
| 124 | + title: "Stadtplan (bunt)", |
| 125 | + mode: "default", |
| 126 | + layerKey: "vectorCityMap", |
| 127 | + offlineDataStoreKey: "wuppBasemap", |
| 128 | + }, |
| 129 | + { |
| 130 | + title: "Stadtplan (light)", |
| 131 | + mode: "default", |
| 132 | + layerKey: "vectorCityMap2", |
| 133 | + offlineDataStoreKey: "wuppBasemap", |
| 134 | + }, |
| 135 | + |
| 136 | + { title: "Luftbildkarte", mode: "default", layerKey: "lbk" }, |
| 137 | + { title: "-", mode: "default", layerKey: "nix" }, |
| 138 | + ]; |
| 139 | + |
| 140 | + const baseLayerConf = { ...defaultLayerConf }; |
| 141 | + if (!baseLayerConf.namedLayers.cismetLight) { |
| 142 | + baseLayerConf.namedLayers.cismetLight = { |
| 143 | + type: "vector", |
| 144 | + style: "https://omt.map-hosting.de/styles/cismet-light/style.json", |
| 145 | + offlineAvailable: true, |
| 146 | + offlineDataStoreKey: "wuppBasemap", |
| 147 | + pane: "backgroundvectorLayers", |
| 148 | + }; |
| 149 | + } |
| 150 | + if (!baseLayerConf.namedLayers.osmBrightOffline) { |
| 151 | + baseLayerConf.namedLayers.osmBrightOffline = { |
| 152 | + type: "vector", |
| 153 | + style: "https://omt.map-hosting.de/styles/osm-bright-grey/style.json", |
| 154 | + offlineAvailable: true, |
| 155 | + offlineDataStoreKey: "wuppBasemap", |
| 156 | + pane: "backgroundvectorLayers", |
| 157 | + }; |
| 158 | + } |
| 159 | + |
| 160 | + return ( |
| 161 | + <TopicMapContextProvider |
| 162 | + backgroundModes={backgroundModes} |
| 163 | + backgroundConfigurations={backgroundConfigurations} |
| 164 | + baseLayerConf={baseLayerConf} |
| 165 | + offlineCacheConfig={offlineConfig} //will Handle the filling of the offline cache |
| 166 | + additionalLayerConfiguration={{ |
| 167 | + brunnen: { |
| 168 | + title: <span>Trinkwasserbrunnen</span>, |
| 169 | + initialActive: false, |
| 170 | + layer: ( |
| 171 | + <MapLibreLayer |
| 172 | + key={"brunnen"} |
| 173 | + style="https://omt.map-hosting.de/styles/brunnen/style.json" |
| 174 | + pane="additionalLayers0" |
| 175 | + offlineAvailable={true} |
| 176 | + offlineDataStoreKey="umweltalarm" |
| 177 | + /> |
| 178 | + ), |
| 179 | + offlineDataStoreKey: "umweltalarm", |
| 180 | + }, |
| 181 | + kanal: { |
| 182 | + title: <span>Kanalnetz</span>, |
| 183 | + initialActive: false, |
| 184 | + layer: ( |
| 185 | + <MapLibreLayer |
| 186 | + key={"kanal"} |
| 187 | + style="https://omt.map-hosting.de/styles/kanal/style.json" |
| 188 | + pane="additionalLayers1" |
| 189 | + offlineAvailable={true} |
| 190 | + offlineDataStoreKey="umweltalarm" |
| 191 | + /> |
| 192 | + ), |
| 193 | + offlineDataStoreKey: "umweltalarm", |
| 194 | + }, |
| 195 | + gewaesser: { |
| 196 | + title: <span>Gewässernetz</span>, |
| 197 | + initialActive: false, |
| 198 | + layer: ( |
| 199 | + <MapLibreLayer |
| 200 | + key={"gewaesser"} |
| 201 | + style="https://omt.map-hosting.de/styles/gewaesser/style.json" |
| 202 | + pane="additionalLayers2" |
| 203 | + offlineAvailable={true} |
| 204 | + offlineDataStoreKey="umweltalarm" |
| 205 | + /> |
| 206 | + ), |
| 207 | + offlineDataStoreKey: "umweltalarm", |
| 208 | + }, |
| 209 | + }} |
| 210 | + > |
| 211 | + {/* <ConsoleLog ghostModeAvailable={true} minifyAvailable={true} /> */} |
| 212 | + <TopicMapComponent gazData={gazData}> |
| 213 | + <FeatureCollection /> |
| 214 | + </TopicMapComponent> |
| 215 | + </TopicMapContextProvider> |
| 216 | + ); |
| 217 | +}; |
0 commit comments