diff --git a/Customizations/JSON/FromJSON.ts b/Customizations/JSON/FromJSON.ts index 2c37b39..f93c700 100644 --- a/Customizations/JSON/FromJSON.ts +++ b/Customizations/JSON/FromJSON.ts @@ -64,7 +64,6 @@ export class FromJSON { } public static LayoutFromJSON(json: LayoutConfigJson): Layout { - console.log(json) const tr = FromJSON.Translation; const layers = json.layers.map(FromJSON.Layer); @@ -115,7 +114,6 @@ export class FromJSON { return undefined; } const transl = new Translation(tr); - transl.addCallback(latest => console.log("tr callback changed to", latest)); return transl; } diff --git a/Logic/FilteredLayer.ts b/Logic/FilteredLayer.ts index ba994b9..ff84209 100644 --- a/Logic/FilteredLayer.ts +++ b/Logic/FilteredLayer.ts @@ -52,12 +52,20 @@ export class FilteredLayer { this._wayHandling = layerDef.wayHandling; this._showOnPopup = showOnPopup; - this._style = layerDef.style; - if (this._style === undefined) { - this._style = function () { + this._style = (tags) => { + if(layerDef.style === undefined){ return {icon: {iconUrl: "./assets/bug.svg"}, color: "#000"}; } - } + + const obj = layerDef.style(tags); + if(obj.weight && typeof (obj.weight) === "string"){ + obj.weight = Number(obj.weight);// Weight MUST be a number, otherwise leaflet does weird things. see https://github.com/Leaflet/Leaflet/issues/6075 + if(isNaN(obj.weight)){ + obj.weight = undefined; + } + } + return obj; + }; this.name = name; this.filters = layerDef.overpassFilter; this._maxAllowedOverlap = layerDef.maxAllowedOverlapPercentage; @@ -215,26 +223,26 @@ export class FilteredLayer { pointToLayer: function (feature, latLng) { const style = self._style(feature.properties); let marker; - if (style.icon === undefined) { - marker = L.circle(latLng, { - radius: 25, - color: style.color - }); + if (style.icon === undefined) { + marker = L.circle(latLng, { + radius: 25, + color: style.color + }); - } else if (style.icon.iconUrl.startsWith("$circle")) { - marker = L.circle(latLng, { - radius: 25, - color: style.color - }); - } else { - if (style.icon.iconSize === undefined) { - style.icon.iconSize = [50, 50] - } + } else if (style.icon.iconUrl.startsWith("$circle")) { + marker = L.circle(latLng, { + radius: 25, + color: style.color + }); + } else { + if (style.icon.iconSize === undefined) { + style.icon.iconSize = [50, 50] + } - marker = L.marker(latLng, { - icon: new L.icon(style.icon), - }); - } + marker = L.marker(latLng, { + icon: new L.icon(style.icon), + }); + } let eventSource = State.state.allElements.addOrGetElement(feature); const popup = L.popup({}, marker); let uiElement: UIElement; diff --git a/State.ts b/State.ts index 49ace34..47187ae 100644 --- a/State.ts +++ b/State.ts @@ -22,7 +22,7 @@ export class State { // The singleton of the global state public static state: State; - public static vNumber = "0.0.8e"; + public static vNumber = "0.0.8f"; // The user journey states thresholds when a new feature gets unlocked public static userJourney = { diff --git a/assets/layers/ghost_bike/ghost_bike.svg b/assets/layers/ghost_bike/ghost_bike.svg index 93a4b2a..0ed275a 100644 --- a/assets/layers/ghost_bike/ghost_bike.svg +++ b/assets/layers/ghost_bike/ghost_bike.svg @@ -1,44 +1,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/assets/themes/cyclestreets/F111.svg b/assets/themes/cyclestreets/F111.svg index 0217385..e5f55a1 100644 --- a/assets/themes/cyclestreets/F111.svg +++ b/assets/themes/cyclestreets/F111.svg @@ -1,775 +1,784 @@ -image/svg+xmlimage/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + d="m 3956,10770 c -16,-5 -40,-19 -53,-32 -55,-51 -53,-16 -53,-853 v -775 h -935 -935 v 375 375 h -300 -300 v -370 -370 h -63 -63 l -41,-72 c -104,-183 -165,-393 -194,-663 -15,-136 -14,-1000 1,-1056 10,-35 27,-53 124,-131 18,-16 40,-28 49,-28 24,0 31,-15 110,-225 42,-110 105,-276 140,-370 36,-93 140,-367 231,-609 92,-241 173,-453 181,-472 l 14,-34 h 518 518 l 94,-335 c 80,-285 98,-338 122,-361 35,-34 268,-130 473,-196 l 163,-52 -58,-43 c -104,-76 -177,-190 -205,-321 -17,-84 -17,-120 1,-207 53,-252 262,-425 514,-425 105,0 186,20 266,65 147,83 247,237 269,416 21,170 -80,387 -225,480 l -49,33 187,62 c 245,81 426,158 456,194 17,20 51,123 118,359 l 94,331 h 180 180 l 102,228 c 56,125 226,504 377,842 l 275,615 33,6 c 48,8 135,76 158,124 19,39 20,65 22,476 1,451 -5,566 -43,751 -35,175 -115,382 -198,511 l -31,47 h -100 -100 v 400 400 h -300 -300 v -375 -375 h -365 -365 v 270 270 h 140 140 v 125 125 h -290 -290 v -395 -395 h -100 -100 l -2,789 -3,790 -35,36 c -19,19 -50,40 -70,45 -40,11 -45,11 -84,0 z M 3850,8755 v -45 h -635 -635 v 45 45 h 635 635 z m 498,-2 3,-43 h -100 -101 v 45 46 l 98,-3 97,-3 z m 532,2 v -45 h -115 -115 v 45 45 h 115 115 z M 3080,8425 v -45 h -385 -385 v 45 45 h 385 385 z m 770,0 v -45 h -95 -95 v 45 45 h 95 95 z m 500,0 v -45 h -100 -100 v 45 45 h 100 100 z m 800,0 v -45 h -250 -250 v 45 45 h 250 250 z m -3247,-93 c 91,-35 199,-168 218,-267 12,-62 -5,-145 -43,-217 -40,-76 -70,-105 -144,-145 -126,-67 -259,-57 -374,27 -51,37 -77,68 -106,130 -23,47 -27,68 -27,150 -1,112 15,151 97,238 80,85 153,114 266,107 36,-2 87,-13 113,-23 z m 3964,9 c 52,-10 139,-74 192,-141 77,-97 77,-277 1,-391 -63,-92 -171,-151 -280,-151 -125,-1 -233,56 -291,155 -90,152 -90,262 -2,384 39,54 132,131 168,138 11,2 29,6 40,8 35,8 128,6 172,-2 z M 3350,8080 v -40 h -385 -385 v 40 40 h 385 385 z m 500,0 v -40 h -95 -95 v 40 40 h 95 95 z m 500,0 v -40 h -100 -100 v 40 40 h 100 100 z m 530,0 v -40 h -115 -115 v 40 40 h 115 115 z M 1625,7106 c 285,-33 685,-52 1313,-62 l 412,-6 v -223 c 0,-212 1,-224 23,-265 55,-104 187,-107 261,-7 20,27 21,43 24,257 l 3,229 121,3 c 66,2 122,1 124,-1 2,-2 4,-131 4,-285 0,-155 5,-314 10,-355 6,-41 8,-77 5,-79 -7,-8 -212,17 -314,38 -178,37 -481,154 -504,195 -7,13 -62,15 -362,15 h -355 v -95 -95 h 135 135 v -26 c 0,-23 175,-657 187,-677 2,-4 -194,-6 -437,-5 l -442,3 -229,615 c -126,338 -249,668 -274,734 l -44,118 37,-5 c 20,-4 96,-13 167,-21 z m 4313,-183 c -56,-115 -215,-444 -354,-733 l -253,-525 -75,-3 -75,-3 20,68 c 93,325 169,603 169,621 0,21 3,22 125,22 h 126 l -3,93 -3,92 -355,3 c -319,2 -355,1 -363,-14 -21,-38 -306,-148 -487,-189 -99,-22 -327,-52 -334,-44 -2,2 3,56 10,119 7,63 13,226 14,363 v 247 h 125 124 l 3,-244 3,-244 25,-27 c 76,-81 195,-71 247,21 22,37 23,49 23,270 v 231 l 298,6 c 405,9 824,37 997,66 104,18 105,34 -7,-196 z M 3257,6335 c 484,-196 1058,-189 1527,16 50,22 97,43 104,46 7,3 12,-2 12,-11 0,-13 18,-16 108,-18 l 108,-3 -92,-330 c -51,-181 -95,-340 -99,-352 -5,-23 -7,-23 -178,-23 h -174 l -17,98 -17,97 56,184 c 30,101 53,186 52,188 -2,2 -55,-10 -118,-27 -355,-92 -715,-92 -1062,1 -43,12 -80,20 -82,17 -2,-2 21,-84 51,-183 l 55,-179 -17,-98 -17,-98 h -173 -173 l -11,38 c -6,20 -50,179 -99,352 l -87,315 94,3 c 70,2 94,6 98,17 5,13 10,13 35,0 16,-9 68,-31 116,-50 z m 163,-882 c 0,-6 -62,-377 -93,-553 -2,-13 -157,532 -157,553 0,4 56,7 125,7 69,0 125,-3 125,-7 z m 1440,0 c 0,-6 -138,-508 -153,-557 -3,-7 -98,538 -97,557 0,4 56,7 125,7 69,0 125,-3 125,-7 z" /> + \ No newline at end of file diff --git a/createLayouts.ts b/createLayouts.ts index 5ead925..4eace81 100644 --- a/createLayouts.ts +++ b/createLayouts.ts @@ -13,17 +13,13 @@ import Translations from "./UI/i18n/Translations"; import {TagRendering} from "./UI/TagRendering"; TagRendering.injectFunction(); - - console.log("Building the layouts") - function enc(str: string): string { return encodeURIComponent(str.toLowerCase()); } function validate(layout: Layout) { - console.log("Validationg ", layout.id) const translations: Translation[] = []; const queue: any[] = [layout] @@ -52,7 +48,6 @@ function validate(layout: Layout) { const txt = translation.translations[ln]; const isMissing = txt === undefined || txt === "" || txt.toLowerCase().indexOf("todo") >= 0; if (isMissing) { - console.log(`Missing or suspicious ${ln}-translation for '`, translation.txt, ":", txt) missing[ln]++ } else { present[ln]++; @@ -60,7 +55,7 @@ function validate(layout: Layout) { } } - console.log("Translation completenes for", layout.id); + console.log("Translation completenes for theme", layout.id); for (const ln of layout.supportedLanguages) { const amiss = missing[ln]; const ok = present[ln]; @@ -129,23 +124,21 @@ function createIcon(iconPath: string, size: number) { } console.log("Creating icon ", name, newname) + try { + svg2img(iconPath, + // @ts-ignore + {width: size, height: size, preserveAspectRatio: true}) + .then((buffer) => { + console.log("Writing icon", newname) + writeFileSync(newname, buffer); + }).catch((error) => { + console.log("ERROR while writing" + iconPath, error) + }); - try{ - - svg2img(iconPath, - // @ts-ignore - {width: size, height: size, preserveAspectRatio: true}) - .then((buffer) => { - console.log("Writing icon", newname) - writeFileSync(newname, buffer); - }).catch((error) => { - console.log("ERROR while writing" + iconPath, error) - }); - - }catch(e){ - console.error("Could not read icon",iconPath,"due to",e) + } catch (e) { + console.error("Could not read icon", iconPath, "due to", e) } - + return newname; } @@ -155,7 +148,6 @@ function createManifest(layout: Layout, relativePath: string) { const icons = []; let icon = layout.icon; - console.log(icon) if (icon.endsWith(".svg")) { // This is an svg. Lets create the needed pngs! const sizes = [72, 96, 120, 128, 144, 152, 180, 192, 384, 512]; @@ -240,16 +232,13 @@ for (const layoutName in all) { }; const layout = all[layoutName]; validate(layout) - console.log("Generating manifest") const manif = JSON.stringify(createManifest(layout, "/MapComplete")); const manifestLocation = encodeURIComponent(layout.id.toLowerCase()) + ".webmanifest"; writeFile(manifestLocation, manif, err); const landing = createLandingPage(layout); - console.log("Generating html-file for ", layout.id) writeFile(enc(layout.id) + ".html", landing, err) - console.log("done") wikiPage += "\n\n"+generateWikiEntry(layout); } diff --git a/deploy.sh b/deploy.sh index d537963..e4927a6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -5,6 +5,8 @@ ts-node createLayouts.ts || { echo 'Creating layouts failed' ; exit 1; } find -name '*.png' | parallel optipng '{}' npm run build || { echo 'Npm build failed' ; exit 1; } +rm -rf .cache + if [[ $1 == "groen" ]] then echo "DEPLOYING TO BUURTNATUUR!"