WIP: add oneway arrows to _all_ lines

This commit is contained in:
Pieter Vander Vennet 2024-02-03 17:27:41 +01:00
parent d48b8aff92
commit 43f9afc3ba
7 changed files with 213 additions and 190 deletions

View file

@ -5,12 +5,7 @@
"nl": "Oplaadpunten",
"de": "Ladestationen"
},
"description": {
"en": "A charging station",
"nl": "Oplaadpunten",
"de": "Eine Ladestation",
"ca": "Una estació de càrrega"
},
"minzoom": 10,
"source": {
"osmTags": {
"and": [
@ -25,7 +20,6 @@
]
}
},
"minzoom": 10,
"title": {
"render": {
"en": "Charging station",
@ -71,103 +65,13 @@
}
]
},
"pointRendering": [
{
"location": [
"point",
"centroid"
],
"marker": [
{
"icon": "pin",
"color": "#fff"
},
{
"icon": {
"render": "./assets/themes/charging_stations/plug.svg",
"mappings": [
{
"if": "bicycle=yes",
"then": "./assets/themes/charging_stations/bicycle.svg"
},
{
"if": {
"or": [
"car=yes",
"motorcar=yes"
]
},
"then": "./assets/themes/charging_stations/car.svg"
}
]
}
}
],
"iconBadges": [
{
"if": {
"or": [
"disused:amenity=charging_station",
"operational_status=broken"
]
},
"then": "close:#c22;"
},
{
"if": {
"or": [
"proposed:amenity=charging_station",
"planned:amenity=charging_station"
]
},
"then": "./assets/layers/charging_station/under_construction.svg"
},
{
"if": {
"and": [
"bicycle=yes",
{
"or": [
"motorcar=yes",
"car=yes"
]
}
]
},
"then": "circle:#fff;./assets/themes/charging_stations/car.svg"
}
],
"anchor": "bottom",
"iconSize": "50,50"
}
],
"lineRendering": [],
"presets": [
{
"tags": [
"amenity=charging_station",
"motorcar=no",
"bicycle=yes"
],
"title": {
"en": "charging station for electrical bikes",
"nl": "oplaadpunt voor elektrische fietsen",
"de": "Ladestation für Elektrofahrräder"
}
},
{
"tags": [
"amenity=charging_station",
"motorcar=yes",
"bicycle=no"
],
"title": {
"en": "charging station for cars",
"nl": "oplaadstation voor elektrische auto's",
"de": "Ladestation für Elektrofahrräder"
}
}
],
"description": {
"en": "A charging station",
"nl": "Oplaadpunten",
"ca": "Una estació de càrrega",
"de": "Eine Ladestation"
},
"#": "no-question-hint-check",
"tagRenderings": [
"images",
{
@ -2412,6 +2316,103 @@
}
}
],
"lineRendering": [],
"pointRendering": [
{
"location": [
"point",
"centroid"
],
"marker": [
{
"icon": "pin",
"color": "#fff"
},
{
"icon": {
"render": "./assets/themes/charging_stations/plug.svg",
"mappings": [
{
"if": "bicycle=yes",
"then": "./assets/themes/charging_stations/bicycle.svg"
},
{
"if": {
"or": [
"car=yes",
"motorcar=yes"
]
},
"then": "./assets/themes/charging_stations/car.svg"
}
]
}
}
],
"iconBadges": [
{
"if": {
"or": [
"disused:amenity=charging_station",
"operational_status=broken"
]
},
"then": "close:#c22;"
},
{
"if": {
"or": [
"proposed:amenity=charging_station",
"planned:amenity=charging_station"
]
},
"then": "./assets/layers/charging_station/under_construction.svg"
},
{
"if": {
"and": [
"bicycle=yes",
{
"or": [
"motorcar=yes",
"car=yes"
]
}
]
},
"then": "circle:#fff;./assets/themes/charging_stations/car.svg"
}
],
"anchor": "bottom",
"iconSize": "50,50"
}
],
"presets": [
{
"tags": [
"amenity=charging_station",
"motorcar=no",
"bicycle=yes"
],
"title": {
"en": "charging station for electrical bikes",
"nl": "oplaadpunt voor elektrische fietsen",
"de": "Ladestation für Elektrofahrräder"
}
},
{
"tags": [
"amenity=charging_station",
"motorcar=yes",
"bicycle=no"
],
"title": {
"en": "charging station for cars",
"nl": "oplaadstation voor elektrische auto's",
"de": "Ladestation für Elektrofahrräder"
}
}
],
"filter": [
{
"id": "vehicle-type",
@ -2420,16 +2421,16 @@
"question": {
"en": "All vehicle types",
"nl": "Alle voertuigen",
"de": "Ladestationen für alle Fahrzeugtypen",
"ca": "Tots els tipus de vehicles"
"ca": "Tots els tipus de vehicles",
"de": "Ladestationen für alle Fahrzeugtypen"
}
},
{
"question": {
"en": "Charging station for bicycles",
"nl": "Oplaadpunten voor fietsen",
"de": "Ladestationen für Fahrräder",
"ca": "Punt de recàrrega per a bicicletes"
"ca": "Punt de recàrrega per a bicicletes",
"de": "Ladestationen für Fahrräder"
},
"osmTags": "bicycle=yes"
},
@ -2480,8 +2481,8 @@
"question": {
"en": "Has a <div style='display: inline-block'><b><b>Schuko wall plug</b> without ground pin (CEE7/4 type F)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/CEE7_4F.svg'/></div> connector",
"nl": "Heeft een <div style='display: inline-block'><b><b>Schuko stekker</b> zonder aardingspin (CEE7/4 type F)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/CEE7_4F.svg'/></div>",
"de": "Verfügt über einen <div style='display: inline-block'><b><b>Schuko-Stecker</b> ohne Erdungsstift (CEE7/4 Typ F)</b><img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/CEE7_4F.svg'/></div>",
"ca": "Té un connector <div style='display: inline-block'><b><b>Schuko</b> sense pin de terra (CEE7/4 tipus F)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/CEE7_4F.svg'/></div>"
"ca": "Té un connector <div style='display: inline-block'><b><b>Schuko</b> sense pin de terra (CEE7/4 tipus F)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/CEE7_4F.svg'/></div>",
"de": "Verfügt über einen <div style='display: inline-block'><b><b>Schuko-Stecker</b> ohne Erdungsstift (CEE7/4 Typ F)</b><img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/CEE7_4F.svg'/></div>"
},
"osmTags": "socket:schuko~*"
},
@ -2489,8 +2490,8 @@
"question": {
"en": "Has a <div style='display: inline-block'><b><b>European wall plug</b> with ground pin (CEE7/4 type E)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/TypeE.svg'/></div> connector",
"nl": "Heeft een <div style='display: inline-block'><b><b>Europese stekker</b> met aardingspin (CEE7/4 type E)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/TypeE.svg'/></div>",
"de": "Verfügt über einen <div style='display: inline-block'><b><b>europäischen Netzstecker</b> mit Erdungsstift (CEE7/4 Typ E)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/TypeE.svg'/></div> Anschluss",
"ca": "Té un connector <div style='display: inline-block'><b><b>endoll de paret Europeu</b> amb un pin de terra (CEE7/4 tipus F)</b><img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/TypeE.svg'/></div>"
"ca": "Té un connector <div style='display: inline-block'><b><b>endoll de paret Europeu</b> amb un pin de terra (CEE7/4 tipus F)</b><img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/TypeE.svg'/></div>",
"de": "Verfügt über einen <div style='display: inline-block'><b><b>europäischen Netzstecker</b> mit Erdungsstift (CEE7/4 Typ E)</b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/TypeE.svg'/></div> Anschluss"
},
"osmTags": "socket:typee~*"
},
@ -2498,8 +2499,8 @@
"question": {
"en": "Has a <div style='display: inline-block'><b><b>Chademo</b></b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/Chademo_type4.svg'/></div> connector",
"nl": "Heeft een <div style='display: inline-block'><b><b>Chademo</b></b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/Chademo_type4.svg'/></div>",
"de": "Verfügt über einen <div style='display: inline-block'><b><b>Chademo</b></b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/Chademo_type4.svg'/></div> Stecker",
"ca": "Té un connector <div style='display: inline-block'><b><b>Chademo</b></b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/Chademo_type4.svg'/></div>"
"ca": "Té un connector <div style='display: inline-block'><b><b>Chademo</b></b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/Chademo_type4.svg'/></div>",
"de": "Verfügt über einen <div style='display: inline-block'><b><b>Chademo</b></b> <img style='width:1rem; display: inline-block' src='./assets/layers/charging_station/Chademo_type4.svg'/></div> Stecker"
},
"osmTags": "socket:chademo~*"
},
@ -2610,20 +2611,6 @@
]
}
],
"deletion": {
"softDeletionTags": {
"and": [
"amenity=",
"disused:amenity=charging_station"
]
},
"neededChangesets": 10
},
"allowMove": {
"enableRelocation": false,
"enableImproveAccuracy": true
},
"#": "no-question-hint-check",
"units": [
{
"maxstay": {
@ -2772,5 +2759,18 @@
]
}
}
]
}
],
"allowMove": {
"enableRelocation": false,
"enableImproveAccuracy": true
},
"deletion": {
"softDeletionTags": {
"and": [
"amenity=",
"disused:amenity=charging_station"
]
},
"neededChangesets": 10
}
}

