Refactoring: split icons into proper layered icons, fix and rerun shops-thief

This commit is contained in:
Pieter Vander Vennet 2023-10-06 23:56:50 +02:00
parent d6cd0516bb
commit 19a760178b
307 changed files with 26845 additions and 116541 deletions

View file

@ -9,10 +9,6 @@ import LineRenderingConfigJson from "./LineRenderingConfigJson"
import { QuestionableTagRenderingConfigJson } from "./QuestionableTagRenderingConfigJson"
import RewritableConfigJson from "./RewritableConfigJson"
import { Translatable } from "./Translatable"
import { Point } from "geojson"
import PointRenderingConfig from "../PointRenderingConfig"
type MapRendering = {}
/**
* Configuration for a single layer
@ -49,6 +45,7 @@ export interface LayerConfigJson {
/**
*
* Question: Where should the data be fetched from?
* title: Data Source
*
* This determines where the data for the layer is fetched: from OSM or from an external geojson dataset.
*
@ -242,12 +239,12 @@ export interface LayerConfigJson {
/**
* Creates points to render on the map.
* This can render points for point-objects, lineobjects or areaobjects; use 'location' to indicate where it should be rendered
* group: maprendering
* group: pointrendering
*/
pointRendering: PointRenderingConfigJson[]
/**
* Creates lines and areas to render on the map
* group: maprendering
* group: linerendering
*/
lineRendering?: LineRenderingConfigJson[]

View file

@ -1,4 +1,4 @@
import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
import { MinimalTagRenderingConfigJson } from "./TagRenderingConfigJson"
/**
* The LineRenderingConfig gives all details onto how to render a single line of a feature.
@ -10,40 +10,69 @@ import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
*/
export default interface LineRenderingConfigJson {
/**
* The color for way-elements and SVG-elements.
* question: What color should lines be drawn in?
*
* For an area, this will be the colour of the outside line.
* If the value starts with "--", the style of the body element will be queried for the corresponding variable instead
*
* types: dynamic value ; string
* title: Line Colour
* inline: The line colour always is <b>{value}</b>
* ifunset: Round ending
* type: color
*
*/
color?: string | TagRenderingConfigJson
color?: MinimalTagRenderingConfigJson | string
/**
* question: How wide should the line be?
* The stroke-width for way-elements
*
* types: dynamic value ; string
* title: Line width
* inline: The line width is <b>{value} pixels</b>
* type: pnat
* ifunset: Use the default-linewidth of 7 pixels
*/
width?: string | number | TagRenderingConfigJson
width?: MinimalTagRenderingConfigJson | number | string
/**
* A dasharray, e.g. "5 6"
* The dasharray defines 'pixels of line, pixels of gap, pixels of line, pixels of gap',
* Default value: "" (empty string == full line)
* question: Should a dasharray be used to render the lines?
* The dasharray defines 'pixels of line, pixels of gap, pixels of line, pixels of gap, ...'. For example, `5 6` will be 5 pixels of line followed by a 6 pixel gap.
* Cannot be a dynamic property due to a mapbox limitation
* ifunset: Ways are rendered with a full line
*/
dashArray?: string | TagRenderingConfigJson
dashArray?: string
/**
* The form at the end of a line
*/
lineCap?: "round" | "square" | "butt" | string | TagRenderingConfigJson
* question: What form should the line-ending have?
* suggestions: return [{if:"value=round",then:"Round endings"}, {if: "value=square", then: "square endings"}, {if: "value=butt", then: "no ending (square ending at the end, without padding)"}]
* types: dynamic value ; string
* title: Line Cap
* ifunset: Use the default value (round ending)
**/
lineCap?: "round" | "square" | "butt" | string | MinimalTagRenderingConfigJson
/**
* The color to fill a polygon with.
* If undefined, this will be slightly more opaque version of the stroke line.
* Use '#00000000' to make the fill invisible
* question: What colour should be used as fill colour for polygons?
* ifunset: The polygon fill colour will be a more transparent version of the stroke colour
* suggestions: return [{if: "value=#00000000", then: "Use a transparent fill (only render the outline)"}]
* inline: The fill colour is <b>{value}</b>
* types: dynamic value ; string
* type: color
*/
fillColor?: string | TagRenderingConfigJson
fillColor?: string | MinimalTagRenderingConfigJson
/**
* question: Should the lines be moved (offsetted) with a number of pixels against the geographical lines?
* The number of pixels this line should be moved.
* Use a positive numbe to move to the right, a negative to move to the left (left/right as defined by the drawing direction of the line).
* Use a positive number to move to the right in the drawing direction or a negative to move to the left (left/right as defined by the drawing direction of the line).
*
* IMPORTANT: MapComplete will already normalize 'key:both:property' and 'key:both' into the corresponding 'key:left' and 'key:right' tagging (same for 'sidewalk=left/right/both' which is rewritten to 'sidewalk:left' and 'sidewalk:right')
* This simplifies programming. Refer to the CalculatedTags.md-documentation for more details
* ifunset: don't offset lines on the map
* inline: Pixel offset by <b>{value}</b> pixels
* types: dynamic value ; number
* type: int
*/
offset?: number | TagRenderingConfigJson
offset?: number | MinimalTagRenderingConfigJson
}

