2023-09-25 03:13:17 +02:00
|
|
|
import * as packagefile from "../../package.json"
|
|
|
|
import * as extraconfig from "../../config.json"
|
2023-09-02 00:55:07 +02:00
|
|
|
import { Utils } from "../Utils"
|
2023-09-27 22:21:35 +02:00
|
|
|
import { AuthConfig } from "../Logic/Osm/AuthConfig"
|
2023-05-08 01:58:33 +02:00
|
|
|
|
2023-06-14 20:44:01 +02:00
|
|
|
export type PriviligedLayerType = (typeof Constants.priviliged_layers)[number]
|
2024-08-21 14:06:42 +02:00
|
|
|
export type DefaultPinIcon = (typeof Constants._defaultPinIcons)[number]
|
2023-04-19 03:20:49 +02:00
|
|
|
|
2021-01-02 16:04:16 +01:00
|
|
|
export default class Constants {
|
2023-10-16 14:27:05 +02:00
|
|
|
public static vNumber: string = packagefile.version
|
2022-07-13 16:12:25 +02:00
|
|
|
/**
|
|
|
|
* API key for Maproulette
|
|
|
|
*
|
2024-06-27 02:29:53 +02:00
|
|
|
* There is no user-friendly way to get the user's API key currently.
|
2022-07-13 16:12:25 +02:00
|
|
|
* 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 08:03:09 +00:00
|
|
|
public static readonly MaprouletteApiKey = ""
|
2023-03-25 02:48:24 +01:00
|
|
|
public static readonly added_by_default = [
|
2022-12-09 13:58:41 +01:00
|
|
|
"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",
|
2023-04-02 02:59:20 +02:00
|
|
|
"last_click",
|
2023-11-22 19:39:19 +01:00
|
|
|
"favourite",
|
2024-02-15 17:39:59 +01:00
|
|
|
"summary",
|
2024-09-17 02:36:38 +02:00
|
|
|
"search",
|
2024-10-19 14:44:55 +02:00
|
|
|
"geocoded_image",
|
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",
|
2023-04-20 01:52:23 +02:00
|
|
|
"split_road",
|
2022-01-26 21:40:38 +01:00
|
|
|
"current_view",
|
2023-03-29 18:54:00 +02:00
|
|
|
"import_candidate",
|
|
|
|
"usersettings",
|
2024-01-16 04:09:58 +01:00
|
|
|
"icons",
|
2024-12-11 02:45:44 +01:00
|
|
|
"filters",
|
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 = [
|
2022-06-13 03:13:42 +02:00
|
|
|
...Constants.added_by_default,
|
|
|
|
...Constants.no_include,
|
2023-03-25 02:48:24 +01:00
|
|
|
] as const
|
2024-09-26 19:15:20 +02:00
|
|
|
|
2024-10-24 00:56:24 +02:00
|
|
|
public static panoramax: {
|
|
|
|
url: string
|
|
|
|
token: string
|
|
|
|
sequence: string
|
|
|
|
testsequence: string
|
|
|
|
} = packagefile.config.panoramax
|
2024-09-26 19:15:20 +02:00
|
|
|
|
2021-01-02 16:04:16 +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,
|
2024-10-17 04:06:03 +02:00
|
|
|
personalThemeUnlock: 5,
|
2021-06-28 18:06:54 +02:00
|
|
|
historyLinkVisible: 10,
|
2021-07-01 02:26:45 +02:00
|
|
|
deletePointsOfOthersUnlock: 20,
|
2021-03-17 14:35:06 +01:00
|
|
|
tagsVisibleAt: 25,
|
2021-03-16 19:35:19 +01:00
|
|
|
tagsVisibleAndWikiLinked: 30,
|
2021-09-09 00:05:51 +02:00
|
|
|
|
2021-06-28 18:06:54 +02:00
|
|
|
mapCompleteHelpUnlock: 50,
|
2021-03-24 01:25:57 +01:00
|
|
|
themeGeneratorReadOnlyUnlock: 50,
|
2021-01-02 16:04:16 +01:00
|
|
|
addNewPointWithUnreadMessagesUnlock: 500,
|
2021-09-09 00:05:51 +02:00
|
|
|
|
2022-01-18 21:26:07 +01:00
|
|
|
importHelperUnlock: 5000,
|
2021-01-02 16:04:16 +01:00
|
|
|
}
|
2025-06-15 11:52:38 +02:00
|
|
|
static readonly minZoomLevelToAddNewPoint = 18
|
2021-02-20 22:18:42 +01:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
*/
|
2023-10-16 13:38:11 +02:00
|
|
|
static updateTimeoutSec: number = 15
|
2021-11-09 01:49:07 +01:00
|
|
|
/**
|
|
|
|
* 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
|
2021-11-09 01:49:07 +01:00
|
|
|
/**
|
|
|
|
* 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]
|
2022-02-22 16:11:00 +01:00
|
|
|
static themeOrder = [
|
|
|
|
"personal",
|
2024-09-15 00:02:51 +02:00
|
|
|
|
2022-02-22 16:11:00 +01:00
|
|
|
"cyclofix",
|
|
|
|
"etymology",
|
2024-09-15 00:02:51 +02:00
|
|
|
"waste",
|
|
|
|
|
2022-02-22 16:11:00 +01:00
|
|
|
"food",
|
|
|
|
"cafes_and_pubs",
|
2023-09-02 00:07:47 +02:00
|
|
|
"shops",
|
2024-09-15 00:02:51 +02:00
|
|
|
"healthcare",
|
|
|
|
"sports",
|
|
|
|
|
|
|
|
"artwork",
|
|
|
|
"bookcases",
|
2022-02-22 16:11:00 +01:00
|
|
|
"playgrounds",
|
2024-09-15 00:02:51 +02:00
|
|
|
"drinking_water",
|
2022-02-22 16:11:00 +01:00
|
|
|
"toilets",
|
2024-09-15 00:02:51 +02:00
|
|
|
"vending_machine",
|
2022-02-22 16:11:00 +01:00
|
|
|
"aed",
|
2024-09-15 00:02:51 +02:00
|
|
|
"clock",
|
2024-09-18 17:00:14 +02:00
|
|
|
"charging_stations",
|
2024-09-15 00:02:51 +02:00
|
|
|
|
|
|
|
"surveillance",
|
|
|
|
"advertising",
|
|
|
|
"circular_economy",
|
2022-09-08 21:40:48 +02:00
|
|
|
]
|
2022-04-09 19:29:51 +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
|
2023-12-24 05:01:10 +01:00
|
|
|
public static readonly viewportCenterCloseToGpsCutoff: number = 20
|
2023-09-25 03:13:17 +02:00
|
|
|
private static readonly config = (() => {
|
|
|
|
const defaultConfig = packagefile.config
|
|
|
|
return { ...defaultConfig, ...extraconfig }
|
|
|
|
})()
|
|
|
|
public static ImgurApiKey = Constants.config.api_keys.imgur
|
|
|
|
public static readonly mapillary_client_token_v4 = Constants.config.api_keys.mapillary_v4
|
|
|
|
public static defaultOverpassUrls = Constants.config.default_overpass_urls
|
2023-09-27 22:21:35 +02:00
|
|
|
public static countryCoderEndpoint: string = Constants.config.country_coder_host
|
2025-01-27 03:47:50 +01:00
|
|
|
public static communityIndexHost: string = Constants.config.community_index_host
|
|
|
|
|
2023-09-27 22:21:35 +02:00
|
|
|
public static osmAuthConfig: AuthConfig = Constants.config.oauth_credentials
|
2023-09-29 11:13:30 +02:00
|
|
|
public static nominatimEndpoint: string = Constants.config.nominatimEndpoint
|
2024-08-21 14:06:42 +02:00
|
|
|
public static photonEndpoint: string = Constants.config.photonEndpoint
|
2025-04-26 22:39:05 +02:00
|
|
|
public static nsiLogosEndpoint: string = Constants.config.nsi_logos_server ?? null
|
2024-11-14 00:55:51 +01:00
|
|
|
public static weblate: string = "https://translate.mapcomplete.org/"
|
2024-08-21 14:06:42 +02:00
|
|
|
|
2024-02-22 18:58:34 +01:00
|
|
|
public static linkedDataProxy: string = Constants.config["jsonld-proxy"]
|
2023-05-08 01:58:33 +02:00
|
|
|
/**
|
|
|
|
* These are the values that are allowed to use as 'backdrop' icon for a map pin
|
|
|
|
*/
|
2024-08-21 14:06:42 +02:00
|
|
|
public static readonly _defaultPinIcons = [
|
2024-07-29 23:34:41 +02:00
|
|
|
"addSmall",
|
2024-08-21 14:06:42 +02:00
|
|
|
"airport",
|
2024-07-29 23:34:41 +02:00
|
|
|
"brick_wall_round",
|
|
|
|
"brick_wall_square",
|
2024-08-21 14:06:42 +02:00
|
|
|
"building_office_2",
|
2024-08-23 02:16:24 +02:00
|
|
|
"building_storefront",
|
2024-01-17 18:08:14 +01:00
|
|
|
"bug",
|
2024-01-12 23:19:31 +01:00
|
|
|
"checkmark",
|
2024-07-29 23:34:41 +02:00
|
|
|
"checkmark",
|
|
|
|
"circle",
|
2024-01-12 23:19:31 +01:00
|
|
|
"clock",
|
|
|
|
"close",
|
2024-07-29 23:34:41 +02:00
|
|
|
"close",
|
|
|
|
"confirm",
|
|
|
|
"computer",
|
|
|
|
"cross_bottom_right",
|
2024-01-12 23:19:31 +01:00
|
|
|
"crosshair",
|
2024-07-29 23:34:41 +02:00
|
|
|
"desktop",
|
|
|
|
"direction",
|
2024-07-27 02:18:58 +02:00
|
|
|
"gear",
|
2024-08-21 14:06:42 +02:00
|
|
|
"globe_alt",
|
2024-07-29 23:34:41 +02:00
|
|
|
"gps_arrow",
|
|
|
|
"heart",
|
|
|
|
"heart_outline",
|
|
|
|
"help",
|
2024-01-12 23:19:31 +01:00
|
|
|
"help",
|
|
|
|
"home",
|
2024-08-21 14:06:42 +02:00
|
|
|
"house",
|
2024-08-25 00:03:44 +02:00
|
|
|
"key",
|
2024-01-12 23:19:31 +01:00
|
|
|
"invalid",
|
2024-07-29 23:34:41 +02:00
|
|
|
"invalid",
|
|
|
|
"link",
|
2024-01-12 23:19:31 +01:00
|
|
|
"location",
|
|
|
|
"location_empty",
|
|
|
|
"location_locked",
|
2024-08-25 00:03:44 +02:00
|
|
|
"lock",
|
2024-07-29 23:34:41 +02:00
|
|
|
"mastodon",
|
|
|
|
"not_found",
|
2024-01-12 23:19:31 +01:00
|
|
|
"note",
|
2024-07-29 23:34:41 +02:00
|
|
|
"party",
|
2024-08-10 12:09:55 +02:00
|
|
|
"pencil",
|
2024-07-29 23:34:41 +02:00
|
|
|
"pin",
|
2024-01-12 23:19:31 +01:00
|
|
|
"resolved",
|
2023-06-14 20:39:36 +02:00
|
|
|
"ring",
|
2024-01-12 23:19:31 +01:00
|
|
|
"scissors",
|
2025-03-09 23:51:56 +01:00
|
|
|
"snowflake",
|
2024-07-29 23:34:41 +02:00
|
|
|
"square",
|
|
|
|
"square_rounded",
|
2023-06-14 20:39:36 +02:00
|
|
|
"teardrop",
|
2024-01-12 23:19:31 +01:00
|
|
|
"teardrop_with_hole_green",
|
2024-08-21 14:06:42 +02:00
|
|
|
"train",
|
2023-06-14 20:39:36 +02:00
|
|
|
"triangle",
|
2024-08-21 14:06:42 +02:00
|
|
|
"user_circle",
|
2024-08-09 16:55:08 +02:00
|
|
|
"wifi",
|
2023-06-14 20:39:36 +02:00
|
|
|
] as const
|
2023-05-08 01:58:33 +02:00
|
|
|
public static readonly defaultPinIcons: string[] = <any>Constants._defaultPinIcons
|
2024-01-22 01:42:05 +01:00
|
|
|
/**
|
|
|
|
* The location that the MVT-layer is hosted.
|
|
|
|
* This is a MapLibre/MapBox vector tile server which hosts vector tiles for every (official) layer
|
|
|
|
*/
|
|
|
|
public static VectorTileServer: string | undefined = Constants.config.mvt_layer_server
|
2024-06-17 19:27:21 +02:00
|
|
|
public static GeoIpServer: string | undefined = Constants.config.geoip_server
|
2024-06-20 15:12:51 +02:00
|
|
|
public static ErrorReportServer: string | undefined = Constants.config.error_server
|
2024-06-17 19:27:21 +02:00
|
|
|
|
2024-06-12 15:03:10 +02:00
|
|
|
public static readonly SummaryServer: string = Constants.config.summary_server
|
2021-01-06 02:21:50 +01:00
|
|
|
|
2024-07-09 13:42:08 +02:00
|
|
|
public static allServers: string[] = [
|
|
|
|
Constants.SummaryServer,
|
|
|
|
Constants.VectorTileServer,
|
|
|
|
Constants.GeoIpServer,
|
|
|
|
Constants.ErrorReportServer,
|
|
|
|
Constants.countryCoderEndpoint,
|
|
|
|
Constants.osmAuthConfig.url,
|
|
|
|
Constants.nominatimEndpoint,
|
2024-08-21 14:06:42 +02:00
|
|
|
Constants.photonEndpoint,
|
2024-07-09 13:42:08 +02:00
|
|
|
Constants.linkedDataProxy,
|
|
|
|
...Constants.defaultOverpassUrls,
|
|
|
|
]
|
2024-06-27 03:44:52 +02:00
|
|
|
|
2025-02-07 01:37:36 +01:00
|
|
|
private static priviligedLayerSet = new Set<string>(Constants.priviliged_layers)
|
|
|
|
|
|
|
|
public static isPriviliged(layer: string | { id: string }) {
|
|
|
|
let id: string
|
|
|
|
if (typeof layer === "string") {
|
|
|
|
id = layer
|
|
|
|
} else {
|
|
|
|
id = layer.id
|
|
|
|
}
|
|
|
|
return this.priviligedLayerSet.has(id)
|
|
|
|
}
|
2021-03-31 11:39:56 +02:00
|
|
|
}
|