2020-08-30 01:13:18 +02:00
import { AndOrTagConfigJson } from "./TagConfigJson" ;
2021-08-07 23:11:34 +02:00
import { TagRenderingConfigJson } from "./TagRenderingConfigJson" ;
2021-07-22 11:29:09 +02:00
import FilterConfigJson from "./FilterConfigJson" ;
2021-08-07 23:11:34 +02:00
import { DeleteConfigJson } from "./DeleteConfigJson" ;
2021-09-13 01:21:47 +02:00
import UnitConfigJson from "./UnitConfigJson" ;
2021-10-14 03:46:09 +02:00
import MoveConfigJson from "./MoveConfigJson" ;
2021-10-19 02:31:32 +02:00
import PointRenderingConfigJson from "./PointRenderingConfigJson" ;
2021-10-20 02:01:27 +02:00
import LineRenderingConfigJson from "./LineRenderingConfigJson" ;
2022-02-28 17:17:38 +01:00
import { QuestionableTagRenderingConfigJson } from "./QuestionableTagRenderingConfigJson" ;
import RewritableConfigJson from "./RewritableConfigJson" ;
2020-08-30 01:13:18 +02:00
/ * *
* 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 .
* /
id : string ;
2021-03-29 02:53:06 +02:00
2020-08-30 01:13:18 +02:00
/ * *
* The name of this layer
2021-05-04 17:47:00 +02:00
* Used in the layer control panel and the 'Personal theme' .
2021-07-03 14:35:44 +02:00
*
2021-05-04 17:47:00 +02:00
* If not given , will be hidden ( and thus not toggable ) in the layer control
2020-08-30 01:13:18 +02:00
* /
2021-05-04 17:47:00 +02:00
name? : string | any
2020-08-30 01:13:18 +02:00
/ * *
* A description for this layer .
2021-01-05 01:30:59 +01:00
* Shown in the layer selections and in the personel theme
2020-08-30 01:13:18 +02:00
* /
description? : string | any ;
2021-03-20 23:45:52 +01:00
/ * *
2022-02-11 03:57:39 +01:00
* This determines where the data for the layer is fetched : from OSM or from an external geojson dataset .
2021-03-29 02:53:06 +02:00
*
2022-02-11 03:57:39 +01:00
* If no 'geojson' is defined , data will be fetched from overpass and the OSM - API .
2021-07-03 14:35:44 +02:00
*
2022-02-11 03:57:39 +01:00
* Every source _must_ define which tags _must_ be present in order to be picked up .
2021-03-29 02:53:06 +02:00
*
2021-03-20 23:45:52 +01:00
* /
2022-02-28 17:17:38 +01:00
source :
2022-02-11 03:57:39 +01:00
( {
/ * *
* Every source must set which tags have to be present in order to load the given layer .
* /
osmTags : AndOrTagConfigJson | string
/ * *
* The maximum amount of seconds that a tile is allowed to linger in the cache
* /
maxCacheAge? : number
} ) &
( { / * # Q u e r y O S M V i a t h e o v e r p a s s A P I w i t h a c u s t o m s c r i p t
* source : { overpassScript : "<custom overpass tags>" } when you want to do special things . _This should be really rare_ .
* This means that the data will be pulled from overpass with this script , and will ignore the osmTags for the query
* However , for the rest of the pipeline , the OsmTags will _still_ be used . This is important to enable layers etc . . .
* /
overpassScript? : string
} |
2022-02-28 17:17:38 +01:00
{
/ * *
* 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 }
* /
geoJson : string ,
/ * *
* To load a tiled geojson layer , set the zoomlevel of the tiles
* /
geoJsonZoomLevel? : number ,
/ * *
* Indicates that the upstream geojson data is OSM - derived .
* Useful for e . g . merging or for scripts generating this cache
* /
isOsmCache? : boolean ,
/ * *
* Some API ' s use a mercator - projection ( EPSG :900913 ) instead of WGS84 . Set the flag ` mercatorCrs: true ` in the source for this
* /
mercatorCrs? : boolean ,
/ * *
* Some API ' s have an id - field , but give it a different name .
* Setting this key will rename this field into 'id'
* /
idKey? : string
} )
2021-11-07 16:34:51 +01:00
2021-03-24 01:25:57 +01:00
/ * *
2021-03-29 02:53:06 +02:00
*
2021-03-26 03:24:58 +01:00
* 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
* ]
2021-03-29 02:53:06 +02:00
*
2021-12-12 02:59:24 +01:00
* 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 .
2022-01-26 21:40:38 +01:00
*
2021-12-12 02:59:24 +01:00
* If a tag has to be evaluated strictly , use ':=' instead :
2022-01-26 21:40:38 +01:00
*
2021-12-12 02:59:24 +01:00
* [
* "_some_key:=some_javascript_expression"
* ]
2022-01-26 21:40:38 +01:00
*
2021-03-24 01:25:57 +01:00
* /
2021-03-29 02:53:06 +02:00
calculatedTags? : string [ ] ;
2021-03-24 01:25:57 +01:00
2020-11-17 02:22:48 +01:00
/ * *
2021-03-29 02:53:06 +02:00
* If set , this layer will not query overpass ; but it ' ll still match the tags above which are by chance returned by other layers .
2020-11-17 02:22:48 +01:00
* Works well together with 'passAllFeatures' , to add decoration
* /
doNotDownload? : boolean ;
2021-03-25 15:19:44 +01:00
/ * *
2021-07-22 10:00:24 +02:00
* This tag rendering should either be 'yes' or 'no' . If 'no' is returned , then the feature will be hidden from view .
2021-11-07 16:34:51 +01:00
* This is useful to hide certain features from view .
*
2021-09-18 02:32:40 +02:00
* Important : hiding features does not work dynamically , but is only calculated when the data is first renders .
2021-03-26 00:55:36 +01:00
* This implies that it is not possible to hide a feature after a tagging change
2021-03-29 02:53:06 +02:00
*
2021-03-25 15:19:44 +01:00
* The default value is 'yes'
* /
isShown? : TagRenderingConfigJson ;
2022-02-07 01:59:07 +01:00
/ * *
* Advanced option - might be set by the theme compiler
2022-02-11 03:57:39 +01:00
*
2022-02-07 01:59:07 +01:00
* If true , this data will _always_ be loaded , even if the theme is disabled
* /
forceLoad? : false | boolean
2021-03-25 15:19:44 +01:00
2020-08-30 01:13:18 +02:00
/ * *
2021-07-27 19:39:57 +02:00
* The minimum needed zoomlevel required before loading of the data start
2021-03-21 01:36:34 +01:00
* Default : 0
2020-08-30 01:13:18 +02:00
* /
2021-03-21 01:36:34 +01:00
minzoom? : number ;
2020-08-30 01:13:18 +02:00
2021-12-03 02:29:25 +01:00
/ * *
* 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 where appropriate ( e . g . for snapping to it )
* /
shownByDefault? : true | boolean ;
2022-01-26 21:40:38 +01:00
2021-03-21 01:36:34 +01:00
/ * *
2021-07-22 10:00:24 +02:00
* The zoom level at which point the data is hidden again
2021-03-21 01:36:34 +01:00
* Default : 100 ( thus : always visible
* /
2021-07-27 19:39:57 +02:00
minzoomVisible? : number ;
2021-03-29 02:53:06 +02:00
2020-08-30 01:13:18 +02:00
/ * *
2020-10-27 01:01:34 +01:00
* The title shown in a popup for elements of this layer .
2020-08-30 01:13:18 +02:00
* /
2020-11-17 02:22:48 +01:00
title? : string | TagRenderingConfigJson ;
/ * *
* Small icons shown next to the title .
* If not specified , the OsmLink and wikipedia links will be used by default .
2021-06-22 03:16:45 +02:00
* Use an empty array to hide them .
2022-01-17 21:33:03 +01:00
* Note that "defaults" will insert all the default titleIcons ( which are added automatically )
2022-02-11 03:57:39 +01:00
*
2022-01-31 00:39:54 +01:00
* Type : icon [ ]
2020-11-17 02:22:48 +01:00
* /
2022-01-17 21:33:03 +01:00
titleIcons ? : ( string | TagRenderingConfigJson ) [ ] | [ "defaults" ] ;
2020-08-30 01:13:18 +02:00
2022-02-28 17:17:38 +01:00
/ * *
* Visualisation of the items on the map
* /
2022-03-08 01:05:54 +01:00
mapRendering : null | ( PointRenderingConfigJson | LineRenderingConfigJson | RewritableConfigJson < LineRenderingConfigJson | PointRenderingConfigJson | LineRenderingConfigJson [ ] | PointRenderingConfigJson [ ] > ) [ ]
2021-07-03 14:35:44 +02:00
2020-11-17 02:22:48 +01:00
/ * *
2021-01-03 03:09:52 +01:00
* If set , this layer will pass all the features it receives onto the next layer .
* This is ideal for decoration , e . g . directionss on cameras
2020-11-17 02:22:48 +01:00
* /
2021-03-29 02:53:06 +02:00
passAllFeatures? : boolean
2020-08-30 01:13:18 +02:00
/ * *
2020-12-09 17:30:11 +01:00
* 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 .
2021-03-29 02:53:06 +02:00
*
2020-12-09 17:30:11 +01:00
* 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 .
2021-03-29 02:53:06 +02:00
*
2020-12-09 17:30:11 +01:00
* Upon confirmation , the full description is shown beneath the buttons - perfect to add pictures and examples .
2021-03-29 02:53:06 +02:00
*
2020-12-09 17:30:11 +01:00
* 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
2020-08-30 01:13:18 +02:00
* /
presets ? : {
2021-03-14 20:40:54 +01:00
/ * *
* The title - shown on the 'add-new' - button .
2022-03-29 21:55:49 +02:00
*
* 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 !
2021-03-14 20:40:54 +01:00
* /
2020-08-30 01:13:18 +02:00
title : string | any ,
2021-03-14 20:40:54 +01:00
/ * *
* The tags to add . It determines the icon too
* /
2020-08-31 02:59:47 +02:00
tags : string [ ] ,
2021-03-14 20:40:54 +01:00
/ * *
* The _first sentence_ of the description is shown on the button of the ` add ` menu .
* The full description is shown in the confirmation dialog .
2021-03-29 02:53:06 +02:00
*
2021-03-14 20:40:54 +01:00
* ( The first sentence is until the first '.' - character in the description )
* /
2020-08-30 01:13:18 +02:00
description? : string | any ,
2021-07-14 00:17:15 +02:00
/ * *
2022-02-09 03:38:40 +01:00
* Example images , which show real - life pictures of what such a feature might look like
2022-02-11 03:57:39 +01:00
*
2022-02-09 22:37:21 +01:00
* Type : image
2022-02-09 03:38:40 +01:00
* /
exampleImages? : string [ ]
/ * *
2021-07-14 00:17:15 +02:00
* If set , the user will prompted to confirm the location before actually adding the data .
2021-07-22 10:00:24 +02:00
* This will be with a 'drag crosshair' - method .
2021-08-07 23:11:34 +02:00
*
2021-07-14 00:17:15 +02:00
* If 'preferredBackgroundCategory' is set , the element will attempt to pick a background layer of that category .
* /
preciseInput? : true | {
2021-08-07 21:19:01 +02:00
/ * *
* The type of background picture
* /
preferredBackground : "osmbasedmap" | "photo" | "historicphoto" | "map" | string | string [ ] ,
/ * *
* If specified , these layers will be shown to and the new point will be snapped towards it
* /
snapToLayer? : string | string [ ] ,
/ * *
* If specified , a new point will only be snapped if it is within this range .
* Distance in meter
*
* Default : 10
* /
maxSnapDistance? : number
2021-07-14 00:17:15 +02:00
}
2020-08-30 01:13:18 +02:00
} [ ] ,
/ * *
* All the tag renderings .
2020-11-17 02:22:48 +01:00
* A tag rendering is a block that either shows the known value or asks a question .
2021-03-29 02:53:06 +02:00
*
2020-11-18 13:41:31 +01:00
* Refer to the class ` TagRenderingConfigJson ` to see the possibilities .
2021-03-29 02:53:06 +02:00
*
2021-07-22 10:00:24 +02:00
* Note that we can also use a string here - where the string refers to a tag rendering defined in ` assets/questions/questions.json ` ,
2020-11-18 13:41:31 +01:00
* where a few very general questions are defined e . g . website , phone number , . . .
2021-03-29 02:53:06 +02:00
*
2020-12-08 23:44:34 +01:00
* 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 .
2021-03-29 02:53:06 +02:00
*
2021-10-23 00:31:41 +02:00
* 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
2020-08-30 01:13:18 +02:00
* /
2022-02-28 17:17:38 +01:00
tagRenderings ? :
( string
| { builtin : string , override : any }
| QuestionableTagRenderingConfigJson
| RewritableConfigJson < ( string | { builtin : string , override : any } | QuestionableTagRenderingConfigJson ) [ ] >
) [ ] ,
2021-03-29 02:53:06 +02:00
2021-07-22 11:29:09 +02:00
/ * *
* All the extra questions for filtering
* /
2022-02-11 03:57:39 +01:00
filter ? : ( FilterConfigJson ) [ ] | { sameAs : string } ,
2021-07-22 11:29:09 +02:00
2021-07-03 14:35:44 +02:00
/ * *
* 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 from OSM 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 .
* /
deletion? : boolean | DeleteConfigJson
2021-03-29 02:53:06 +02:00
2021-10-14 03:46:09 +02:00
/ * *
* Indicates if a point can be moved and configures the modalities .
2021-11-07 16:34:51 +01:00
*
2021-10-14 03:46:09 +02:00
* A feature can be moved by MapComplete if :
2021-11-07 16:34:51 +01:00
*
2021-10-14 03:46:09 +02:00
* - It is a point
* - The point is _not_ part of a way or a a relation .
2021-11-07 16:34:51 +01:00
*
2021-10-14 03:46:09 +02:00
* Off by default . Can be enabled by setting this flag or by configuring .
* /
2021-11-07 16:34:51 +01:00
allowMove? : boolean | MoveConfigJson
2021-10-14 03:46:09 +02:00
2021-07-15 20:47:28 +02:00
/ * *
* IF set , a 'split this road' button is shown
* /
allowSplit? : boolean
2021-09-13 01:21:47 +02:00
/ * *
* 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
*
* /
units? : UnitConfigJson [ ]
2022-02-14 18:18:05 +01:00
/ * *
* If set , synchronizes wether or not this layer is selected .
2022-02-28 17:17:38 +01:00
*
2022-02-14 18:18:05 +01:00
* no : Do not sync at all , always revert to default
* local : keep selection on local storage
* theme - only : sync via OSM , but this layer will only be toggled in this theme
* global : all layers with this ID will be synced accross all themes
* /
syncSelection ? : "no" | "local" | "theme-only" | "global"
2020-08-30 01:13:18 +02:00
}