Fix maxspeed theme

This commit is contained in:
pietervdvn 2022-06-04 18:10:09 +02:00
parent bcd51b4ee2
commit b62e54ccf6
5 changed files with 216 additions and 209 deletions

View file

@ -13,6 +13,7 @@ import Img from "../../UI/Base/Img";
import Combine from "../../UI/Base/Combine";
import {VariableUiElement} from "../../UI/Base/VariableUIElement";
export default class PointRenderingConfig extends WithContextLoader {
private static readonly allowed_location_codes = new Set<string>(["point", "centroid", "start", "end","projected_centerpoint"])
@ -126,13 +127,20 @@ export default class PointRenderingConfig extends WithContextLoader {
public GetBaseIcon(tags?: any): BaseUIElement {
tags = tags ?? {id: "node/-1"}
const rotation = Utils.SubstituteKeys(this.rotation?.GetRenderValue(tags)?.txt ?? "0deg", tags)
const htmlDefs = Utils.SubstituteKeys(this.icon?.GetRenderValue(tags)?.txt, tags)
let defaultPin: BaseUIElement = undefined
if (this.label === undefined) {
defaultPin = Svg.teardrop_with_hole_green_svg()
}
return PointRenderingConfig.FromHtmlMulti(htmlDefs, rotation, false, defaultPin)
if(this.icon === undefined){
return defaultPin;
}
const rotation = Utils.SubstituteKeys(this.rotation?.GetRenderValue(tags)?.txt ?? "0deg", tags)
const htmlDefs = Utils.SubstituteKeys(this.icon?.GetRenderValue(tags)?.txt, tags)
if(htmlDefs === undefined){
// This layer doesn't want to show an icon right now
return undefined
}
return PointRenderingConfig.FromHtmlMulti(htmlDefs, rotation, false, defaultPin)
}
public GetSimpleIcon(tags: UIEventSource<any>): BaseUIElement {

View file

@ -0,0 +1,12 @@
[
{
"path": "living_street_be.svg",
"license": "CC0",
"authors": [
"Belgische Wetgever"
],
"sources": [
"https://nl.wikipedia.org/wiki/Bestand:Belgian_road_sign_F12a.svg"
]
}
]

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" width="372px" height="250px" viewBox="0 0 372 250" version="1.1">
<g id="surface1">
<path style="fill:none;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 11.947711 103.576168 L 143.44739 103.514429 C 149.707652 103.514429 154.762077 98.451843 154.762077 92.183726 L 154.822288 11.541421 C 154.822288 5.21319 149.766235 0.150604 143.509227 0.150604 L 11.466027 0.150604 C 5.207392 0.150604 0.149713 5.21319 0.149713 11.541421 L 0.149713 92.365693 C 0.149713 98.633811 5.205765 103.696396 11.4644 103.696396 Z M 11.947711 103.576168 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 145.793971 94.656529 L 9.23824 94.656529 L 9.23824 9.190471 L 145.793971 9.190471 Z M 145.793971 94.656529 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 107.27554 22.751896 L 107.27554 45.293073 L 132.975649 45.293073 L 132.975649 22.813635 L 128.702332 19.557723 L 128.702332 14.072714 L 124.850489 14.072714 L 124.850489 16.784349 L 120.035279 14.072714 Z M 107.27554 22.751896 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 99.091797 51.803272 C 92.471899 51.803272 87.176632 46.558719 87.176632 39.928292 L 87.176632 36.433549 L 89.822638 36.433549 L 89.822638 38.602532 C 89.822638 44.570079 94.69806 49.452322 100.657269 49.452322 L 138.331127 49.452322 L 138.331127 51.803272 Z M 99.091797 51.803272 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 79.411108 14.735594 L 59.190152 14.735594 L 56.181256 22.751896 L 55.219515 23.655232 L 55.219515 25.463531 L 56.423725 32.878691 L 57.806938 32.878691 L 57.806938 37.398624 L 60.15352 37.398624 L 60.15352 32.938805 L 78.148315 32.938805 L 78.148315 37.276771 L 80.314265 37.276771 L 80.314265 32.878691 L 81.759317 32.878691 L 82.722684 25.946069 L 82.660846 23.897314 L 81.518475 22.932238 Z M 79.411108 14.735594 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 67.736785 84.952158 C 64.246205 84.952158 62.080255 81.215333 63.824731 78.201502 C 65.569208 75.187672 69.904362 75.129182 71.648839 78.201502 C 73.393315 81.215333 71.227365 84.952158 67.736785 84.952158 Z M 67.736785 84.952158 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 20.552927 86.45826 C 21.275453 86.45826 22.17861 85.554924 22.17861 84.830305 C 22.17861 84.10731 21.576505 83.506169 20.85398 83.506169 L 28.497455 71.751418 L 30.603195 62.893518 L 42.88125 85.616662 L 48.658201 82.662946 C 49.380726 82.662946 49.982831 82.06018 49.982831 81.337186 C 49.982831 80.614191 49.380726 80.011425 48.658201 80.011425 L 46.492251 80.614191 L 35.418405 58.131503 L 37.463934 45.83735 L 40.954515 55.29964 L 49.320516 56.625401 C 50.223673 56.625401 51.004782 55.842292 51.004782 54.937331 C 51.004782 54.032369 50.223673 53.249261 49.320516 53.249261 L 44.023621 52.284185 L 39.629884 40.470944 L 35.958672 40.531058 L 35.237774 40.230488 L 35.537199 38.240222 L 36.319935 37.637456 C 37.223092 37.637456 38.004201 36.854348 38.004201 35.949386 L 38.848775 31.972105 C 39.029407 31.068768 38.126249 30.103692 37.223092 30.103692 L 33.250828 29.803122 C 32.469719 29.681269 31.807404 29.983464 31.745566 30.646344 L 30.181721 39.445755 L 29.579617 40.048521 L 26.51051 39.928292 L 18.746613 48.004708 L 18.746613 57.226542 C 18.746613 58.128254 19.529349 58.914612 20.432506 58.914612 C 21.335663 58.914612 22.116772 58.129879 22.116772 57.226542 L 22.478035 50.053463 L 27.714719 45.050992 L 23.560196 68.617359 L 14.774349 82.599583 Z M 20.552927 86.45826 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 100.836273 83.145484 L 100.476638 82.482604 L 94.81848 85.616662 L 93.134214 85.616662 L 87.89753 80.011425 L 81.336216 83.507794 L 76.945733 89.8344 L 73.876626 88.14633 C 73.575574 87.905874 73.393315 87.605303 73.393315 87.242994 C 73.393315 86.638603 73.876626 86.15769 74.477104 86.15769 C 74.717945 86.15769 74.958787 86.219429 75.139419 86.399771 L 75.621103 86.638603 L 79.533156 80.191768 L 84.948844 77.600361 L 84.408577 70.607624 L 75.139419 71.5727 C 74.597525 71.5727 74.115841 71.091787 74.115841 70.54751 C 74.115841 70.006483 74.597525 69.523945 75.139419 69.523945 L 84.045687 68.440266 L 84.828423 67.655533 L 84.647792 65.788745 C 83.262951 65.366321 82.241 64.040561 82.241 62.532833 C 82.241 60.664421 83.804845 59.096579 85.67137 59.096579 C 87.536268 59.096579 89.10174 60.664421 89.10174 62.532833 C 89.10174 63.618137 88.559846 64.581588 87.778737 65.244468 L 87.778737 66.932538 L 88.380842 67.897614 L 93.918578 67.535304 L 98.491319 61.146959 C 98.912793 60.604307 98.971376 60.121769 99.51327 60.121769 C 100.055165 60.121769 100.535221 60.604307 100.535221 61.146959 L 95.059322 69.463831 L 89.882849 70.006483 L 90.605374 77.057709 L 94.397007 81.879838 L 100.958322 78.685665 L 102.823219 82.120294 C 102.88343 82.302261 102.94364 82.482604 102.94364 82.724685 C 102.94364 83.327451 102.461956 83.808364 101.859851 83.808364 C 101.378168 83.808364 101.016905 83.569532 100.836273 83.205598 Z M 100.836273 83.145484 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:nonzero;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 123.405438 33.419718 L 116.364067 33.419718 L 116.364067 42.521324 L 109.80438 42.521324 L 109.80438 24.560194 L 120.035279 16.784349 L 130.205967 24.019167 L 130.205967 42.521324 L 123.226434 42.521324 L 123.226434 33.419718 Z M 123.405438 33.419718 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(100%,100%,100%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,100%,100%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 123.286644 30.045203 L 116.847378 30.045203 L 116.847378 23.174319 L 123.286644 23.174319 Z M 123.286644 30.045203 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 75.378633 27.754367 L 63.403258 27.754367 L 63.403258 26.849405 L 75.380261 26.849405 L 75.380261 27.754367 Z M 75.378633 27.754367 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 77.487627 29.442437 L 60.635203 29.442437 L 60.635203 28.537475 L 77.487627 28.537475 Z M 77.487627 29.442437 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 75.25984 31.190621 L 63.463469 31.190621 L 63.463469 30.28566 L 75.25984 30.28566 Z M 75.25984 31.190621 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 58.94931 28.056562 C 57.867149 28.056562 57.144623 26.849405 57.686517 25.885954 C 58.228412 24.922504 59.671836 24.922504 60.21373 25.885954 C 60.755624 26.849405 60.033099 28.056562 58.94931 28.056562 Z M 58.94931 28.056562 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:evenodd;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 79.111683 28.056562 C 78.027894 28.056562 77.305369 26.849405 77.847263 25.885954 C 78.38753 24.922504 79.832581 24.922504 80.372848 25.885954 C 80.91637 26.849405 80.193844 28.056562 79.111683 28.056562 Z M 79.111683 28.056562 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
<path style="fill-rule:nonzero;fill:rgb(0%,44.313726%,70.19608%);fill-opacity:1;stroke-width:0.301;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,44.313726%,70.19608%);stroke-opacity:1;stroke-miterlimit:3.863;" d="M 57.204834 22.813635 L 59.792257 15.941126 L 78.629999 15.941126 L 80.436313 22.873749 Z M 57.204834 22.813635 " transform="matrix(2.400434,0,0,2.40428,0,0.161343)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 10 KiB

View file

@ -0,0 +1,169 @@
{
"id": "maxspeed",
"name": {
"es": "Velocidad",
"ca": "Velocitat",
"en": "Maxspeed"
},
"source": {
"osmTags": {
"and": [
{
"or": [
"highway=residential",
"highway=living_street",
"highway=motorway",
"highway=tertiary",
"highway=unclassified",
"highway=secondary",
"highway=primary",
"highway=trunk",
"highway=motorway",
"highway=tertiary_link",
"highway=secondary_link",
"highway=primary_link",
"highway=trunk_link",
"highway=motorway_link"
]
},
"type!=multipolygon",
"area!=yes"
]
}
},
"minzoom": 16,
"title": {
"render": {
"*": " {name}"
},
"mappings": [
{
"if": "name=",
"then": {
"en": "Road without a name"
}
}
]
},
"description": {
"en": "Shows the allowed speed for every road"
},
"tagRenderings": [
{
"render": {
"en": "The maximum allowed speed on this road is {maxspeed}"
},
"question": {
"es": "Qué velocidad tiene",
"ca": "Quina velocitat té",
"en": "What is the legal maximum speed one is allowed to drive on this road?"
},
"freeform": {
"key": "maxspeed",
"type": "pnat"
},
"mappings": [
{
"if": "highway=living_street",
"then": {
"en": "This is a living street, which has a maxspeed of 20km/h",
"nl": "Dit is een woonerf en heeft dus een maximale snelheid van 20km/h"
},
"icon": {
"path":"./assets/layers/maxspeed/living_street_be.svg",
"size": "large"
},
"hideInAnswer": "_country!=be"
}
],
"id": "maxspeed-maxspeed"
}
],
"allowSplit": true,
"mapRendering": [
{
"render": null,
"icon": {
"mappings": [
{
"if": "maxspeed~[1-9]0|1[0-4]0",
"then": "./assets/themes/maxspeed/maxspeed_{maxspeed}.svg"
}
]
},
"condition": "maxspeed!=30",
"iconSize": {
"render": "32,32,center"
},
"location": [
"point",
"projected_centerpoint"
]
},
{
"color": {
"render": "#000000",
"mappings": [
{
"if": "maxspeed=",
"then": "#ff0000"
}
]
},
"width": {
"render": "3"
}
}
],
"units": [
{
"applicableUnits": [
{
"#": "km/h is the default for a maxspeed; should be empty string",
"canonicalDenomination": "",
"alternativeDenomination": [
"km/u",
"kmh",
"kph"
],
"default": true,
"human": {
"en": "kilometers/hour",
"ca": "quilòmetres/hora",
"es": "kilómetros/hora",
"nl": "kilometers/uur"
},
"humanShort": {
"en": "km/h",
"ca": "km/h",
"es": "km/h",
"nl": "km/u"
}
},
{
"canonicalDenomination": "mph",
"alternativeDenomination": [
"m/u",
"mh",
"m/ph"
],
"human": {
"en": "miles/hour",
"ca": "milles/hora",
"es": "millas/hora",
"nl": "miles/uur"
},
"humanShort": {
"en": "mph",
"ca": "mph",
"es": "mph",
"nl": "mph"
}
}
],
"appliesToKey": [
"maxspeed"
]
}
]
}

View file

@ -6,14 +6,10 @@
"en": "Maxspeed"
},
"shortDescription": {
"es": "Completar propiedades de velocidad",
"ca": "Completar propietats de velocitat",
"en": "Complete maxspeed tags"
"en": "This map shows the legally allowed maximum speed on every road."
},
"description": {
"es": "Completaremos las propiedades de velocidad de una vía.",
"ca": "Completarem les propietats de la velocitat de la via que faltin.",
"en": "Complete the maxspeed properties of a way."
"en": "This map shows the legally allowed maximum speed on every road. If a maxspeed is missing or wrong, you can correct it here."
},
"maintainer": "",
"icon": "./assets/themes/maxspeed/maxspeed_logo.svg",
@ -23,205 +19,6 @@
"startZoom": 1,
"widenFactor": 0.01,
"layers": [
{
"id": "maxspeed",
"name": {
"es": "Velocidad",
"ca": "Velocitat",
"en": "Maxspeed"
},
"minzoom": 16,
"title": {
"render": {
"es": "Nombre: {name}",
"ca": "Nom: {name}",
"en": "Name: {name}"
},
"mappings": [
{
"if": {
"and": [
"name="
]
},
"then": {
"es": "Nombre: {name}",
"ca": "Nom: {name}",
"en": "Name: {name}"
}
}
]
},
"description": {
"es": "Completar las propiedades que faltan sobre velocidad",
"ca": "Completarem les propietats que falten de velocitat",
"en": "Complete the maxspeed properties of a way."
},
"tagRenderings": [
{
"render": {
"es": "Velocidad: {maxspeed}",
"ca": "Velocitat: {maxspeed}",
"en": "Speed: {maxspeed}"
},
"question": {
"es": "Qué velocidad tiene",
"ca": "Quina velocitat té",
"en": "What is the maxspeed"
},
"freeform": {
"key": "maxspeed"
},
"id": "maxspeed-maxspeed"
},
{
"render": {
"es": "Sentido único: {oneway}",
"ca": "Sentit únic: {oneway}",
"en": "Oneway: {oneway}"
},
"question": {
"es": "¿La vía es de sentido único?",
"ca": "La via és de sentit únic?",
"en": "Is this road a oneway-road?"
},
"freeform": {
"key": "oneway"
},
"mappings": [
{
"if": {
"and": [
"oneway=yes"
]
},
"then": {
"es": "Sentido único",
"ca": "Sentit únic",
"en": "Oneway road"
}
},
{
"if": {
"and": [
"oneway=no"
]
},
"then": {
"es": "Doble sentido",
"ca": "Doble sentit",
"en": "Twoway street"
}
}
],
"id": "maxspeed-oneway"
}
],
"source": {
"osmTags": {
"or": [
"highway=residential",
"highway=living_street",
"highway=motorway",
"highway=tertiary",
"highway=service",
"highway=unclassified",
"highway=secondary",
"highway=primary",
"highway=trunk",
"highway=motorway",
"highway=tertiary_link",
"highway=secondary_link",
"highway=primary_link",
"highway=trunk_link",
"highway=motorway_link"
]
}
},
"allowSplit": true,
"mapRendering": [
{
"icon": {
"render": null,
"mappings": [
{
"if": "maxspeed~[1-9]0|1[0-4]0",
"then": "./assets/themes/maxspeed/maxspeed_{maxspeed}.svg"
}
]
},
"iconSize": {
"render": "32,32,center"
},
"location": [
"point",
"projected_centerpoint"
]
},
{
"color": {
"render": "#000000",
"mappings": [
{
"if": "maxspeed=",
"then": "#ff0000"
}
]
},
"width": {
"render": "3"
}
}
],
"units": [
{
"applicableUnits": [
{
"#": "km/h is the default for a maxspeed; should be empty string",
"canonicalDenomination": "",
"alternativeDenomination": [
"km/u",
"kmh",
"kph"
],
"default": true,
"human": {
"en": "kilometers/hour",
"ca": "quilòmetres/hora",
"es": "kilómetros/hora",
"nl": "kilometers/uur"
},
"humanShort": {
"en": "km/h",
"ca": "km/h",
"es": "km/h",
"nl": "km/u"
}
},
{
"canonicalDenomination": "mph",
"alternativeDenomination": [
"m/u",
"mh",
"m/ph"
],
"human": {
"en": "miles/hour",
"ca": "milles/hora",
"es": "millas/hora",
"nl": "miles/uur"
},
"humanShort": {
"en": "mph",
"ca": "mph",
"es": "mph",
"nl": "mph"
}
}
],
"appliesToKey": [ "maxspeed"]
}
]
}
"maxspeed"
]
}