forked from MapComplete/MapComplete
Merge master
This commit is contained in:
commit
80168f5d0d
919 changed files with 95585 additions and 8504 deletions
104
src/Models/ThemeConfig/Json/DeleteConfigJson.ts
Normal file
104
src/Models/ThemeConfig/Json/DeleteConfigJson.ts
Normal file
|
@ -0,0 +1,104 @@
|
|||
import { TagConfigJson } from "./TagConfigJson"
|
||||
|
||||
export interface DeleteConfigJson {
|
||||
/***
|
||||
* By default, the contributor needs 20 previous changesets to delete points edited by others.
|
||||
* For some small features (e.g. bicycle racks) this is too much and this requirement can be lowered or dropped, which can be done here.
|
||||
*
|
||||
* type: nat
|
||||
* question: How many changesets must a contributor have before being allowed to delete a point?
|
||||
*/
|
||||
neededChangesets?: number
|
||||
|
||||
/***
|
||||
* By default, three reasons to delete a point are shown:
|
||||
*
|
||||
* - The point does not exist anymore
|
||||
* - The point was a testing point
|
||||
* - THe point could not be found
|
||||
*
|
||||
* However, for some layers, there might be different or more specific reasons for deletion which can be user friendly to set, e.g.:
|
||||
*
|
||||
* - the shop has closed
|
||||
* - the climbing route has been closed of for nature conservation reasons
|
||||
* - ...
|
||||
*
|
||||
* These reasons can be stated here and will be shown in the list of options the user can choose from
|
||||
*/
|
||||
extraDeleteReasons?: {
|
||||
/**
|
||||
* The text that will be shown to the user as option for why this point does not exist anymore.
|
||||
* Note that the most common reasons (test point, does not exist anymore, cannot be found) are already offered by default
|
||||
*
|
||||
* question: For what extra reason might this feature be removed in real-life?
|
||||
*/
|
||||
explanation: string | any
|
||||
/**
|
||||
* The text that will be uploaded into the changeset or will be used in the fixme in case of a soft deletion
|
||||
* Should be a few words, in english
|
||||
*
|
||||
* question: What should be added to the changeset as delete reason?
|
||||
*/
|
||||
changesetMessage: string
|
||||
}[]
|
||||
|
||||
/**
|
||||
* In some cases, a (starting) contributor might wish to delete a feature even though deletion is not appropriate.
|
||||
* (The most relevant case are small paths running over private property. These should be marked as 'private' instead of deleted, as the community might trace the path again from aerial imagery, gettting us back to the original situation).
|
||||
*
|
||||
* By adding a 'nonDeleteMapping', an option can be added into the list which will retag the feature.
|
||||
* It is important that the feature will be retagged in such a way that it won't be picked up by the layer anymore!
|
||||
*/
|
||||
nonDeleteMappings?: {
|
||||
/**
|
||||
* The tags that will be given to the object.
|
||||
* This must remove tags so that the 'source/osmTags' won't match anymore
|
||||
*
|
||||
* question: What tags should be applied to the object?
|
||||
*/
|
||||
if: TagConfigJson
|
||||
/**
|
||||
* The human explanation for the options
|
||||
*
|
||||
* question: What text should be shown to the contributor for this reason?
|
||||
*/
|
||||
then: string | any
|
||||
}[]
|
||||
|
||||
/**
|
||||
* In some cases, the contributor is not allowed to delete the current feature (e.g. because it isn't a point, the point is referenced by a relation or the user isn't experienced enough).
|
||||
* To still offer the user a 'delete'-option, the feature is retagged with these tags. This is a soft deletion, as the point isn't actually removed from OSM but rather marked as 'disused'
|
||||
* It is important that the feature will be retagged in such a way that it won't be picked up by the layer anymore!
|
||||
*
|
||||
* Example (note that "amenity=" erases the 'amenity'-key alltogether):
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* "and": ["disussed:amenity=public_bookcase", "amenity="]
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* or (notice the use of the ':='-tag to copy the old value of 'shop=*' into 'disused:shop='):
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* "and": ["disused:shop:={shop}", "shop="]
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* question: If a hard delete is not possible, what tags should be applied to mark this feature as deleted?
|
||||
* type: tag
|
||||
*/
|
||||
softDeletionTags?: TagConfigJson
|
||||
|
||||
/**
|
||||
* Set this flag if the default delete reasons should be omitted from the dialog.
|
||||
* This requires at least one extraDeleteReason or nonDeleteMapping
|
||||
*
|
||||
* question: Should the default delete reasons be hidden?
|
||||
* iftrue: Hide the default delete reasons
|
||||
* iffalse: Show the default delete reasons
|
||||
* ifunset: Show the default delete reasons (default behaviour)
|
||||
*/
|
||||
omitDefaultDeleteReasons?: false | boolean
|
||||
}
|
7
src/Models/ThemeConfig/Json/ExtraLinkConfigJson.ts
Normal file
7
src/Models/ThemeConfig/Json/ExtraLinkConfigJson.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
export default interface ExtraLinkConfigJson {
|
||||
icon?: string
|
||||
text?: string | any
|
||||
href: string
|
||||
newTab?: false | boolean
|
||||
requirements?: ("iframe" | "no-iframe" | "welcome-message" | "no-welcome-message")[]
|
||||
}
|
55
src/Models/ThemeConfig/Json/FilterConfigJson.ts
Normal file
55
src/Models/ThemeConfig/Json/FilterConfigJson.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
import { TagConfigJson } from "./TagConfigJson"
|
||||
|
||||
export default interface FilterConfigJson {
|
||||
/**
|
||||
* An id/name for this filter, used to set the URL parameters
|
||||
*/
|
||||
id: string
|
||||
/**
|
||||
* The options for a filter
|
||||
* If there are multiple options these will be a list of radio buttons
|
||||
* If there is only one option this will be a checkbox
|
||||
* Filtering is done based on the given osmTags that are compared to the objects in that layer.
|
||||
*
|
||||
* An example which searches by name:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* "id": "shop-name",
|
||||
* "options": [
|
||||
* {
|
||||
* "fields": [
|
||||
* {
|
||||
* "name": "search",
|
||||
* "type": "string"
|
||||
* }
|
||||
* ],
|
||||
* "osmTags": "name~i~.*{search}.*",
|
||||
* "question": {
|
||||
* "en": "Only show shops with name {search}",
|
||||
* }
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
options: {
|
||||
question: string | any
|
||||
osmTags?: TagConfigJson
|
||||
default?: boolean
|
||||
fields?: {
|
||||
/**
|
||||
* If name is `search`, use "_first_comment~.*{search}.*" as osmTags
|
||||
*/
|
||||
name: string
|
||||
type?: string | "string"
|
||||
}[]
|
||||
}[]
|
||||
|
||||
/**
|
||||
* Used for comments or to disable a check
|
||||
*
|
||||
* "ignore-possible-duplicate": disables a check in `DetectDuplicateFilters` which complains that a filter can be replaced by a filter from the `filters`-library-layer
|
||||
*/
|
||||
"#"?: string | "ignore-possible-duplicate"
|
||||
}
|
536
src/Models/ThemeConfig/Json/LayerConfigJson.ts
Normal file
536
src/Models/ThemeConfig/Json/LayerConfigJson.ts
Normal file
|
@ -0,0 +1,536 @@
|
|||
import { TagConfigJson } from "./TagConfigJson"
|
||||
import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
|
||||
import FilterConfigJson from "./FilterConfigJson"
|
||||
import { DeleteConfigJson } from "./DeleteConfigJson"
|
||||
import UnitConfigJson from "./UnitConfigJson"
|
||||
import MoveConfigJson from "./MoveConfigJson"
|
||||
import PointRenderingConfigJson from "./PointRenderingConfigJson"
|
||||
import LineRenderingConfigJson from "./LineRenderingConfigJson"
|
||||
import { QuestionableTagRenderingConfigJson } from "./QuestionableTagRenderingConfigJson"
|
||||
import RewritableConfigJson from "./RewritableConfigJson"
|
||||
import { Translatable } from "./Translatable"
|
||||
|
||||
/**
|
||||
* Configuration for a single layer
|
||||
*/
|
||||
export interface LayerConfigJson {
|
||||
/**
|
||||
* The id of this layer.
|
||||
* This should be a simple, lowercase, human readable string that is used to identify the layer.
|
||||
*
|
||||
* group: Basic
|
||||
* question: What is the identifier of this layer?
|
||||
*/
|
||||
id: string
|
||||
|
||||
/**
|
||||
* Used in the layer control panel to toggle a layer on and of.
|
||||
*
|
||||
* ifunset: This will hide the layer in the layer control, making it not filterable and not toggleable
|
||||
*
|
||||
* group: Basic
|
||||
* question: What is the name of this layer?
|
||||
*/
|
||||
name?: Translatable
|
||||
|
||||
/**
|
||||
* A description for the features shown in this layer.
|
||||
* This often resembles the introduction of the wiki.osm.org-page for this feature.
|
||||
*
|
||||
* group: Basic
|
||||
* question: How would you describe the features that are shown on this layer?
|
||||
*/
|
||||
description?: Translatable
|
||||
|
||||
/**
|
||||
*
|
||||
* Question: Where should the data be fetched from?
|
||||
*
|
||||
* This determines where the data for the layer is fetched: from OSM or from an external geojson dataset.
|
||||
*
|
||||
* If no 'geojson' is defined, data will be fetched from overpass and the OSM-API.
|
||||
*
|
||||
* Every source _must_ define which tags _must_ be present in order to be picked up.
|
||||
*
|
||||
* Note: a source must always be defined. 'special' is only allowed if this is a builtin-layer
|
||||
*
|
||||
* types: Load data with specific tags from OpenStreetMap ; Load data from an external geojson source ;
|
||||
* typesdefault: 0
|
||||
* group: Basic
|
||||
*/
|
||||
source:
|
||||
| "special"
|
||||
| "special:library"
|
||||
| {
|
||||
/**
|
||||
* question: Which tags must be present on the feature to show it in this layer?
|
||||
*
|
||||
* Every source must set which tags have to be present in order to load the given layer.
|
||||
*/
|
||||
osmTags: TagConfigJson
|
||||
/**
|
||||
* question: How long (in seconds) is the data allowed to remain cached until it must be refreshed?
|
||||
* The maximum amount of seconds that a tile is allowed to linger in the cache
|
||||
*
|
||||
* type: nat
|
||||
* default: 30 days
|
||||
*/
|
||||
maxCacheAge?: number
|
||||
}
|
||||
| {
|
||||
/**
|
||||
* The actual source of the data to load, if loaded via geojson.
|
||||
*
|
||||
* # A single geojson-file
|
||||
* source: {geoJson: "https://my.source.net/some-geo-data.geojson"}
|
||||
* fetches a geojson from a third party source
|
||||
*
|
||||
* # A tiled geojson source
|
||||
* source: {geoJson: "https://my.source.net/some-tile-geojson-{layer}-{z}-{x}-{y}.geojson", geoJsonZoomLevel: 14}
|
||||
* to use a tiled geojson source. The web server must offer multiple geojsons. {z}, {x} and {y} are substituted by the location; {layer} is substituted with the id of the loaded layer
|
||||
*
|
||||
* Some API's use a BBOX instead of a tile, this can be used by specifying {y_min}, {y_max}, {x_min} and {x_max}
|
||||
*
|
||||
* question: What is the URL of the geojson?
|
||||
* type: url
|
||||
*/
|
||||
geoJson: string
|
||||
/**
|
||||
* To load a tiled geojson layer, set the zoomlevel of the tiles
|
||||
*
|
||||
* question: If using a tiled geojson, what is the zoomlevel of the tiles?
|
||||
* ifunset: This is not a tiled geojson
|
||||
*/
|
||||
geoJsonZoomLevel?: number
|
||||
/**
|
||||
* Indicates that the upstream geojson data is OSM-derived.
|
||||
* Useful for e.g. merging or for scripts generating this cache.
|
||||
* This also indicates that making changes on this data is possible
|
||||
*
|
||||
* question: Is this geojson a cache of OpenStreetMap data?
|
||||
* ifunset: This is not an OpenStreetMap cache
|
||||
* iftrue: this is based on OpenStreetMap and can thus be edited
|
||||
*/
|
||||
isOsmCache?: boolean
|
||||
/**
|
||||
* Some API's use a mercator-projection (EPSG:900913) instead of WGS84. Set the flag `mercatorCrs: true` in the source for this
|
||||
*
|
||||
* question: Does this geojson use EPSG:900913 instead of WGS84 as projection?
|
||||
* iftrue: This geojson uses EPSG:900913 instead of WGS84
|
||||
* ifunset: This geojson uses WGS84 just like most geojson (default)
|
||||
*/
|
||||
mercatorCrs?: boolean
|
||||
/**
|
||||
* Some API's have an id-field, but give it a different name.
|
||||
* Setting this key will rename this field into 'id'
|
||||
*
|
||||
* ifunset: An id with key `id` will be assigned automatically if no attribute `id` is set
|
||||
* inline: This geojson uses <b>{value}</b> as attribute to set the id
|
||||
* question: What is the name of the attribute containing the ID of the object?
|
||||
*/
|
||||
idKey?: string
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* A list of extra tags to calculate, specified as "keyToAssignTo=javascript-expression".
|
||||
* There are a few extra functions available. Refer to <a>Docs/CalculatedTags.md</a> for more information
|
||||
* The functions will be run in order, e.g.
|
||||
* [
|
||||
* "_max_overlap_m2=Math.max(...feat.overlapsWith("someOtherLayer").map(o => o.overlap))
|
||||
* "_max_overlap_ratio=Number(feat._max_overlap_m2)/feat.area
|
||||
* ]
|
||||
*
|
||||
* The specified tags are evaluated lazily. E.g. if a calculated tag is only used in the popup (e.g. the number of nearby features),
|
||||
* the expensive calculation will only be performed then for that feature. This avoids clogging up the contributors PC when all features are loaded.
|
||||
*
|
||||
* If a tag has to be evaluated strictly, use ':=' instead:
|
||||
*
|
||||
* [
|
||||
* "_some_key:=some_javascript_expression"
|
||||
* ]
|
||||
*
|
||||
* See the full documentation on [https://github.com/pietervdvn/MapComplete/blob/master/Docs/CalculatedTags.md]
|
||||
*
|
||||
* group: expert
|
||||
* question: What extra attributes should be calculated with javascript?
|
||||
*
|
||||
*/
|
||||
calculatedTags?: string[]
|
||||
|
||||
/**
|
||||
* If set, only features matching this extra tag will be shown.
|
||||
* This is useful to hide certain features from view based on a calculated tag or if the features are provided by a different layer.
|
||||
*
|
||||
* question: What other tags should features match for being shown?
|
||||
* group: advanced
|
||||
* ifunset: all features which match the 'source'-specification are shown.
|
||||
*/
|
||||
isShown?: TagConfigJson
|
||||
|
||||
/**
|
||||
* The minimum needed zoomlevel required to start loading and displaying the data.
|
||||
* This can be used to only show common features (e.g. a bicycle parking) only when the map is zoomed in very much (17).
|
||||
* This prevents cluttering the map with thousands of parkings if one is looking to an entire city.
|
||||
*
|
||||
* Default: 0
|
||||
* group: Basic
|
||||
* type: nat
|
||||
* question: At what zoom level should features of the layer be shown?
|
||||
* ifunset: Always load this layer, even if the entire world is in view.
|
||||
*/
|
||||
minzoom?: number
|
||||
|
||||
/**
|
||||
* Indicates if this layer is shown by default;
|
||||
* can be used to hide a layer from start, or to load the layer but only to show it when appropriate (e.g. for advanced users)
|
||||
*
|
||||
* question: Should this layer be enabled when opening the map for the first time?
|
||||
* iftrue: the layer is enabled when opening the map
|
||||
* iffalse: the layer is hidden until the contributor enables it. (If the filter-popup is disabled, this might never get enabled nor loaded)
|
||||
* default: true
|
||||
* group: advanced
|
||||
*/
|
||||
shownByDefault?: true | boolean
|
||||
|
||||
/**
|
||||
* The zoom level at which point the data is hidden again
|
||||
* Default: 100 (thus: always visible
|
||||
*
|
||||
* group: expert
|
||||
*/
|
||||
minzoomVisible?: number
|
||||
|
||||
/**
|
||||
* The title shown in a popup for elements of this layer.
|
||||
*
|
||||
* group: title
|
||||
* question: What title should be shown on the infobox?
|
||||
* types: use a fixed translation ; Use a dynamic tagRendering ; use a fixed string for all languages
|
||||
* typesdefault: 1
|
||||
*
|
||||
*/
|
||||
title?: TagRenderingConfigJson | Translatable
|
||||
|
||||
/**
|
||||
*
|
||||
* Question: Should the information for this layer be shown in the sidebar or in a splash screen?
|
||||
*
|
||||
* If set, open the selectedElementView in a floatOver instead of on the right.
|
||||
*
|
||||
* iftrue: show the infobox in the splashscreen floating over the entire UI
|
||||
* iffalse: show the infobox in a sidebar on the right
|
||||
* group: advanced
|
||||
* default: sidebar
|
||||
*/
|
||||
popupInFloatover?: boolean
|
||||
|
||||
/**
|
||||
* Small icons shown next to the title.
|
||||
* If not specified, the OsmLink and wikipedia links will be used by default.
|
||||
* Use an empty array to hide them.
|
||||
* Note that "defaults" will insert all the default titleIcons (which are added automatically)
|
||||
*
|
||||
* Type: icon[]
|
||||
* group: infobox
|
||||
*/
|
||||
titleIcons?: (string | TagRenderingConfigJson)[] | ["defaults"]
|
||||
|
||||
/**
|
||||
* Visualisation of the items on the map
|
||||
*
|
||||
* group: maprendering
|
||||
*/
|
||||
mapRendering:
|
||||
| null
|
||||
| (
|
||||
| PointRenderingConfigJson
|
||||
| LineRenderingConfigJson
|
||||
| RewritableConfigJson<
|
||||
| LineRenderingConfigJson
|
||||
| PointRenderingConfigJson
|
||||
| LineRenderingConfigJson[]
|
||||
| PointRenderingConfigJson[]
|
||||
>
|
||||
)[]
|
||||
|
||||
/**
|
||||
* If set, this layer will pass all the features it receives onto the next layer.
|
||||
* This is ideal for decoration, e.g. directions on cameras
|
||||
* iftrue: Make the features from this layer also available to the other layer; might result in this object being rendered by multiple layers
|
||||
* iffalse: normal behaviour: don't pass features allong
|
||||
* question: should this layer pass features to the next layers?
|
||||
* group: expert
|
||||
*/
|
||||
passAllFeatures?: boolean
|
||||
|
||||
/**
|
||||
* If set, this layer will not query overpass; but it'll still match the tags above which are by chance returned by other layers.
|
||||
* Works well together with 'passAllFeatures', to add decoration
|
||||
* The opposite of `forceLoad`
|
||||
*
|
||||
* iftrue: Do not attempt to query the data for this layer from overpass/the OSM API
|
||||
* iffalse: download the data as usual
|
||||
* group: expert
|
||||
* question: Should this layer be downloaded or is the data provided by a different layer (which has 'passAllFeatures'-set)?
|
||||
* default: false
|
||||
*/
|
||||
doNotDownload?: boolean
|
||||
|
||||
/**
|
||||
* Advanced option - might be set by the theme compiler
|
||||
*
|
||||
* If true, this data will _always_ be loaded, even if the theme is disabled by a filter or hidden.
|
||||
* The opposite of `doNotDownload`
|
||||
*
|
||||
* question: Should this layer be forcibly loaded?
|
||||
* ifftrue: always download this layer, even if it is disabled
|
||||
* iffalse: only download data for this layer when needed (default)
|
||||
* default: false
|
||||
* group: expert
|
||||
*/
|
||||
forceLoad?: false | boolean
|
||||
|
||||
/**
|
||||
* Presets for this layer.
|
||||
* A preset shows up when clicking the map on a without data (or when right-clicking/long-pressing);
|
||||
* it will prompt the user to add a new point.
|
||||
*
|
||||
* The most important aspect are the tags, which define which tags the new point will have;
|
||||
* The title is shown in the dialog, along with the first sentence of the description.
|
||||
*
|
||||
* Upon confirmation, the full description is shown beneath the buttons - perfect to add pictures and examples.
|
||||
*
|
||||
* Note: the icon of the preset is determined automatically based on the tags and the icon above. Don't worry about that!
|
||||
* NB: if no presets are defined, the popup to add new points doesn't show up at all
|
||||
*
|
||||
* group: presets
|
||||
*/
|
||||
presets?: {
|
||||
/**
|
||||
* The title - shown on the 'add-new'-button.
|
||||
*
|
||||
* This should include the article of the noun, e.g. 'a hydrant', 'a bicycle pump'.
|
||||
* This text will be inserted into `Add {category} here`, becoming `Add a hydrant here`.
|
||||
*
|
||||
* Do _not_ indicate 'new': 'add a new shop here' is incorrect, as the shop might have existed forever, it could just be unmapped!
|
||||
*
|
||||
* question: What is the word to describe this object?
|
||||
* inline: Add <b>{value}</b> here
|
||||
*/
|
||||
title: Translatable
|
||||
/**
|
||||
* A single tag (encoded as <code>key=value</code>) out of all the tags to add onto the newly created point.
|
||||
* Note that the icon in the UI will be chosen automatically based on the tags provided here.
|
||||
*
|
||||
* question: What tag should be added to the new object?
|
||||
* type: simple_tag
|
||||
*/
|
||||
tags: string[]
|
||||
/**
|
||||
* An extra explanation of what the feature is, if it is not immediately clear from the title alone.
|
||||
*
|
||||
* The _first sentence_ of the description is shown on the button of the `add` menu.
|
||||
* The full description is shown in the confirmation dialog.
|
||||
*
|
||||
* (The first sentence is until the first '.'-character in the description)
|
||||
*
|
||||
* question: How would you describe this feature?
|
||||
*/
|
||||
description?: Translatable
|
||||
|
||||
/**
|
||||
* The URL of an example image which shows a real-life example of what such a feature might look like.
|
||||
*
|
||||
* Type: image
|
||||
* question: What is the URL of an image showing such a feature?
|
||||
*/
|
||||
exampleImages?: string[]
|
||||
|
||||
/**
|
||||
* question: Should the created point be snapped to a line layer?
|
||||
*
|
||||
* If specified, these layers will be shown in the precise location picker and the new point will be snapped towards it.
|
||||
* For example, this can be used to snap against `walls_and_buildings` (e.g. to attach a defibrillator, an entrance, an artwork, ... to the wall)
|
||||
* or to snap an obstacle (such as a bollard) to the `cycleways_and_roads`.
|
||||
*
|
||||
* suggestions: return Array.from(layers.keys()).map(key => ({if: "value="+key, then: key+" - "+layers.get(key).description}))
|
||||
*/
|
||||
snapToLayer?: string[]
|
||||
|
||||
/**
|
||||
* question: What is the maximum distance in the location-input that a point can be moved to be snapped to a way?
|
||||
*
|
||||
* inline: a point is snapped if the location input is at most <b>{value}m</b> away from an object
|
||||
*
|
||||
* If specified, a new point will only be snapped if it is within this range.
|
||||
* If further away, it'll be placed in the center of the location input
|
||||
* Distance in meter
|
||||
*
|
||||
* Default: 10
|
||||
*/
|
||||
maxSnapDistance?: number
|
||||
}[]
|
||||
|
||||
/**
|
||||
* question: Which tagRenderings should be shown in the infobox?
|
||||
*
|
||||
* A tag rendering is a block that either shows the known value or asks a question.
|
||||
*
|
||||
* Refer to the class `TagRenderingConfigJson` to see the possibilities.
|
||||
*
|
||||
* Note that we can also use a string here - where the string refers to a tag rendering defined in `assets/questions/questions.json`,
|
||||
* where a few very general questions are defined e.g. website, phone number, ...
|
||||
* Furthermore, _all_ the questions of another layer can be reused with `otherlayer.*`
|
||||
* If you need only a single of the tagRenderings, use `otherlayer.tagrenderingId`
|
||||
* If one or more questions have a 'group' or 'label' set, select all the entries with the corresponding group or label with `otherlayer.*group`
|
||||
* Remark: if a tagRendering is 'lent' from another layer, the 'source'-tags are copied and added as condition.
|
||||
* If they are not wanted, remove them with an override
|
||||
*
|
||||
* A special value is 'questions', which indicates the location of the questions box. If not specified, it'll be appended to the bottom of the featureInfobox.
|
||||
*
|
||||
* At last, one can define a group of renderings where parts of all strings will be replaced by multiple other strings.
|
||||
* This is mainly create questions for a 'left' and a 'right' side of the road.
|
||||
* These will be grouped and questions will be asked together
|
||||
*
|
||||
* group: tagrenderings
|
||||
*
|
||||
*/
|
||||
tagRenderings?: (
|
||||
| string
|
||||
| {
|
||||
id?: string
|
||||
builtin: string | string[]
|
||||
override: Partial<QuestionableTagRenderingConfigJson>
|
||||
}
|
||||
| QuestionableTagRenderingConfigJson
|
||||
| (RewritableConfigJson<
|
||||
(
|
||||
| string
|
||||
| { builtin: string; override: Partial<QuestionableTagRenderingConfigJson> }
|
||||
| QuestionableTagRenderingConfigJson
|
||||
)[]
|
||||
> & { id: string })
|
||||
)[]
|
||||
|
||||
/**
|
||||
* All the extra questions for filtering.
|
||||
* If a string is given, mapComplete will search in 'filters.json' for the appropriate filter or will try to parse it as `layername.filterid` and us that one
|
||||
*
|
||||
* group: filters
|
||||
*/
|
||||
filter?: (FilterConfigJson | string)[] | { sameAs: string }
|
||||
|
||||
/**
|
||||
* This block defines under what circumstances the delete dialog is shown for objects of this layer.
|
||||
* If set, a dialog is shown to the user to (soft) delete the point.
|
||||
* The dialog is built to be user friendly and to prevent mistakes.
|
||||
* If deletion is not possible, the dialog will hide itself and show the reason of non-deletability instead.
|
||||
*
|
||||
* To configure, the following values are possible:
|
||||
*
|
||||
* - false: never ever show the delete button
|
||||
* - true: show the default delete button
|
||||
* - undefined: use the mapcomplete default to show deletion or not. Currently, this is the same as 'false' but this will change in the future
|
||||
* - or: a hash with options (see below)
|
||||
*
|
||||
* ### The delete dialog
|
||||
*
|
||||
*
|
||||
*
|
||||
* #### Hard deletion if enough experience
|
||||
|
||||
* A feature can only be deleted from OpenStreetMap by mapcomplete if:
|
||||
|
||||
* - It is a node
|
||||
* - No ways or relations use the node
|
||||
* - The logged-in user has enough experience OR the user is the only one to have edited the point previously
|
||||
* - The logged-in user has no unread messages (or has a ton of experience)
|
||||
* - The user did not select one of the 'non-delete-options' (see below)
|
||||
*
|
||||
* In all other cases, a 'soft deletion' is used.
|
||||
*
|
||||
* #### Soft deletion
|
||||
*
|
||||
* A 'soft deletion' is when the point isn't deleted fromOSM but retagged so that it'll won't how up in the mapcomplete theme anymore.
|
||||
* This makes it look like it was deleted, without doing damage. A fixme will be added to the point.
|
||||
*
|
||||
* Note that a soft deletion is _only_ possible if these tags are provided by the theme creator, as they'll be different for every theme
|
||||
*
|
||||
* ##### No-delete options
|
||||
*
|
||||
* In some cases, the contributor might want to delete something for the wrong reason (e.g. someone who wants to have a path removed "because the path is on their private property").
|
||||
* However, the path exists in reality and should thus be on OSM - otherwise the next contributor will pass by and notice "hey, there is a path missing here! Let me redraw it in OSM!)
|
||||
*
|
||||
* The correct approach is to retag the feature in such a way that it is semantically correct *and* that it doesn't show up on the theme anymore.
|
||||
* A no-delete option is offered as 'reason to delete it', but secretly retags.
|
||||
*
|
||||
* group: editing
|
||||
* types: use an advanced delete configuration ; boolean
|
||||
* iftrue: Allow deletion
|
||||
* iffalse: Do not allow deletion
|
||||
*
|
||||
**/
|
||||
deletion?: DeleteConfigJson | boolean
|
||||
|
||||
/**
|
||||
* Indicates if a point can be moved and why.
|
||||
*
|
||||
* A feature can be moved by MapComplete if:
|
||||
*
|
||||
* - It is a point
|
||||
* - The point is _not_ part of a way or a a relation.
|
||||
*
|
||||
* types: use an advanced move configuration ; boolean
|
||||
* group: editing
|
||||
* question: Is deleting a point allowed?
|
||||
* iftrue: Allow contributors to move a point (for accuracy or a relocation)
|
||||
* iffalse: Don't allow contributors to move points
|
||||
* ifunset: Don't allow contributors to move points (default)
|
||||
*/
|
||||
allowMove?: MoveConfigJson | boolean
|
||||
|
||||
/**
|
||||
* If set, a 'split this way' button is shown on objects rendered as LineStrings, e.g. highways.
|
||||
*
|
||||
* If the way is part of a relation, MapComplete will attempt to update this relation as well
|
||||
* question: Should the contributor be able to split ways using this layer?
|
||||
* iftrue: enable the 'split-roads'-component
|
||||
* iffalse: don't enable the split-roads componenet
|
||||
* ifunset: don't enable the split-roads component
|
||||
* group: editing
|
||||
*/
|
||||
allowSplit?: boolean
|
||||
|
||||
/**
|
||||
* @see UnitConfigJson
|
||||
*
|
||||
* group: editing
|
||||
*/
|
||||
units?: UnitConfigJson[]
|
||||
|
||||
/**
|
||||
* If set, synchronizes whether or not this layer is enabled.
|
||||
*
|
||||
* group: advanced
|
||||
* question: Should enabling/disabling the layer be saved (locally or in the cloud)?
|
||||
* suggestions: return [{if: "value=no", then: "Don't save, always revert to the default"}, {if: "value=local", then: "Save selection in local storage"}, {if: "value=theme-only", then: "Save the state in the OSM-usersettings, but apply on this theme only (default)"}, {if: "value=global", then: "Save in OSM-usersettings and toggle on _all_ themes using this layer"}]
|
||||
*/
|
||||
syncSelection?: "no" | "local" | "theme-only" | "global"
|
||||
|
||||
/**
|
||||
* Used for comments and/or to disable some checks
|
||||
*
|
||||
* no-question-hint-check: disables a check in MiscTagRenderingChecks which complains about 'div', 'span' or 'class=subtle'-HTML elements in the tagRendering
|
||||
*
|
||||
* group: hidden
|
||||
*/
|
||||
"#"?: string | "no-question-hint-check"
|
||||
|
||||
/**
|
||||
* _Set automatically by MapComplete, please ignore_
|
||||
*
|
||||
* group: hidden
|
||||
*/
|
||||
fullNodeDatabase?: boolean
|
||||
}
|
309
src/Models/ThemeConfig/Json/LayoutConfigJson.ts
Normal file
309
src/Models/ThemeConfig/Json/LayoutConfigJson.ts
Normal file
|
@ -0,0 +1,309 @@
|
|||
import { LayerConfigJson } from "./LayerConfigJson"
|
||||
import ExtraLinkConfigJson from "./ExtraLinkConfigJson"
|
||||
|
||||
import { RasterLayerProperties } from "../../RasterLayerProperties"
|
||||
|
||||
/**
|
||||
* Defines the entire theme.
|
||||
*
|
||||
* A theme is the collection of the layers that are shown; the intro text, the icon, ...
|
||||
* It more or less defines the entire experience.
|
||||
*
|
||||
* Most of the fields defined here are metadata about the theme, such as its name, description, supported languages, default starting location, ...
|
||||
*
|
||||
* The main chunk of the json will however be the 'layers'-array, where the details of your layers are.
|
||||
*
|
||||
* General remark: a type (string | any) indicates either a fixed or a translatable string.
|
||||
*/
|
||||
export interface LayoutConfigJson {
|
||||
/**
|
||||
* The id of this layout.
|
||||
*
|
||||
* This is used as hashtag in the changeset message, which will read something like "Adding data with #mapcomplete for theme #<the theme id>"
|
||||
* Make sure it is something decent and descriptive, it should be a simple, lowercase string.
|
||||
*
|
||||
* On official themes, it'll become the name of the page, e.g.
|
||||
* 'cyclestreets' which become 'cyclestreets.html'
|
||||
*/
|
||||
id: string
|
||||
|
||||
/**
|
||||
* Who helped to create this theme and should be attributed?
|
||||
*/
|
||||
credits?: string
|
||||
|
||||
/**
|
||||
* Only used in 'generateLayerOverview': if present, every translation will be checked to make sure it is fully translated.
|
||||
*
|
||||
* This must be a list of two-letter, lowercase codes which identifies the language, e.g. "en", "nl", ...
|
||||
*/
|
||||
mustHaveLanguage?: string[]
|
||||
|
||||
/**
|
||||
* The title, as shown in the welcome message and the more-screen.
|
||||
*/
|
||||
title: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* A short description, showed as social description and in the 'more theme'-buttons.
|
||||
* Note that if this one is not defined, the first sentence of 'description' is used
|
||||
*/
|
||||
shortDescription?: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* The description, as shown in the welcome message and the more-screen
|
||||
*/
|
||||
description: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* A part of the description, shown under the login-button.
|
||||
*/
|
||||
descriptionTail?: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* The icon representing this theme.
|
||||
* Used as logo in the more-screen and (for official themes) as favicon, webmanifest logo, ...
|
||||
* Either a URL or a base64 encoded value (which should include 'data:image/svg+xml;base64)
|
||||
*
|
||||
* Type: icon
|
||||
*/
|
||||
icon: string
|
||||
|
||||
/**
|
||||
* Link to a 'social image' which is included as og:image-tag on official themes.
|
||||
* Useful to share the theme on social media.
|
||||
* See https://www.h3xed.com/web-and-internet/how-to-use-og-image-meta-tag-facebook-reddit for more information$
|
||||
*
|
||||
* Type: image
|
||||
*/
|
||||
socialImage?: string
|
||||
|
||||
/**
|
||||
* Default location and zoom to start.
|
||||
* Note that this is barely used. Once the user has visited mapcomplete at least once, the previous location of the user will be used
|
||||
*/
|
||||
startZoom: number
|
||||
startLat: number
|
||||
startLon: number
|
||||
|
||||
/**
|
||||
* When a query is run, the data within bounds of the visible map is loaded.
|
||||
* However, users tend to pan and zoom a lot. It is pretty annoying if every single pan means a reloading of the data.
|
||||
* For this, the bounds are widened in order to make a small pan still within bounds of the loaded data.
|
||||
*
|
||||
* IF widenfactor is 1, this feature is disabled. A recommended value is between 1 and 3
|
||||
*/
|
||||
widenFactor?: number
|
||||
/**
|
||||
* At low zoom levels, overpass is used to query features.
|
||||
* At high zoom level, the OSM api is used to fetch one or more BBOX aligning with a slippy tile.
|
||||
* The overpassMaxZoom controls the flipoverpoint: if the zoom is this or lower, overpass is used.
|
||||
*/
|
||||
overpassMaxZoom?: 17 | number
|
||||
|
||||
/**
|
||||
* When the OSM-api is used to fetch features, it does so in a tiled fashion.
|
||||
* These tiles are using a ceratin zoom level, that can be controlled here
|
||||
* Default: overpassMaxZoom + 1
|
||||
*/
|
||||
osmApiTileSize?: number
|
||||
|
||||
/**
|
||||
* An override applied on all layers of the theme.
|
||||
*
|
||||
* E.g.: if there are two layers defined:
|
||||
* ```
|
||||
* "layers":[
|
||||
* {"title": ..., "tagRenderings": [...], "osmSource":{"tags": ...}},
|
||||
* {"title", ..., "tagRenderings", [...], "osmSource":{"tags" ...}}
|
||||
* ]
|
||||
* ```
|
||||
*
|
||||
* and overrideAll is specified:
|
||||
* ```
|
||||
* "overrideAll": {
|
||||
* "osmSource":{"geoJsonSource":"xyz"}
|
||||
* }
|
||||
* then the result will be that all the layers will have these properties applied and result in:
|
||||
* "layers":[
|
||||
* {"title": ..., "tagRenderings": [...], "osmSource":{"tags": ..., "geoJsonSource":"xyz"}},
|
||||
* {"title", ..., "tagRenderings", [...], "osmSource":{"tags" ..., "geoJsonSource":"xyz"}}
|
||||
* ]
|
||||
* ```
|
||||
*
|
||||
* If the overrideAll contains a list where the keys starts with a plus, the values will be appended (instead of discarding the old list), for example
|
||||
*
|
||||
* "overrideAll": {
|
||||
* "+tagRenderings": [ { ... some tagrendering ... }]
|
||||
* }
|
||||
*
|
||||
* In the above scenario, `sometagrendering` will be added at the beginning of the tagrenderings of every layer
|
||||
*/
|
||||
overrideAll?: Partial<any | LayerConfigJson>
|
||||
|
||||
/**
|
||||
* The id of the default background. BY default: vanilla OSM
|
||||
*/
|
||||
defaultBackgroundId?: string
|
||||
|
||||
/**
|
||||
* Define some (overlay) slippy map tilesources
|
||||
*/
|
||||
tileLayerSources?: (RasterLayerProperties & { defaultState?: true | boolean })[]
|
||||
|
||||
/**
|
||||
* The layers to display.
|
||||
*
|
||||
* Every layer contains a description of which feature to display - the overpassTags which are queried.
|
||||
* Instead of running one query for every layer, the query is fused.
|
||||
*
|
||||
* Afterwards, every layer is given the list of features.
|
||||
* Every layer takes away the features that match with them*, and give the leftovers to the next layers.
|
||||
*
|
||||
* This implies that the _order_ of the layers is important in the case of features with the same tags;
|
||||
* as the later layers might never receive their feature.
|
||||
*
|
||||
* *layers can also remove 'leftover'-features if the leftovers overlap with a feature in the layer itself
|
||||
*
|
||||
* Note that builtin layers can be reused. Either put in the name of the layer to reuse, or use {builtin: "layername", override: ...}
|
||||
*
|
||||
* The 'override'-object will be copied over the original values of the layer, which allows to change certain aspects of the layer
|
||||
*
|
||||
* For example: If you would like to use layer nature reserves, but only from a specific operator (eg. Natuurpunt) you would use the following in your theme:
|
||||
*
|
||||
* ```
|
||||
* "layer": {
|
||||
* "builtin": "nature_reserve",
|
||||
* "override": {"source":
|
||||
* {"osmTags": {
|
||||
* "+and":["operator=Natuurpunt"]
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* It's also possible to load multiple layers at once, for example, if you would like for both drinking water and benches to start at the zoomlevel at 12, you would use the following:
|
||||
*
|
||||
* ```
|
||||
* "layer": {
|
||||
* "builtin": ["benches", "drinking_water"],
|
||||
* "override": {"minzoom": 12}
|
||||
* }
|
||||
*```
|
||||
*/
|
||||
layers: (
|
||||
| LayerConfigJson
|
||||
| string
|
||||
| {
|
||||
builtin: string | string[]
|
||||
override: Partial<LayerConfigJson>
|
||||
/**
|
||||
* TagRenderings with any of these labels will be removed from the layer.
|
||||
* Note that the 'id' and 'group' are considered labels too
|
||||
*/
|
||||
hideTagRenderingsWithLabels?: string[]
|
||||
}
|
||||
)[]
|
||||
|
||||
/**
|
||||
* The URL of a custom CSS stylesheet to modify the layout
|
||||
*/
|
||||
customCss?: string
|
||||
/**
|
||||
* If set to true, this layout will not be shown in the overview with more themes
|
||||
*/
|
||||
hideFromOverview?: boolean
|
||||
|
||||
/**
|
||||
* If set to true, the basemap will not scroll outside of the area visible on initial zoom.
|
||||
* If set to [[lon, lat], [lon, lat]], the map will not scroll outside of those bounds.
|
||||
* Off by default, which will enable panning to the entire world
|
||||
*/
|
||||
lockLocation?: [[number, number], [number, number]] | number[][]
|
||||
|
||||
/**
|
||||
* Adds an additional button on the top-left of the application.
|
||||
* This can link to an arbitrary location.
|
||||
*
|
||||
* Note that {lat},{lon},{zoom}, {language} and {theme} will be replaced
|
||||
*
|
||||
* Default: {icon: "./assets/svg/pop-out.svg", href: 'https://mapcomplete.osm.be/{theme}.html?lat={lat}&lon={lon}&z={zoom}, requirements: ["iframe","no-welcome-message]},
|
||||
*
|
||||
*/
|
||||
extraLink?: ExtraLinkConfigJson
|
||||
|
||||
/**
|
||||
* If set to false, disables logging in.
|
||||
* The userbadge will be hidden, all login-buttons will be hidden and editing will be disabled
|
||||
*/
|
||||
enableUserBadge?: true | boolean
|
||||
/**
|
||||
* If false, hides the tab 'share'-tab in the welcomeMessage
|
||||
*/
|
||||
enableShareScreen?: true | boolean
|
||||
/**
|
||||
* Hides the tab with more themes in the welcomeMessage
|
||||
*/
|
||||
enableMoreQuests?: true | boolean
|
||||
/**
|
||||
* If false, the layer selection/filter view will be hidden
|
||||
* The corresponding URL-parameter is 'fs-filters' instead of 'fs-layers'
|
||||
*/
|
||||
enableLayers?: true | boolean
|
||||
/**
|
||||
* If set to false, hides the search bar
|
||||
*/
|
||||
enableSearch?: true | boolean
|
||||
/**
|
||||
* If set to false, the ability to add new points or nodes will be disabled.
|
||||
* Editing already existing features will still be possible
|
||||
*/
|
||||
enableAddNewPoints?: true | boolean
|
||||
/**
|
||||
* If set to false, the 'geolocation'-button will be hidden.
|
||||
*/
|
||||
enableGeolocation?: true | boolean
|
||||
/**
|
||||
* Enable switching the backgroundlayer.
|
||||
* If false, the quickswitch-buttons are removed (bottom left) and the dropdown in the layer selection is removed as well
|
||||
*/
|
||||
enableBackgroundLayerSelection?: true | boolean
|
||||
/**
|
||||
* If set to true, will show _all_ unanswered questions in a popup instead of just the next one
|
||||
*/
|
||||
enableShowAllQuestions?: false | boolean
|
||||
/**
|
||||
* If set to true, download button for the data will be shown (offers downloading as geojson and csv)
|
||||
*/
|
||||
enableDownload?: true | boolean
|
||||
/**
|
||||
* If set to true, exporting a pdf is enabled
|
||||
*/
|
||||
enablePdfDownload?: true | boolean
|
||||
|
||||
/**
|
||||
* If true, notes will be loaded and parsed. If a note is an import (as created by the import_helper.html-tool from mapcomplete),
|
||||
* these notes will be shown if a relevant layer is present.
|
||||
*
|
||||
* Default is true for official layers and false for unofficial (sideloaded) layers
|
||||
*/
|
||||
enableNoteImports?: true | boolean
|
||||
|
||||
/**
|
||||
* Set one or more overpass URLs to use for this theme..
|
||||
*/
|
||||
overpassUrl?: string | string[]
|
||||
/**
|
||||
* Set a different timeout for overpass queries - in seconds. Default: 30s
|
||||
*/
|
||||
overpassTimeout?: number
|
||||
|
||||
/**
|
||||
* Enables tracking of all nodes when data is loaded.
|
||||
* This is useful for the 'ImportWay' and 'ConflateWay'-buttons who need this database.
|
||||
*
|
||||
* Note: this flag will be automatically set.
|
||||
*/
|
||||
enableNodeDatabase?: boolean
|
||||
}
|
49
src/Models/ThemeConfig/Json/LineRenderingConfigJson.ts
Normal file
49
src/Models/ThemeConfig/Json/LineRenderingConfigJson.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
|
||||
|
||||
/**
|
||||
* The LineRenderingConfig gives all details onto how to render a single line of a feature.
|
||||
*
|
||||
* This can be used if:
|
||||
*
|
||||
* - The feature is a line
|
||||
* - The feature is an area
|
||||
*/
|
||||
export default interface LineRenderingConfigJson {
|
||||
/**
|
||||
* The color for way-elements and SVG-elements.
|
||||
* If the value starts with "--", the style of the body element will be queried for the corresponding variable instead
|
||||
*/
|
||||
color?: string | TagRenderingConfigJson
|
||||
/**
|
||||
* The stroke-width for way-elements
|
||||
*/
|
||||
width?: string | number | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
dashArray?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* The form at the end of a line
|
||||
*/
|
||||
lineCap?: "round" | "square" | "butt" | string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
fillColor?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
offset?: number | TagRenderingConfigJson
|
||||
}
|
21
src/Models/ThemeConfig/Json/MoveConfigJson.ts
Normal file
21
src/Models/ThemeConfig/Json/MoveConfigJson.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
export default interface MoveConfigJson {
|
||||
/**
|
||||
*
|
||||
* question: Should moving this type of point to improve the accuracy be allowed?
|
||||
* iftrue: This point can be moved to improve the accuracy
|
||||
* ifunset: (default) This point can be moved to improve the accuracy
|
||||
* iffalse: This point cannot be moved to improve the accuracy
|
||||
*/
|
||||
enableImproveAccuracy?: true | boolean
|
||||
/**
|
||||
*
|
||||
* question: Should moving this type of point due to a relocation be allowed?
|
||||
*
|
||||
* This will erase the attributes `addr:street`, `addr:housenumber`, `addr:city` and `addr:postcode`
|
||||
*
|
||||
* iftrue: This type of point can be moved due to a relocation (and will remove address information when this is done)
|
||||
* ifunset: (default) This type of point can be moved due to a relocation (and will remove address information when this is done)
|
||||
* iffalse: This type of point cannot be moved due to a relocation
|
||||
*/
|
||||
enableRelocation?: true | boolean
|
||||
}
|
111
src/Models/ThemeConfig/Json/PointRenderingConfigJson.ts
Normal file
111
src/Models/ThemeConfig/Json/PointRenderingConfigJson.ts
Normal file
|
@ -0,0 +1,111 @@
|
|||
import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
|
||||
import { TagConfigJson } from "./TagConfigJson"
|
||||
|
||||
/**
|
||||
* The PointRenderingConfig gives all details onto how to render a single point of a feature.
|
||||
*
|
||||
* This can be used if:
|
||||
*
|
||||
* - The feature is a point
|
||||
* - To render something at the centroid of an area, or at the start, end or projected centroid of a way
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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>`
|
||||
|
||||
* Type: icon
|
||||
*/
|
||||
icon?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* A list of extra badges to show next to the icon as small badge
|
||||
* They will be added as a 25% height icon at the bottom right of the icon, with all the badges in a flex layout.
|
||||
*
|
||||
* Note: strings are interpreted as icons, so layering and substituting is supported. You can use `circle:white;./my_icon.svg` to add a background circle
|
||||
*/
|
||||
iconBadges?: {
|
||||
if: TagConfigJson
|
||||
/**
|
||||
* Badge to show
|
||||
* Type: icon
|
||||
*/
|
||||
then: string | TagRenderingConfigJson
|
||||
}[]
|
||||
|
||||
/**
|
||||
* A string containing "width,height" or "width,height,anchorpoint" where anchorpoint is any of 'center', 'top', 'bottom', 'left', 'right', 'bottomleft','topright', ...
|
||||
* Default is '40,40,center'
|
||||
*/
|
||||
iconSize?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
anchor?: "center" | "top" | "bottom" | "left" | "right" | string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* The rotation of an icon, useful for e.g. directions.
|
||||
* Usage: as if it were a css property for 'rotate', thus has to end with 'deg', e.g. `90deg`, `{direction}deg`, `calc(90deg - {camera:direction}deg)``
|
||||
*/
|
||||
rotation?: string | TagRenderingConfigJson
|
||||
/**
|
||||
* A HTML-fragment that is shown below the icon, 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.
|
||||
*/
|
||||
label?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* A snippet of css code which is applied onto the container of the entire marker
|
||||
*/
|
||||
css?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* A snippet of css-classes which are applied onto the container of the entire marker. They can be space-separated
|
||||
*/
|
||||
cssClasses?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* Css that is applied onto the label
|
||||
*/
|
||||
labelCss?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* Css classes that are applied onto the label; can be space-separated
|
||||
*/
|
||||
labelCssClasses?: string | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* If the map is pitched, the marker will stay parallel to the screen.
|
||||
* Set to 'map' if you want to put it flattened on the map
|
||||
*/
|
||||
pitchAlignment?: "canvas" | "map" | TagRenderingConfigJson
|
||||
|
||||
/**
|
||||
* If the map is rotated, the icon will still point to the north if no rotation was applied
|
||||
*/
|
||||
rotationAlignment?: "map" | "canvas" | TagRenderingConfigJson
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
import { TagConfigJson } from "./TagConfigJson"
|
||||
import { TagRenderingConfigJson } from "./TagRenderingConfigJson"
|
||||
|
||||
export interface MappingConfigJson {
|
||||
/**
|
||||
* quesiton: What tags should be matched to show this option?
|
||||
*
|
||||
* If in 'question'-mode and the contributor selects this option, these tags will be applied to the object
|
||||
*/
|
||||
if: TagConfigJson
|
||||
|
||||
/**
|
||||
* Shown if the 'if is fulfilled
|
||||
* Type: rendered
|
||||
*/
|
||||
then: string | Record<string, string>
|
||||
/**
|
||||
* An extra icon supporting the choice
|
||||
* Type: icon
|
||||
*/
|
||||
icon?:
|
||||
| string
|
||||
| {
|
||||
/**
|
||||
* The path to the icon
|
||||
* Type: icon
|
||||
*/
|
||||
path: string
|
||||
/**
|
||||
* Size of the image
|
||||
*/
|
||||
class?: "small" | "medium" | "large" | string
|
||||
}
|
||||
|
||||
/**
|
||||
* In some cases, multiple taggings exist (e.g. a default assumption, or a commonly mapped abbreviation and a fully written variation).
|
||||
*
|
||||
* In the latter case, a correct text should be shown, but only a single, canonical tagging should be selectable by the user.
|
||||
* In this case, one of the mappings can be hiden by setting this flag.
|
||||
*
|
||||
* To demonstrate an example making a default assumption:
|
||||
*
|
||||
* mappings: [
|
||||
* {
|
||||
* if: "access=", -- no access tag present, we assume accessible
|
||||
* then: "Accessible to the general public",
|
||||
* hideInAnswer: true
|
||||
* },
|
||||
* {
|
||||
* if: "access=yes",
|
||||
* then: "Accessible to the general public", -- the user selected this, we add that to OSM
|
||||
* },
|
||||
* {
|
||||
* if: "access=no",
|
||||
* then: "Not accessible to the public"
|
||||
* }
|
||||
* ]
|
||||
*
|
||||
*
|
||||
* For example, for an operator, we have `operator=Agentschap Natuur en Bos`, which is often abbreviated to `operator=ANB`.
|
||||
* Then, we would add two mappings:
|
||||
* {
|
||||
* if: "operator=Agentschap Natuur en Bos" -- the non-abbreviated version which should be uploaded
|
||||
* then: "Maintained by Agentschap Natuur en Bos"
|
||||
* },
|
||||
* {
|
||||
* if: "operator=ANB", -- we don't want to upload abbreviations
|
||||
* then: "Maintained by Agentschap Natuur en Bos"
|
||||
* hideInAnswer: true
|
||||
* }
|
||||
*
|
||||
* Hide in answer can also be a tagsfilter, e.g. to make sure an option is only shown when appropriate.
|
||||
* Keep in mind that this is reverse logic: it will be hidden in the answer if the condition is true, it will thus only show in the case of a mismatch
|
||||
*
|
||||
* e.g., for toilets: if "wheelchair=no", we know there is no wheelchair dedicated room.
|
||||
* For the location of the changing table, the option "in the wheelchair accessible toilet is weird", so we write:
|
||||
*
|
||||
* {
|
||||
* "question": "Where is the changing table located?"
|
||||
* "mappings": [
|
||||
* {"if":"changing_table:location=female","then":"In the female restroom"},
|
||||
* {"if":"changing_table:location=male","then":"In the male restroom"},
|
||||
* {"if":"changing_table:location=wheelchair","then":"In the wheelchair accessible restroom", "hideInAnswer": "wheelchair=no"},
|
||||
*
|
||||
* ]
|
||||
* }
|
||||
*
|
||||
* Also have a look for the meta-tags
|
||||
* {
|
||||
* if: "operator=Agentschap Natuur en Bos",
|
||||
* then: "Maintained by Agentschap Natuur en Bos",
|
||||
* hideInAnswer: "_country!=be"
|
||||
* }
|
||||
*/
|
||||
hideInAnswer?: boolean | TagConfigJson
|
||||
/**
|
||||
* Only applicable if 'multiAnswer' is set.
|
||||
* This is for situations such as:
|
||||
* `accepts:coins=no` where one can select all the possible payment methods. However, we want to make explicit that some options _were not_ selected.
|
||||
* This can be done with `ifnot`
|
||||
* Note that we can not explicitly render this negative case to the user, we cannot show `does _not_ accept coins`.
|
||||
* If this is important to your usecase, consider using multiple radiobutton-fields without `multiAnswer`
|
||||
*/
|
||||
ifnot?: TagConfigJson
|
||||
|
||||
/**
|
||||
* If chosen as answer, these tags will be applied as well onto the object.
|
||||
* Not compatible with multiAnswer.
|
||||
*
|
||||
* This can be used e.g. to erase other keys which indicate the 'not' value:
|
||||
*```json
|
||||
* {
|
||||
* "if": "crossing:marking=rainbow",
|
||||
* "then": "This is a rainbow crossing",
|
||||
* "addExtraTags": ["not:crossing:marking="]
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
addExtraTags?: string[]
|
||||
|
||||
/**
|
||||
* If there are many options, the mappings-radiobuttons will be replaced by an element with a searchfunction
|
||||
*
|
||||
* Searchterms (per language) allow to easily find an option if there are many options
|
||||
*/
|
||||
searchTerms?: Record<string, string[]>
|
||||
|
||||
/**
|
||||
* If the searchable selector is picked, mappings with this item will have priority and show up even if the others are hidden
|
||||
* Use this sparingly
|
||||
*/
|
||||
priorityIf?: TagConfigJson
|
||||
|
||||
/**
|
||||
* Used for comments or to disable a validation
|
||||
*
|
||||
* ignore-image-in-then: normally, a `then`-clause is not allowed to have an `img`-html-element as icons are preferred. In some cases (most notably title-icons), this is allowed
|
||||
*/
|
||||
"#"?: string | "ignore-image-in-then"
|
||||
}
|
||||
|
||||
/**
|
||||
* A QuestionableTagRenderingConfigJson is a single piece of code which converts one ore more tags into a HTML-snippet.
|
||||
* If the desired tags are missing and a question is defined, a question will be shown instead.
|
||||
*/
|
||||
export interface QuestionableTagRenderingConfigJson extends TagRenderingConfigJson {
|
||||
/**
|
||||
* The id of the tagrendering, should be an unique string.
|
||||
* Used to keep the translations in sync. Only used in the tagRenderings-array of a layerConfig, not requered otherwise.
|
||||
*
|
||||
* question: What is the id of this tagRendering?
|
||||
*/
|
||||
id: string
|
||||
|
||||
/**
|
||||
* Allows fixed-tag inputs, shown either as radiobuttons or as checkboxes
|
||||
*
|
||||
* question: What are common options?
|
||||
*/
|
||||
mappings?: MappingConfigJson[]
|
||||
|
||||
/**
|
||||
* If true, use checkboxes instead of radio buttons when asking the question
|
||||
*
|
||||
* question: Should a contributor be allowed to select multiple mappings?
|
||||
*
|
||||
* iftrue: allow to select multiple mappigns
|
||||
* iffalse: only allow to select a single mapping
|
||||
* ifunset: only allow to select a single mapping
|
||||
*/
|
||||
multiAnswer?: boolean
|
||||
|
||||
/**
|
||||
* Allow freeform text input from the user
|
||||
*/
|
||||
freeform?: {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
key: string
|
||||
|
||||
/**
|
||||
* question: What is the input type?
|
||||
* The type of the text-field, e.g. 'string', 'nat', 'float', 'date',...
|
||||
* See Docs/SpecialInputElements.md and UI/Input/ValidatedTextField.ts for supported values
|
||||
*/
|
||||
type?: string
|
||||
/**
|
||||
* A (translated) text that is shown (as gray text) within the textfield
|
||||
*/
|
||||
placeholder?: string | any
|
||||
|
||||
/**
|
||||
* Extra parameters to initialize the input helper arguments.
|
||||
* For semantics, see the 'SpecialInputElements.md'
|
||||
*/
|
||||
helperArgs?: (string | number | boolean | any)[]
|
||||
/**
|
||||
* If a value is added with the textfield, these extra tag is addded.
|
||||
* Useful to add a 'fixme=freeform textfield used - to be checked'
|
||||
**/
|
||||
addExtraTags?: string[]
|
||||
|
||||
/**
|
||||
* When set, influences the way a question is asked.
|
||||
* Instead of showing a full-width text field, the text field will be shown within the rendering of the question.
|
||||
*
|
||||
* This combines badly with special input elements, as it'll distort the layout.
|
||||
* Note that this will be set automatically if no special elements are present.
|
||||
*/
|
||||
inline?: boolean
|
||||
|
||||
/**
|
||||
* default value to enter if no previous tagging is present.
|
||||
* Normally undefined (aka do not enter anything)
|
||||
*/
|
||||
default?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* If it turns out that this tagRendering doesn't match _any_ value, then we show this question.
|
||||
* If undefined, the question is never asked and this tagrendering is read-only
|
||||
*/
|
||||
question?: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* A hint which is shown in subtle text under the question.
|
||||
* This can give some extra information on what the answer should ook like
|
||||
*/
|
||||
questionHint?: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* A list of labels. These are strings that are used for various purposes, e.g. to filter them away
|
||||
*/
|
||||
labels?: string[]
|
||||
}
|
51
src/Models/ThemeConfig/Json/RewritableConfigJson.ts
Normal file
51
src/Models/ThemeConfig/Json/RewritableConfigJson.ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Rewrites and multiplies the given renderings of type T.
|
||||
*
|
||||
* This can be used for introducing many similar questions automatically,
|
||||
* which also makes translations easier.
|
||||
*
|
||||
* (Note that the key does _not_ need to be wrapped in {}.
|
||||
* However, we recommend to use them if the key is used in a translation, as missing keys will be picked up and warned for by the translation scripts)
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* rewrite: {
|
||||
* sourceString: ["key", "a|b|c"],
|
||||
* into: [
|
||||
* ["X", 0]
|
||||
* ["Y", 1],
|
||||
* ["Z", 2]
|
||||
* ],
|
||||
* renderings: [{
|
||||
* "key":"a|b|c"
|
||||
* }]
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* will result in _three_ copies (as the values to rewrite into have three values, namely:
|
||||
*
|
||||
* [
|
||||
* {
|
||||
* # The first pair: key --> X, a|b|c --> 0
|
||||
* "X": 0
|
||||
* },
|
||||
* {
|
||||
* "Y": 1
|
||||
* },
|
||||
* {
|
||||
* "Z": 2
|
||||
* }
|
||||
*
|
||||
* ]
|
||||
*
|
||||
* @see ExpandRewrite
|
||||
*/
|
||||
export default interface RewritableConfigJson<T> {
|
||||
rewrite: {
|
||||
sourceString: string[]
|
||||
into: (string | any)[][]
|
||||
}
|
||||
renderings: T
|
||||
}
|
14
src/Models/ThemeConfig/Json/TagConfigJson.ts
Normal file
14
src/Models/ThemeConfig/Json/TagConfigJson.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* The main representation of Tags.
|
||||
* See https://github.com/pietervdvn/MapComplete/blob/develop/Docs/Tags_format.md for more documentation
|
||||
*
|
||||
* type: tag
|
||||
*/
|
||||
export type TagConfigJson =
|
||||
| string
|
||||
| {
|
||||
and: TagConfigJson[]
|
||||
}
|
||||
| {
|
||||
or: TagConfigJson[]
|
||||
}
|
155
src/Models/ThemeConfig/Json/TagRenderingConfigJson.ts
Normal file
155
src/Models/ThemeConfig/Json/TagRenderingConfigJson.ts
Normal file
|
@ -0,0 +1,155 @@
|
|||
import { TagConfigJson } from "./TagConfigJson"
|
||||
import { Translatable } from "./Translatable"
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export interface TagRenderingConfigJson {
|
||||
/**
|
||||
* question: What text should be rendered?
|
||||
*
|
||||
* This piece of text will be shown in the infobox.
|
||||
* Note that "{key}"-parts are substituted by the corresponding values of the element.
|
||||
*
|
||||
* This text will be shown if:
|
||||
* - there is no mapping which matches (or there are no matches)
|
||||
* - no question, no mappings and no 'freeform' is set
|
||||
*
|
||||
* Note that this is a HTML-interpreted value, so you can add links as e.g. '<a href='{website}'>{website}</a>' or include images such as `This is of type A <br><img src='typeA-icon.svg' />`
|
||||
* type: rendered
|
||||
*/
|
||||
render?:
|
||||
| Translatable
|
||||
| { special: Record<string, string | Record<string, string>> & { type: string } }
|
||||
|
||||
/**
|
||||
*
|
||||
* question: When should this item be shown?
|
||||
*
|
||||
* Only show this tagrendering (or ask the question) if the selected object also matches the tags specified as `condition`.
|
||||
*
|
||||
* This is useful to ask a follow-up question.
|
||||
* For example, within toilets, asking _where_ the diaper changing table is is only useful _if_ there is one.
|
||||
* This can be done by adding `"condition": "changing_table=yes"`
|
||||
*
|
||||
* A full example would be:
|
||||
* ```json
|
||||
* {
|
||||
* "question": "Where is the changing table located?",
|
||||
* "render": "The changing table is located at {changing_table:location}",
|
||||
* "condition": "changing_table=yes",
|
||||
* "freeform": {
|
||||
* "key": "changing_table:location",
|
||||
* "inline": true
|
||||
* },
|
||||
* "mappings": [
|
||||
* {
|
||||
* "then": "The changing table is in the toilet for women.",
|
||||
* "if": "changing_table:location=female_toilet"
|
||||
* },
|
||||
* {
|
||||
* "then": "The changing table is in the toilet for men.",
|
||||
* "if": "changing_table:location=male_toilet"
|
||||
* },
|
||||
* {
|
||||
* "if": "changing_table:location=wheelchair_toilet",
|
||||
* "then": "The changing table is in the toilet for wheelchair users.",
|
||||
* },
|
||||
* {
|
||||
* "if": "changing_table:location=dedicated_room",
|
||||
* "then": "The changing table is in a dedicated room. ",
|
||||
* }
|
||||
* ],
|
||||
* "id": "toilet-changing_table:location"
|
||||
* },
|
||||
* ```
|
||||
* */
|
||||
condition?: TagConfigJson
|
||||
|
||||
/**
|
||||
*
|
||||
* question: When should this item be shown (including special conditions)?
|
||||
*
|
||||
* If set, this tag will be evaluated agains the _usersettings/application state_ table.
|
||||
* Enable 'show debug info' in user settings to see available options.
|
||||
* Note that values with an underscore depicts _application state_ (including metainfo about the user) whereas values without an underscore depict _user settings_
|
||||
*/
|
||||
metacondition?: TagConfigJson
|
||||
|
||||
/**
|
||||
* question: Should a freeform text field be shown?
|
||||
* Allow freeform text input from the user
|
||||
* ifunset: Do not add a freeform text field
|
||||
* types: Use a freeform value
|
||||
*/
|
||||
freeform?: {
|
||||
/**
|
||||
* What attribute should be filled out
|
||||
* If this key is present in the feature, then 'render' is used to display the value.
|
||||
* If this is undefined, the rendering is _always_ shown
|
||||
*/
|
||||
key: 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
|
||||
* Type: rendered
|
||||
*/
|
||||
then: Translatable
|
||||
/**
|
||||
* question: What icon should be added to this mapping?
|
||||
* An icon supporting this mapping; typically shown pretty small
|
||||
* Type: icon
|
||||
*/
|
||||
icon?:
|
||||
| string
|
||||
| {
|
||||
/**
|
||||
* The path to the icon
|
||||
* Type: icon
|
||||
*/
|
||||
path: string
|
||||
/**
|
||||
* A hint to mapcomplete on how to render this icon within the mapping.
|
||||
* This is translated to 'mapping-icon-<classtype>', so defining your own in combination with a custom CSS is possible (but discouraged)
|
||||
*/
|
||||
class?: "small" | "medium" | "large" | string
|
||||
}
|
||||
}[]
|
||||
|
||||
/**
|
||||
* A human-readable text explaining what this tagRendering does.
|
||||
* Mostly used for the shared tagrenderings
|
||||
*/
|
||||
description?: Translatable
|
||||
|
||||
/**
|
||||
* question: What css-classes should be applied to showing this attribute?
|
||||
*
|
||||
* A list of css-classes to apply to the entire tagRendering.
|
||||
* These classes are applied in 'answer'-mode, not in question mode
|
||||
* This is only for advanced users.
|
||||
*
|
||||
* Values are split on ` ` (space)
|
||||
*/
|
||||
classes?: string
|
||||
}
|
1
src/Models/ThemeConfig/Json/Translatable.ts
Normal file
1
src/Models/ThemeConfig/Json/Translatable.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export type Translatable = string | Record<string, string>
|
146
src/Models/ThemeConfig/Json/UnitConfigJson.ts
Normal file
146
src/Models/ThemeConfig/Json/UnitConfigJson.ts
Normal file
|
@ -0,0 +1,146 @@
|
|||
/**
|
||||
* In some cases, a value is represented in a certain unit (such as meters for heigt/distance/..., km/h for speed, ...)
|
||||
*
|
||||
* Sometimes, multiple denominations are possible (e.g. km/h vs mile/h; megawatt vs kilowatt vs gigawatt for power generators, ...)
|
||||
*
|
||||
* This brings in some troubles, as there are multiple ways to write it (no denomitation, 'm' vs 'meter' 'metre', ...)
|
||||
*
|
||||
* Not only do we want to write consistent data to OSM, we also want to present this consistently to the user.
|
||||
* This is handled by defining units.
|
||||
*
|
||||
* # Rendering
|
||||
*
|
||||
* To render a value with long (human) denomination, use {canonical(key)}
|
||||
*
|
||||
* # Usage
|
||||
*
|
||||
* First of all, you define which keys have units applied, for example:
|
||||
*
|
||||
* ```
|
||||
* units: [
|
||||
* appliesTo: ["maxspeed", "maxspeed:hgv", "maxspeed:bus"]
|
||||
* applicableUnits: [
|
||||
* ...
|
||||
* ]
|
||||
* ]
|
||||
* ```
|
||||
*
|
||||
* ApplicableUnits defines which is the canonical extension, how it is presented to the user, ...:
|
||||
*
|
||||
* ```
|
||||
* applicableUnits: [
|
||||
* {
|
||||
* canonicalDenomination: "km/h",
|
||||
* alternativeDenomination: ["km/u", "kmh", "kph"]
|
||||
* default: true,
|
||||
* human: {
|
||||
* en: "kilometer/hour",
|
||||
* nl: "kilometer/uur"
|
||||
* },
|
||||
* humanShort: {
|
||||
* en: "km/h",
|
||||
* nl: "km/u"
|
||||
* }
|
||||
* },
|
||||
* {
|
||||
* canoncialDenomination: "mph",
|
||||
* ... similar for miles an hour ...
|
||||
* }
|
||||
* ]
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* If this is defined, then every key which the denominations apply to (`maxspeed`, `maxspeed:hgv` and `maxspeed:bus`) will be rewritten at the metatagging stage:
|
||||
* every value will be parsed and the canonical extension will be added add presented to the other parts of the code.
|
||||
*
|
||||
* Also, if a freeform text field is used, an extra dropdown with applicable denominations will be given
|
||||
*
|
||||
*/
|
||||
export default interface UnitConfigJson {
|
||||
/**
|
||||
* Every key from this list will be normalized.
|
||||
*
|
||||
* To render the value properly (with a human readable denomination), use `{canonical(<key>)}`
|
||||
*/
|
||||
appliesToKey: string[]
|
||||
/**
|
||||
* If set, invalid values will be erased in the MC application (but not in OSM of course!)
|
||||
* Be careful with setting this
|
||||
*/
|
||||
eraseInvalidValues?: boolean
|
||||
/**
|
||||
* The possible denominations for this unit.
|
||||
* For length, denominations could be "meter", "kilometer", "miles", "foot"
|
||||
*/
|
||||
applicableUnits: DenominationConfigJson[]
|
||||
|
||||
/**
|
||||
* In some cases, the default denomination is not the most user friendly to input.
|
||||
* E.g., when measuring kerb heights, it is illogical to ask contributors to input an amount in meters.
|
||||
*
|
||||
* When a default input method should be used, this can be specified by setting the canonical denomination here, e.g.
|
||||
* `defaultInput: "cm"`. This must be a denomination which appears in the applicableUnits
|
||||
*/
|
||||
defaultInput?: string
|
||||
}
|
||||
|
||||
export interface DenominationConfigJson {
|
||||
/**
|
||||
* If this evaluates to true and the value to interpret has _no_ unit given, assumes that this unit is meant.
|
||||
* Alternatively, a list of country codes can be given where this acts as the default interpretation
|
||||
*
|
||||
* E.g., a denomination using "meter" would probably set this flag to "true";
|
||||
* a denomination for "mp/h" will use the condition "_country=gb" to indicate that it is the default in the UK.
|
||||
*
|
||||
* If none of the units indicate that they are the default, the first denomination will be used instead
|
||||
*/
|
||||
useIfNoUnitGiven?: boolean | string[]
|
||||
|
||||
/**
|
||||
* The canonical value for this denomination which will be added to the value in OSM.
|
||||
* e.g. "m" for meters
|
||||
* If the user inputs '42', the canonical value will be added and it'll become '42m'.
|
||||
*
|
||||
* Important: often, _no_ canonical values are expected, e.g. in the case of 'maxspeed' where 'km/h' is the default.
|
||||
* In this case, an empty string should be used
|
||||
*/
|
||||
canonicalDenomination: string
|
||||
|
||||
/**
|
||||
* The canonical denomination in the case that the unit is precisely '1'.
|
||||
* Used for display purposes only.
|
||||
*
|
||||
* E.g.: for duration of something in minutes: `2 minutes` but `1 minute`; the `minute` goes here
|
||||
*/
|
||||
canonicalDenominationSingular?: string
|
||||
|
||||
/**
|
||||
* A list of alternative values which can occur in the OSM database - used for parsing.
|
||||
* E.g.: while 'm' is canonical, `meter`, `mtrs`, ... can occur as well
|
||||
*/
|
||||
alternativeDenomination?: string[]
|
||||
|
||||
/**
|
||||
* The value for humans in the dropdown. This should not use abbreviations and should be translated, e.g.
|
||||
* {
|
||||
* "en": "meter",
|
||||
* "fr": "metre"
|
||||
* }
|
||||
*/
|
||||
human?: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* The value for humans in the dropdown. This should not use abbreviations and should be translated, e.g.
|
||||
* {
|
||||
* "en": "minute",
|
||||
* "nl": "minuut"
|
||||
* }
|
||||
*/
|
||||
humanSingular?: string | Record<string, string>
|
||||
|
||||
/**
|
||||
* If set, then the canonical value will be prefixed instead, e.g. for '€'
|
||||
* Note that if all values use 'prefix', the dropdown might move to before the text field
|
||||
*/
|
||||
prefix?: boolean
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue