- // modules/osm/tags.js
- function osmIsInterestingTag(key) {
- return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon
- key.indexOf("tiger:") !== 0;
- }
- var osmLifecyclePrefixes = {
- // nonexistent, might be built
- proposed: true,
- planned: true,
- // under maintentance or between groundbreaking and opening
- construction: true,
- // existent but not functional
- disused: true,
- // dilapidated to nonexistent
- abandoned: true,
- was: true,
- // nonexistent, still may appear in imagery
- dismantled: true,
- razed: true,
- demolished: true,
- destroyed: true,
- removed: true,
- obliterated: true,
- // existent occasionally, e.g. stormwater drainage basin
- intermittent: true
- };
- function osmRemoveLifecyclePrefix(key) {
- const keySegments = key.split(":");
- if (keySegments.length === 1)
- return key;
- if (keySegments[0] in osmLifecyclePrefixes) {
- return key.slice(keySegments[0].length + 1);
- }
- return key;
- }
- var osmAreaKeys = {};
- function osmSetAreaKeys(value) {
- osmAreaKeys = value;
- }
- var osmAreaKeysExceptions = {
- highway: {
- elevator: true,
- rest_area: true,
- services: true
- },
- public_transport: {
- platform: true
- },
- railway: {
- platform: true,
- roundhouse: true,
- station: true,
- traverser: true,
- turntable: true,
- wash: true
- },
- waterway: {
- dam: true
- }
- };
- function osmTagSuggestingArea(tags) {
- if (tags.area === "yes")
- return { area: "yes" };
- if (tags.area === "no")
- return null;
- var returnTags = {};
- for (var realKey in tags) {
- const key = osmRemoveLifecyclePrefix(realKey);
- if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) {
- returnTags[realKey] = tags[realKey];
- return returnTags;
- }
- if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) {
- returnTags[realKey] = tags[realKey];
- return returnTags;
- }
- }
- return null;
- }
- var osmLineTags = {};
- function osmSetLineTags(value) {
- osmLineTags = value;
- }
- var osmPointTags = {};
- function osmSetPointTags(value) {
- osmPointTags = value;
- }
- var osmVertexTags = {};
- function osmSetVertexTags(value) {
- osmVertexTags = value;
- }
- function osmNodeGeometriesForTags(nodeTags) {
- var geometries = {};
- for (var key in nodeTags) {
- if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) {
- geometries.point = true;
- }
- if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) {
- geometries.vertex = true;
- }
- if (geometries.point && geometries.vertex)
- break;
- }
- return geometries;
- }
- var osmOneWayTags = {
- "aerialway": {
- "chair_lift": true,
- "drag_lift": true,
- "j-bar": true,
- "magic_carpet": true,
- "mixed_lift": true,
- "platter": true,
- "rope_tow": true,
- "t-bar": true,
- "zip_line": true
- },
- "highway": {
- "motorway": true
- },
- "junction": {
- "circular": true,
- "roundabout": true
- },
- "man_made": {
- "goods_conveyor": true,
- "piste:halfpipe": true
- },
- "piste:type": {
- "downhill": true,
- "sled": true,
- "yes": true
- },
- "seamark:type": {
- "two-way_route": true,
- "recommended_traffic_lane": true,
- "separation_lane": true,
- "separation_roundabout": true
- },
- "waterway": {
- "canal": true,
- "ditch": true,
- "drain": true,
- "fish_pass": true,
- "pressurised": true,
- "river": true,
- "spillway": true,
- "stream": true,
- "tidal_channel": true
- }
- };
- var osmPavedTags = {
- "surface": {
- "paved": true,
- "asphalt": true,
- "concrete": true,
- "chipseal": true,
- "concrete:lanes": true,
- "concrete:plates": true
- },
- "tracktype": {
- "grade1": true
- }
- };
- var osmSemipavedTags = {
- "surface": {
- "cobblestone": true,
- "cobblestone:flattened": true,
- "unhewn_cobblestone": true,
- "sett": true,
- "paving_stones": true,
- "metal": true,
- "wood": true
- }
- };
- var osmRightSideIsInsideTags = {
- "natural": {
- "cliff": true,
- "coastline": "coastline"
- },
- "barrier": {
- "retaining_wall": true,
- "kerb": true,
- "guard_rail": true,
- "city_wall": true
- },
- "man_made": {
- "embankment": true,
- "quay": true
- },
- "waterway": {
- "weir": true
- }
- };
- var osmRoutableHighwayTagValues = {
- motorway: true,
- trunk: true,
- primary: true,
- secondary: true,
- tertiary: true,
- residential: true,
- motorway_link: true,
- trunk_link: true,
- primary_link: true,
- secondary_link: true,
- tertiary_link: true,
- unclassified: true,
- road: true,
- service: true,
- track: true,
- living_street: true,
- bus_guideway: true,
- busway: true,
- path: true,
- footway: true,
- cycleway: true,
- bridleway: true,
- pedestrian: true,
- corridor: true,
- steps: true
- };
- var osmPathHighwayTagValues = {
- path: true,
- footway: true,
- cycleway: true,
- bridleway: true,
- pedestrian: true,
- corridor: true,
- steps: true
- };
- var osmRailwayTrackTagValues = {
- rail: true,
- light_rail: true,
- tram: true,
- subway: true,
- monorail: true,
- funicular: true,
- miniature: true,
- narrow_gauge: true,
- disused: true,
- preserved: true
- };
- var osmFlowingWaterwayTagValues = {
- canal: true,
- ditch: true,
- drain: true,
- fish_pass: true,
- river: true,
- stream: true,
- tidal_channel: true
- };
- var allowUpperCaseTagValues = /network|taxon|genus|species|brand|grape_variety|royal_cypher|listed_status|booth|rating|stars|:output|_hours|_times|_ref|manufacturer|country|target|brewery|cai_scale|traffic_sign/;
- function isColourValid(value) {
- if (!value.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) {
- return false;
- }
- if (!CSS.supports("color", value) || ["unset", "inherit", "initial", "revert"].includes(value)) {
- return false;
- }
- return true;
- }
- var osmMutuallyExclusiveTagPairs = [
- ["noname", "name"],
- ["noref", "ref"],
- ["nohousenumber", "addr:housenumber"],
- ["noaddress", "addr:housenumber"],
- ["noaddress", "addr:housename"],
- ["noaddress", "addr:unit"],
- ["addr:nostreet", "addr:street"]
- ];
-