From 9c671f47350b545785223475aaf23a623c610f62 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 25 Sep 2020 23:10:40 +0200 Subject: [PATCH 1/6] Fix bug with weird clipping behaviour (cause of #125) --- Logic/FilteredLayer.ts | 52 ++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 22 deletions(-) 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; From e6bdf7d3358c49a3f17fe17ad79f56d01b43ecba Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 25 Sep 2020 23:11:01 +0200 Subject: [PATCH 2/6] Version bump --- State.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = { From 232431bbf73d08ab5ec064fab71e4d5bc58512e8 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 25 Sep 2020 23:24:35 +0200 Subject: [PATCH 3/6] Fixed the ghost bike icon as png --- assets/layers/ghost_bike/ghost_bike.svg | 114 +++++++++++++++--------- 1 file changed, 71 insertions(+), 43 deletions(-) diff --git a/assets/layers/ghost_bike/ghost_bike.svg b/assets/layers/ghost_bike/ghost_bike.svg index 93a4b2a..61046a5 100644 --- a/assets/layers/ghost_bike/ghost_bike.svg +++ b/assets/layers/ghost_bike/ghost_bike.svg @@ -1,44 +1,72 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + From 622add9e52f339dc3c95687082a876ee71ae3e3d Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 25 Sep 2020 23:24:56 +0200 Subject: [PATCH 4/6] Add cache deletion in deploy script --- deploy.sh | 2 ++ 1 file changed, 2 insertions(+) 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!" From d05fbeb919774359dbc1aefb2ae7075ba4ab1b08 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 25 Sep 2020 23:26:54 +0200 Subject: [PATCH 5/6] Cleanup of F111 svg --- assets/themes/cyclestreets/F111.svg | 1214 +++++++++++++++------------ 1 file changed, 657 insertions(+), 557 deletions(-) diff --git a/assets/themes/cyclestreets/F111.svg b/assets/themes/cyclestreets/F111.svg index 0217385..b0bdec6 100644 --- a/assets/themes/cyclestreets/F111.svg +++ b/assets/themes/cyclestreets/F111.svg @@ -1,628 +1,755 @@ + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + d="m 12596.22,10705.407 c -14.571,-4.554 -36.427,-17.303 -48.266,-29.142 -50.998,-47.355 -48.266,27.321 -48.266,-1259.4763 0,-1262.2076 -1.821,-1216.6735 40.07,-1251.2794 12.749,-10.9282 14.571,-86.515 14.571,-692.1196 0,-402.5223 3.642,-708.512 9.107,-751.3141 4.553,-40.0701 7.285,-74.6761 4.553,-76.4975 -6.375,-7.2855 -193.065,15.4816 -285.955,34.606 -162.102,33.6953 -438.038,140.2453 -458.984,177.5834 -6.375,11.8388 -56.462,13.6602 -329.668,13.6602 h -323.293 v -86.5149 -86.515 h 122.943 122.942 V 6674.72 c 0,-13.6603 59.195,-232.2243 131.138,-485.3944 72.855,-253.1701 161.191,-565.5346 196.708,-693.0303 50.999,-181.2261 70.123,-237.6885 89.247,-256.8128 30.053,-32.7847 200.35,-104.7287 412.54,-174.8513 l 169.387,-55.5517 -44.623,-31.874 c -95.622,-65.5692 -168.477,-178.4939 -193.976,-297.7935 -16.393,-78.3189 -16.393,-110.1927 0,-189.4222 48.266,-229.4924 238.599,-387.0406 468.091,-387.0406 95.622,0 169.387,18.2137 242.242,59.1945 133.871,75.5867 224.939,215.832 244.974,378.8444 19.125,154.8162 -72.854,352.4346 -204.904,437.1282 l -44.623,30.0525 170.298,56.4624 c 223.117,73.7654 387.951,143.888 415.271,176.6726 15.482,18.2137 44.624,107.4607 101.997,305.9897 232.225,818.7048 314.186,1111.9449 314.186,1131.0693 0,20.035 1.821,20.035 113.836,20.035 h 114.746 l -2.732,84.6936 -2.733,83.7829 -323.292,2.732 c -290.509,1.8214 -323.293,0.9107 -330.579,-12.7496 -19.124,-34.6059 -278.668,-134.7811 -443.502,-172.1191 -90.158,-20.0351 -297.794,-47.3556 -304.169,-40.0702 -1.821,1.8214 2.732,50.9983 9.107,108.3714 8.196,75.5868 11.839,282.312 12.75,749.4927 v 643.8534 l 22.766,34.606 22.768,34.6059 -1.822,1208.4774 -2.731,1207.5678 -31.875,32.784 c -17.303,17.303 -45.534,36.427 -63.748,40.981 -36.426,10.017 -40.98,10.017 -76.497,0 z m -636.568,-4038.8832 c 440.771,-178.494 963.504,-172.1192 1390.614,14.571 45.535,20.0351 88.336,39.1594 94.712,41.8915 6.374,2.732 10.928,-1.8214 10.928,-10.0175 0,-11.8389 16.392,-14.571 98.353,-16.3924 l 98.354,-2.732 -187.601,-672.0846 c -101.996,-369.7376 -187.6,-668.4419 -188.511,-664.7991 -0.911,4.5534 -35.517,202.1718 -75.587,439.8602 l -72.854,433.4855 50.087,166.6551 c 27.321,92.8898 48.267,169.3871 47.356,171.2085 -1.822,1.8214 -50.088,-9.1068 -107.461,-24.5885 -323.293,-83.7828 -651.139,-83.7828 -967.146,0.9107 -39.159,10.9283 -72.855,18.2137 -74.676,15.4816 -1.821,-1.8213 19.124,-76.4973 46.444,-165.7444 l 49.177,-163.0123 -74.676,-440.771 c -41.891,-242.2419 -76.497,-436.2174 -79.229,-429.8427 -1.821,5.4641 -85.604,307.8111 -186.69,671.1739 l -183.959,662.0671 85.605,2.732 c 63.748,1.8214 85.605,5.4641 89.247,15.4816 4.553,11.8389 9.107,11.8389 31.874,0 14.571,-8.1961 61.926,-28.2311 105.639,-45.5342 z" /> + + + + + + + + + + + + + From 387d8d4dc1bcc1aecbda037476a9caa6b544fce7 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 25 Sep 2020 23:37:59 +0200 Subject: [PATCH 6/6] Cleaning up log messages, cleaning svg files --- Customizations/JSON/FromJSON.ts | 2 - assets/layers/ghost_bike/ghost_bike.svg | 1 + assets/themes/cyclestreets/F111.svg | 1631 +++++++++++------------ createLayouts.ts | 39 +- 4 files changed, 785 insertions(+), 888 deletions(-) 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/assets/layers/ghost_bike/ghost_bike.svg b/assets/layers/ghost_bike/ghost_bike.svg index 61046a5..0ed275a 100644 --- a/assets/layers/ghost_bike/ghost_bike.svg +++ b/assets/layers/ghost_bike/ghost_bike.svg @@ -11,6 +11,7 @@ viewBox="0 0 98 122" height="122" width="98"> + - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/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); }