View file

@ -1,6 +1,11 @@
import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
import { TagConfigJson } from "./TagConfigJson"
export interface IconConfigJson {
icon: string | TagRenderingConfigJson | { builtin: string; override: any }
color?: string | TagRenderingConfigJson | { builtin: string; override: any }
}
/**
* The PointRenderingConfig gives all details onto how to render a single point of a feature.
*
@ -11,28 +16,26 @@ import { TagConfigJson } from "./TagConfigJson"
*/
export default interface PointRenderingConfigJson {
/**
* All the locations that this point should be rendered at.
* Possible values are:
* - `point`: only renders points at their location
* - `centroid`: show a symbol at the centerpoint of a (multi)Linestring and (multi)polygon. Points will _not_ be rendered with this
* - `projected_centerpoint`: Only on (multi)linestrings: calculate the centerpoint and snap it to the way
* - `start` and `end`: only on linestrings: add a point to the first/last coordinate of the LineString
* question: At what location should this icon be shown?
* multianswer: true
* suggestions: return [{if: "value=point",then: "Show an icon for point (node) objects"},{if: "value=centroid",then: "Show an icon for line or polygon (way) objects at their centroid location"}, {if: "value=start",then: "Show an icon for line (way) objects at the start"},{if: "value=end",then: "Show an icon for line (way) object at the end"},{if: "value=projected_centerpoint",then: "Show an icon for line (way) object near the centroid location, but moved onto the line"}]
*/
location: ("point" | "centroid" | "start" | "end" | "projected_centerpoint" | string)[]
/**
* The icon for an element.
* Note that this also doubles as the icon for this layer (rendered with the overpass-tags) ánd the icon in the presets.
*
* The result of the icon is rendered as follows:
* the resulting string is interpreted as a _list_ of items, separated by ";". The bottommost layer is the first layer.
* As a result, on could use a generic pin, then overlay it with a specific icon.
* To make things even more practical, one can use all SVG's from the folder "assets/svg" and _substitute the color_ in it.
* E.g. to draw a red pin, use "pin:#f00", to have a green circle with your icon on top, use `circle:#0f0;<path to my icon.svg>`
* question: What marker should be used to
* The icon for an element.
* Note that this also doubles as the icon for this layer (rendered with the overpass-tags) ánd the icon in the presets.
*
* The result of the icon is rendered as follows:
* the resulting string is interpreted as a _list_ of items, separated by ";". The bottommost layer is the first layer.
* As a result, on could use a generic pin, then overlay it with a specific icon.
* To make things even more practical, one c an use all SVG's from the folder "assets/svg" and _substitute the color_ in it.
* E.g. to draw a red pin, use "pin:#f00", to have a green circle with your icon on top, use `circle:#0f0;<path to my icon.svg>`
* Type: icon
*/
icon?: string | TagRenderingConfigJson
* Type: icon
*/
marker?: IconConfigJson[]
/**
* A list of extra badges to show next to the icon as small badge
@ -59,8 +62,9 @@ export default interface PointRenderingConfigJson {
* question: What is the anchorpoint of the icon?
*
* This matches the geographical point with a location on the icon.
* For example, a feature attached to the ground can use 'bottom' as zooming in will give the appearance of being anchored to a fixed location.
*
* ifunset: Use MapComplete-default (<b>center</b>)
* suggestions: return [{if: "value=center", then: "Place the <b>center</b> of the icon on the geographical location"},{if: "value=top", then: "Place the <b>top</b> of the icon on the geographical location"},{if: "value=bottom", then: "Place the <b>bottom</b> of the icon on the geographical location"},{if: "value=left", then: "Place the <b>left</b> of the icon on the geographical location"},{if: "value=right", then: "Place the <b>right</b> of the icon on the geographical location"}]
*/
anchor?: "center" | "top" | "bottom" | "left" | "right" | string | TagRenderingConfigJson
@ -70,31 +74,52 @@ export default interface PointRenderingConfigJson {
*/
rotation?: string | TagRenderingConfigJson
/**
* A HTML-fragment that is shown below the icon, for example:
* <div style="background: white">{name}</div>
* question: What label should be shown beneath the marker?
* For example: <div style="background: white">{name}</div>
*
* If the icon is undefined, then the label is shown in the center of the feature.
* Note that, if the wayhandling hides the icon then no label is shown as well.
* types: Dynamic value | string
* inline: Always show label <b>{value}</b> beneath the marker
*/
label?: string | TagRenderingConfigJson
/**
* A snippet of css code which is applied onto the container of the entire marker
* question: What CSS should be applied to the entire marker?
* You can set the css-properties here, e.g. `background: red; font-size: 12px; `
* This will be applied to the _container_ containing both the marker and the label
* inline: Apply CSS-style <b>{value}</b> to the _entire marker_
* types: Dynamic value ; string
*/
css?: string | TagRenderingConfigJson
/**
* A snippet of css-classes which are applied onto the container of the entire marker. They can be space-separated
* question: Which CSS-classes should be applied to the entire marker?
* This will be applied to the _container_ containing both the marker and the label
*
* The classes should be separated by a space (` `)
* You can use most Tailwind-css classes, see https://tailwindcss.com/ for more information
* For example: `center bg-gray-500 mx-2 my-1 rounded-full`
* inline: Apply CSS-classes <b>{value}</b> to the entire container
* types: Dynamic value ; string
*/
cssClasses?: string | TagRenderingConfigJson
/**
* Css that is applied onto the label
* question: What CSS should be applied to the label?
* You can set the css-properties here, e.g. `background: red; font-size: 12px; `
* inline: Apply CSS-style <b>{value}</b> to the label
* types: Dynamic value ; string
*/
labelCss?: string | TagRenderingConfigJson
labelCss?: TagRenderingConfigJson | string
/**
* Css classes that are applied onto the label; can be space-separated
* question: Which CSS-classes should be applied to the label?
*
* The classes should be separated by a space (` `)
* You can use most Tailwind-css classes, see https://tailwindcss.com/ for more information
* For example: `center bg-gray-500 mx-2 my-1 rounded-full`
* inline: Apply CSS-classes <b>{value}</b> to the label
* types: Dynamic value ; string
*/
labelCssClasses?: string | TagRenderingConfigJson
@ -105,7 +130,9 @@ export default interface PointRenderingConfigJson {
pitchAlignment?: "canvas" | "map" | TagRenderingConfigJson
/**
* If the map is rotated, the icon will still point to the north if no rotation was applied
* question: Should the icon be rotated or tilted if the map is rotated or tilted?
* ifunset: Do not rotate or tilt icons. Always keep the icons straight
* suggestions: return [{if: "value=canvas", then: "If the map is tilted, tilt the icon as well. This gives the impression of an icon that is glued to the ground."}, {if: "value=map", then: "If the map is rotated, rotate the icon as well. This gives the impression of an icon that floats perpendicular above the ground."}]
*/
rotationAlignment?: "map" | "canvas" | TagRenderingConfigJson
}

View file

@ -1,6 +1,6 @@
import { TagConfigJson } from "./TagConfigJson"
import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
import { Translatable } from "./Translatable"
import type { Translatable } from "./Translatable"
export interface MappingConfigJson {
/**

View file

@ -1,6 +1,43 @@
import { TagConfigJson } from "./TagConfigJson"
import { Translatable } from "./Translatable"
/**
* Mostly used for lineRendering and pointRendering
*/
export interface MinimalTagRenderingConfigJson {
/**
* question: What value should be rendered?
*
* This piece of text will be shown in the infobox.
* Note that "&LBRACEkey&RBRACE"-parts are substituted by the corresponding values of the element.
*
* This value will be used if there is no mapping which matches (or there are no matches)
* Note that this is a HTML-interpreted value, so you can add links as e.g. '&lt;a href='{website}'>{website}&lt;/a>' or include images such as `This is of type A &lt;br>&lt;img src='typeA-icon.svg' />`
*/
render?: string
/**
* Allows fixed-tag inputs, shown either as radiobuttons or as checkboxes
*/
mappings?: {
/**
* question: When should this single mapping match?
*
* If this condition is met, then the text under `then` will be shown.
* If no value matches, and the user selects this mapping as an option, then these tags will be uploaded to OSM.
*
* For example: {'if': 'diet:vegetarion=yes', 'then':'A vegetarian option is offered here'}
*
* This can be an substituting-tag as well, e.g. {'if': 'addr:street:={_calculated_nearby_streetname}', 'then': '{_calculated_nearby_streetname}'}
*/ if: TagConfigJson
/**
* question: What text should be shown?
*
* If the condition `if` is met, the text `then` will be rendered.
* If not known yet, the user will be presented with `then` as an option
*/ then: string
}[]
}
/**
* A TagRenderingConfigJson is a single piece of code which converts one ore more tags into a HTML-snippet.
* For an _editable_ tagRendering, use 'QuestionableTagRenderingConfigJson' instead, which extends this one