2020-08-30 01:13:18 +02:00
|
|
|
import {TagRenderingConfigJson} from "./TagRenderingConfigJson";
|
|
|
|
import {AndOrTagConfigJson} from "./TagConfigJson";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* Used in the layer control panel and the 'Personal theme'
|
|
|
|
*/
|
|
|
|
name: string | any
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
/**
|
|
|
|
* This determines where the data for the layer is fetched.
|
|
|
|
* There are some options:
|
2021-03-29 02:53:06 +02:00
|
|
|
*
|
2021-03-20 23:45:52 +01:00
|
|
|
* source: {osmTags: "key=value"} will fetch all objects with given tags from OSM. Currently, this will create a query to overpass and fetch the data - in the future this might fetch from the OSM API
|
2021-04-22 03:30:46 +02:00
|
|
|
* source: {geoJson: "https://my.source.net/some-geo-data.geojson"} to fetch a geojson from a third party source
|
|
|
|
* source: {geoJson: "https://my.source.net/some-tile-geojson-{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
|
2021-03-29 02:53:06 +02:00
|
|
|
*
|
|
|
|
* source: {overpassScript: "<custom overpass tags>"} when you want to do special things. _This should be really rare_.
|
2021-03-20 23:45:52 +01:00
|
|
|
* 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...
|
2021-03-29 02:53:06 +02:00
|
|
|
*
|
|
|
|
*
|
2021-03-21 00:44:23 +01:00
|
|
|
* NOTE: the previous format was 'overpassTags: AndOrTagCOnfigJson | string', which is interpreted as a shorthand for source: {osmTags: "key=value"}
|
|
|
|
* While still supported, this is considered deprecated
|
2021-03-20 23:45:52 +01:00
|
|
|
*/
|
2021-03-29 02:53:06 +02:00
|
|
|
source: { osmTags: AndOrTagConfigJson | string } |
|
2021-04-22 03:30:46 +02:00
|
|
|
{ osmTags: AndOrTagConfigJson | string, geoJson: string, geoJsonZoomLevel?: number } |
|
2021-03-29 02:53:06 +02:00
|
|
|
{ osmTags: AndOrTagConfigJson | string, overpassScript: string }
|
2020-08-30 01:13:18 +02: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-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
|
|
|
|
|
|
|
/**
|
|
|
|
* This tagrendering should either be 'yes' or 'no'. If 'no' is returned, then the feature will be hidden from view.
|
2021-03-26 00:55:36 +01:00
|
|
|
* This is useful to hide certain features from view. Important: hiding features does not work dynamically, but is only calculated when the data is first renders.
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
|
2020-08-30 01:13:18 +02:00
|
|
|
/**
|
|
|
|
* The zoomlevel at which point the data is shown and loaded.
|
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-03-21 01:36:34 +01:00
|
|
|
/**
|
|
|
|
* The zoomlevel at which point the data is hidden again
|
|
|
|
* Default: 100 (thus: always visible
|
|
|
|
*/
|
|
|
|
maxzoom?: 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.
|
|
|
|
* Use an empty array to hide them
|
|
|
|
*/
|
2020-10-27 01:01:34 +01:00
|
|
|
titleIcons?: (string | TagRenderingConfigJson)[];
|
2020-08-30 01:13:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2021-03-29 02:53:06 +02:00
|
|
|
*
|
2020-11-27 13:39:00 +01:00
|
|
|
* The result of the icon is rendered as follows:
|
|
|
|
* the resulting string is interpreted as a _list_ of items, seperated 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 svgs 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>`
|
2021-04-06 18:17:07 +02:00
|
|
|
*
|
2020-08-30 01:13:18 +02:00
|
|
|
*/
|
|
|
|
icon?: string | TagRenderingConfigJson;
|
2020-08-31 02:59:47 +02:00
|
|
|
|
2020-11-27 03:05:29 +01:00
|
|
|
/**
|
|
|
|
* IconsOverlays are a list of extra icons/badges to overlay over the icon.
|
|
|
|
* The 'badge'-toggle changes their behaviour.
|
|
|
|
* If badge is set, it will be added as a 25% height icon at the bottom right of the icon, with all the badges in a flex layout.
|
|
|
|
* If badges is false, it'll be a simple overlay
|
2021-03-29 02:53:06 +02:00
|
|
|
*
|
2020-11-27 13:39:00 +01:00
|
|
|
* Note: strings are interpreted as icons, so layering and substituting is supported
|
2020-11-27 03:05:29 +01:00
|
|
|
*/
|
2021-03-29 02:53:06 +02:00
|
|
|
iconOverlays?: { if: string | AndOrTagConfigJson, then: string | TagRenderingConfigJson, badge?: boolean }[]
|
2020-11-27 03:05:29 +01:00
|
|
|
|
2020-08-31 02:59:47 +02:00
|
|
|
/**
|
2021-03-29 02:53:06 +02:00
|
|
|
* A string containing "width,height" or "width,height,anchorpoint" where anchorpoint is any of 'center', 'top', 'bottom', 'left', 'right', 'bottomleft','topright', ...
|
2020-08-31 02:59:47 +02:00
|
|
|
* Default is '40,40,center'
|
|
|
|
*/
|
|
|
|
iconSize?: string | TagRenderingConfigJson;
|
2020-08-30 01:13:18 +02:00
|
|
|
/**
|
2020-11-17 16:29:51 +01:00
|
|
|
* 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)``
|
2020-11-17 02:22:48 +01:00
|
|
|
*/
|
|
|
|
rotation?: string | TagRenderingConfigJson;
|
2021-04-10 23:53:13 +02:00
|
|
|
/**
|
2021-04-18 14:24:30 +02:00
|
|
|
* A HTML-fragment that is shown below the icon, for example:
|
2021-04-11 00:09:19 +02:00
|
|
|
* <div style="background: white; display: block">{name}</div>
|
2021-04-18 14:24:30 +02:00
|
|
|
*
|
|
|
|
* 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.
|
2021-04-10 23:53:13 +02:00
|
|
|
*/
|
|
|
|
label?: string | TagRenderingConfigJson ;
|
|
|
|
|
2020-11-17 02:22:48 +01:00
|
|
|
/**
|
|
|
|
* 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
|
2020-08-30 01:13:18 +02:00
|
|
|
*/
|
|
|
|
color?: string | TagRenderingConfigJson;
|
|
|
|
/**
|
|
|
|
* The stroke-width for way-elements
|
|
|
|
*/
|
|
|
|
width?: string | TagRenderingConfigJson;
|
|
|
|
|
2020-10-30 00:56:46 +01:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
2020-08-30 01:13:18 +02:00
|
|
|
/**
|
|
|
|
* Wayhandling: should a way/area be displayed as:
|
|
|
|
* 0) The way itself
|
2020-11-19 10:05:10 +01:00
|
|
|
* 1) Only the centerpoint
|
|
|
|
* 2) The centerpoint and the way
|
2020-08-30 01:13:18 +02:00
|
|
|
*/
|
|
|
|
wayHandling?: number;
|
|
|
|
|
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.
|
|
|
|
*/
|
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,
|
|
|
|
}[],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*
|
2020-11-18 13:41:31 +01:00
|
|
|
* Note that we can also use a string here - where the string refers to a tagrenering defined in `assets/questions/questions.json`,
|
|
|
|
* 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
|
|
|
*
|
2020-08-30 01:13:18 +02:00
|
|
|
*/
|
|
|
|
tagRenderings?: (string | TagRenderingConfigJson) []
|
2021-03-29 02:53:06 +02:00
|
|
|
|
|
|
|
|
2020-08-30 01:13:18 +02:00
|
|
|
}
|