BIN
assets/png/oneway.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

47
assets/png/oneway.svg Normal file
View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="394.39307"
height="391.37128"
viewBox="0 0 394.39307 391.37128"
version="1.1"
id="svg1"
sodipodi:docname="oneway.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25)"
inkscape:export-filename="oneway.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<sodipodi:namedview
id="namedview1"
pagecolor="#efe1c6"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.5375607"
inkscape:cx="170.07459"
inkscape:cy="205.52035"
inkscape:window-width="1850"
inkscape:window-height="1016"
inkscape:window-x="70"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg1"
showgrid="false" />
<g
id="surface1"
transform="rotate(90,189.69566,197.95776)">
<path
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:20;stroke-linecap:round;stroke-linejoin:bevel"
d="M 187.80469,0 375.40803,374.83557 187.60156,294.06641 94.257812,334.53516 C 42.917969,356.78906 0.3535155,374.31054 0.3535155,374.31054 Z"
id="path1"
sodipodi:nodetypes="cccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -33,7 +33,9 @@
"layers": [
"hotel",
{
"builtin": ["love_hotel"],
"builtin": [
"love_hotel"
],
"override": {
"minzoom": 18
}

View file

@ -30,62 +30,4 @@ export default class LineRenderingConfig extends WithContextLoader {
this.offset = this.tr("offset", "0")
}
public GenerateLeafletStyle(tags: {}): {
fillColor?: string
color: string
lineCap: string
offset: number
weight: number
dashArray: string
fill?: boolean
} {
function rendernum(tr: TagRenderingConfig, deflt: number) {
const str = Number(render(tr, "" + deflt))
const n = Number(str)
if (isNaN(n)) {
return deflt
}
return n
}
function render(tr: TagRenderingConfig, deflt?: string) {
if (tags === undefined) {
return deflt
}
if (tr === undefined) {
return deflt
}
const str = tr?.GetRenderValue(tags)?.txt ?? deflt
if (str === "") {
return deflt
}
return Utils.SubstituteKeys(str, tags)?.replace(/{.*}/g, "")
}
const dashArray = render(this.dashArray)
let color = render(this.color, "#00f")
if (color.startsWith("--")) {
color = getComputedStyle(document.body).getPropertyValue("--catch-detail-color")
}
const style = {
color,
dashArray,
weight: rendernum(this.width, 5),
lineCap: render(this.lineCap),
offset: rendernum(this.offset, 0),
}
const fillStr = render(this.fill, undefined)
if (fillStr !== undefined && fillStr !== "") {
style["fill"] = fillStr === "yes" || fillStr === "true"
}
const fillColorStr = render(this.fillColor, undefined)
if (fillColorStr !== undefined) {
style["fillColor"] = fillColorStr
}
return style
}
}

View file

@ -235,6 +235,33 @@ class LineRenderingLayer {
map.on("styledata", () => self.update(features.features))
}
private addSymbolLayer(sourceId: string, url: string = "./assets/png/oneway.png"){
const map = this._map
const imgId = url.replaceAll(/[/.-]/g, "_")
map.loadImage(url, (err, image) => {
if (err) {
console.error("Could not add symbol layer to line due to", err);
return
}
map.addImage(imgId, image);
map.addLayer({
'id': "symbol-layer"+imgId,
'type': 'symbol',
'source': sourceId,
'layout': {
'symbol-placement': 'line',
'symbol-spacing': 1,
'icon-allow-overlap': true,
'icon-rotation-alignment':'map',
'icon-pitch-alignment':'map',
'icon-image': imgId,
'icon-size': 0.045,
'visibility': 'visible'
}
});
});
}
public destruct(): void {
this._map.removeLayer(this._layername + "_polygon")
}
@ -320,6 +347,8 @@ class LineRenderingLayer {
"line-cap": "round",
},
})
this.addSymbolLayer(this._layername)
for (const feature of features) {
if (!feature.properties.id) {

File diff suppressed because one or more lines are too long