mapcomplete/Models/Constants.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

155 lines
5.6 KiB
TypeScript
Raw Normal View History

import { Utils } from "../Utils"
2023-05-06 11:05:19 +02:00
import * as meta from "../package.json"
2023-05-08 01:58:33 +02:00
export type PriviligedLayerType = typeof Constants.priviliged_layers[number]
export default class Constants {
2023-05-06 11:05:19 +02:00
public static vNumber = meta.version
public static ImgurApiKey = "7070e7167f0a25a"
public static readonly mapillary_client_token_v4 =
"MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"
2022-07-13 16:12:25 +02:00
/**
* API key for Maproulette
*
* Currently there is no user-friendly way to get the user's API key.
* See https://github.com/maproulette/maproulette2/issues/476 for more information.
* Using an empty string however does work for most actions, but will attribute all actions to the Superuser.
*/
2022-07-13 10:03:09 +02:00
public static readonly MaprouletteApiKey = ""
2021-09-29 16:55:05 +02:00
public static defaultOverpassUrls = [
// The official instance, 10000 queries per day per project allowed
"https://overpass-api.de/api/interpreter",
// 'Fair usage'
"https://overpass.kumi.systems/api/interpreter",
// Offline: "https://overpass.nchc.org.tw/api/interpreter",
2021-09-29 16:55:05 +02:00
"https://overpass.openstreetmap.ru/cgi/interpreter",
// Doesn't support nwr: "https://overpass.openstreetmap.fr/api/interpreter"
2021-09-29 16:55:05 +02:00
]
2023-03-25 02:48:24 +01:00
public static readonly added_by_default = [
"selected_element",
2021-12-21 18:35:31 +01:00
"gps_location",
"gps_location_history",
"home_location",
"gps_track",
2023-03-25 02:48:24 +01:00
"range",
"last_click",
2023-03-25 02:48:24 +01:00
] as const
/**
* Special layers which are not included in a theme by default
*/
public static readonly no_include = [
2022-01-26 21:40:38 +01:00
"conflation",
"split_point",
"split_road",
2022-01-26 21:40:38 +01:00
"current_view",
"matchpoint",
"import_candidate",
"usersettings",
2023-03-25 02:48:24 +01:00
] as const
2021-12-21 18:35:31 +01:00
/**
* Layer IDs of layers which have special properties through built-in hooks
*/
2023-03-25 02:48:24 +01:00
public static readonly priviliged_layers = [
...Constants.added_by_default,
...Constants.no_include,
2023-03-25 02:48:24 +01:00
] as const
2021-12-21 18:35:31 +01:00
// The user journey states thresholds when a new feature gets unlocked
public static userJourney = {
2021-03-16 19:35:19 +01:00
moreScreenUnlock: 1,
2021-06-28 18:06:54 +02:00
personalLayoutUnlock: 5,
historyLinkVisible: 10,
deletePointsOfOthersUnlock: 20,
2021-03-17 14:35:06 +01:00
tagsVisibleAt: 25,
2021-03-16 19:35:19 +01:00
tagsVisibleAndWikiLinked: 30,
2021-06-28 18:06:54 +02:00
mapCompleteHelpUnlock: 50,
themeGeneratorReadOnlyUnlock: 50,
themeGeneratorFullUnlock: 500,
addNewPointWithUnreadMessagesUnlock: 500,
2022-01-18 21:26:07 +01:00
importHelperUnlock: 5000,
}
static readonly minZoomLevelToAddNewPoint = Constants.isRetina() ? 18 : 19
/**
* Used by 'PendingChangesUploader', which waits this amount of seconds to upload changes.
* (Note that pendingChanges might upload sooner if the popup is closed or similar)
*/
static updateTimeoutSec: number = 30
/**
* If the contributor has their GPS location enabled and makes a change,
* the points visited less then `nearbyVisitTime`-seconds ago will be inspected.
* The point closest to the changed feature will be considered and this distance will be tracked.
* ALl these distances are used to calculate a nearby-score
*/
2022-01-26 21:40:38 +01:00
static nearbyVisitTime: number = 30 * 60
/**
* If a user makes a change, the distance to the changed object is calculated.
* If a user makes multiple changes, all these distances are put into multiple bins, depending on this distance.
* For every bin, the totals are uploaded as metadata
*/
2022-01-26 21:40:38 +01:00
static distanceToChangeObjectBins = [25, 50, 100, 500, 1000, 5000, Number.MAX_VALUE]
static themeOrder = [
"personal",
"cyclofix",
"waste",
"etymology",
"food",
"cafes_and_pubs",
"playgrounds",
"hailhydrant",
"toilets",
"aed",
"bookcases",
2022-09-08 21:40:48 +02:00
]
/**
* Upon initialization, the GPS will search the location.
* If the location is found within the given timout, it'll automatically fly to it.
*
* In seconds
*/
2023-02-09 03:12:21 +01:00
static zoomToLocationTimeout = 15
static countryCoderEndpoint: string =
"https://raw.githubusercontent.com/pietervdvn/MapComplete-data/main/latlon2country"
public static readonly OsmPreferenceKeyPicturesLicense = "pictures-license"
2023-05-08 01:58:33 +02:00
/**
* These are the values that are allowed to use as 'backdrop' icon for a map pin
*/
private static readonly _defaultPinIcons = [
"square",
"circle",
"none",
"pin",
"person",
"plus",
"ring",
"star",
"teardrop",
"triangle",
"crosshair",
] as const
2023-05-08 01:58:33 +02:00
public static readonly defaultPinIcons: string[] = <any>Constants._defaultPinIcons
2021-01-06 02:21:50 +01:00
private static isRetina(): boolean {
2022-06-02 03:02:35 +02:00
if (Utils.runningFromConsole) {
return false
}
2021-01-06 02:21:50 +01:00
// The cause for this line of code: https://github.com/pietervdvn/MapComplete/issues/115
// See https://stackoverflow.com/questions/19689715/what-is-the-best-way-to-detect-retina-support-on-a-device-using-javascript
return (
(window.matchMedia &&
(window.matchMedia(
"only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx), only screen and (min-resolution: 75.6dpcm)"
).matches ||
2021-01-06 02:21:50 +01:00
window.matchMedia(
"only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min--moz-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)"
).matches)) ||
(window.devicePixelRatio && window.devicePixelRatio >= 2)
2022-09-08 21:40:48 +02:00
)
2021-01-06 02:21:50 +01:00
}
2021-03-31 11:39:56 +02:00
}