Merge develop

This commit is contained in:
Pieter Vander Vennet 2023-09-16 19:03:07 +02:00
commit be5f46d8c8
321 changed files with 14942 additions and 4545 deletions

213
scripts/@types/eli.ts Normal file
View file

@ -0,0 +1,213 @@
import { Feature, FeatureCollection } from "geojson"
export interface Eli extends FeatureCollection {
features: EliEntry[]
}
export interface EliEntry extends Feature {
properties: {
/**
* The name of the imagery source
*/
name: string
/**
* Whether the imagery name should be translated
*/
i18n?: boolean
/**
* Type of layer
*/
type: "tms" | "wms" | "bing" | "scanex" | "wms_endpoint" | "wmts"
/**
* A rough categorisation of different types of layers.
* @see https://github.com/osmlab/editor-layer-index/blob/gh-pages/CONTRIBUTING.md#categories
*/
category?:
| "photo"
| "map"
| "historicmap"
| "osmbasedmap"
| "historicphoto"
| "qa"
| "elevation"
| "other"
/**
* A URL template for imagery tiles
*/
url: string
/**
* The minimum zoom level
*/
min_zoom?: number
/**
* The maximum zoom level
*/
max_zoom?: number
/**
* explicit/implicit permission by the owner for use in OSM
*/
permission_osm?: "explicit" | "implicit" | "no"
/**
* A URL for the license or permissions for the imagery
*/
license_url?: string
/**
* A URL for the privacy policy of the operator or false if there is no existing privacy policy for tis imagery.
*/
privacy_policy_url?: string | boolean
/**
* A unique identifier for the source; used in imagery_used changeset tag
*/
id: string
/**
* A short English-language description of the source
*/
description?: string
/**
* The ISO 3166-1 alpha-2 two letter country code in upper case. Use ZZ for unknown or multiple.
*/
country_code?: string
/**
* Whether this imagery should be shown in the default world-wide menu
*/
default?: boolean
/**
* Whether this imagery is the best source for the region
*/
best?: boolean
/**
* The age of the oldest imagery or data in the source, as an RFC3339 date or leading portion of one
*/
start_date?: string
/**
* The age of the newest imagery or data in the source, as an RFC3339 date or leading portion of one
*/
end_date?: string
/**
* HTTP header to check for information if the tile is invalid
*/
no_tile_header?: { [header: string]: string[] } | null
/**
* 'true' if tiles are transparent and can be overlaid on another source
*/
overlay?: boolean
/**
* Available projections
*/
available_projections?: string[]
/**
* Attribution
*/
attribution?: {
/**
* URL
*/
url?: string
/**
* Text
*/
text?: string
/**
* HTML formatted attribution
*/
html?: string
/**
* Whether attribution is required
*/
required?: boolean
}
/**
* A URL for an image, that can be displayed in the list of imagery layers next to the name
*/
icon?: string
/**
* A link to an EULA text that has to be accepted by the user, before the imagery source is added. Can contain {lang} to be replaced by a current user language wiki code (like FR:) or an empty string for the default English text.
*/
eula?: string
/**
* A URL for an image, that is displayed in the mapview for attribution
*/
"logo-image"?: string
/**
* Customized text for the terms of use link (default is "Background Terms of Use")
*/
"terms-of-use-text"?: string
/**
* Specify a checksum for tiles, which aren't real tiles. `type` is the digest type and can be MD5, SHA-1, SHA-256, SHA-384 and SHA-512, value is the hex encoded checksum in lower case. To create a checksum save the tile as file and upload it to e.g. https://defuse.ca/checksums.htm.
*/
"no-tile-checksum"?: string
/**
* header-name attribute specifies a header returned by tile server, that will be shown as `metadata-key` attribute in Show Tile Info dialog
*/
"metadata-header"?: string
/**
* Set to `true` if imagery source is properly aligned and does not need imagery offset adjustments. This is used for OSM based sources too.
*/
"valid-georeference"?: boolean
/**
* Size of individual tiles delivered by a TMS service
*/
"tile-size"?: number
/**
* Whether tiles status can be accessed by appending /status to the tile URL and can be submitted for re-rendering by appending /dirty.
*/
"mod-tile-features"?: string
/**
* HTTP headers to be sent to server. It has two attributes header-name and header-value. May be specified multiple times.
*/
"custom-http-headers"?: { "header-name": string; "header-value": string }[]
/**
* Default layer to open (when using WMS_ENDPOINT type). Contains list of layer tag with two attributes - name and style, e.g. `\"default-layers\": [\"layer\": { name=\"Basisdata_NP_Basiskart_JanMayen_WMTS_25829\" \"style\":\"default\" } ]` (not allowed in `mirror` attribute)
*/
"default-layers"?: { layer: { "layer-name": string; "layer-style": string } }[]
/**
* format to use when connecting tile server (when using WMS_ENDPOINT type)
*/
format?: string
/**
* If `true` transparent tiles will be requested from WMS server
*/
transparent?: boolean
/**
* minimum expiry time for tiles in seconds. The larger the value, the longer entry in cache will be considered valid
*/
"minimum-tile-expire"?: number
}
}

View file

@ -1,10 +1,10 @@
import { existsSync, readdirSync, readFileSync, unlinkSync, writeFileSync } from "fs"
import ScriptUtils from "./ScriptUtils"
import { Utils } from "../Utils"
import { Utils } from "../src/Utils"
import Script from "./Script"
import { GeoOperations } from "../Logic/GeoOperations"
import { GeoOperations } from "../src/Logic/GeoOperations"
import { Feature, Polygon } from "geojson"
import { Tiles } from "../Models/TileRange"
import { Tiles } from "../src/Models/TileRange"
class StatsDownloader {
private readonly urlTemplate =

View file

@ -28,22 +28,22 @@ BRANCH=`git rev-parse --abbrev-ref HEAD`
echo "The branch name is $BRANCH"
if [ $BRANCH = "develop" ]
then
SRC_MAPS="--sourcemap"
echo "Source maps are enabled"
# SRC_MAPS="--sourcemap"
echo "Source maps are NOT enabled as they consume to much RAM"
fi
if [ $BRANCH = "master" ]
if [ $BRANCH = "master" ] || [ $BRANCH = "develop" ]
then
ASSET_URL="./"
export ASSET_URL
echo "$ASSET_URL"
else
ASSET_URL="mc/$BRANCH"
ASSET_URL="$BRANCH"
export ASSET_URL
echo "$ASSET_URL"
fi
export NODE_OPTIONS=--max-old-space-size=6500
export NODE_OPTIONS=--max-old-space-size=7000
vite build $SRC_MAPS

View file

@ -1,6 +1,6 @@
import Script from "./Script"
import { Utils } from "../src/Utils"
import { FeatureCollection } from "geojson"
import { Eli, EliEntry } from "./@types/eli"
import fs from "fs"
class DownloadEli extends Script {
@ -12,8 +12,8 @@ class DownloadEli extends Script {
// Target should use '.json' instead of '.geojson', as the latter cannot be imported by the build systems
const target = args[0] ?? "src/assets/editor-layer-index.json"
const eli = <FeatureCollection>await Utils.downloadJson(url)
const keptLayers = []
const eli: Eli = await Utils.downloadJson(url)
const keptLayers: EliEntry[] = []
console.log("Got", eli.features.length, "ELI-entries")
for (let layer of eli.features) {
const props = layer.properties
@ -45,11 +45,11 @@ class DownloadEli extends Script {
continue
}
if (props.permission_url === "no") {
if (props.permission_osm === "no") {
continue
}
if (props.max_zoom < 19) {
if (props.max_zoom && props.max_zoom < 19) {
// We want users to zoom to level 19 when adding a point
// If they are on a layer which hasn't enough precision, they can not zoom far enough. This is confusing, so we don't use this layer
continue
@ -60,24 +60,24 @@ class DownloadEli extends Script {
continue
}
const keptKeys = [
"name",
"id",
"url",
"attribution",
"type",
"category",
"min_zoom",
"max_zoom",
"best",
"default",
"tile-size",
]
layer.properties = {}
for (const keptKey of keptKeys) {
if (props[keptKey]) {
layer.properties[keptKey] = props[keptKey]
}
if (props.url.startsWith("http://")) {
// Mixed content will not work properly, so we don't use this layer
continue
}
// Override the layer, so it contains only the properties we need
layer.properties = {
name: props.name,
id: props.id,
url: props.url,
attribution: props.attribution,
type: props.type,
category: props.category,
min_zoom: props.min_zoom,
max_zoom: props.max_zoom,
best: props.best ? true : undefined,
default: props.default ? true : undefined,
"tile-size": props["tile-size"],
}
layer = { properties: layer.properties, type: layer.type, geometry: layer.geometry }

View file

@ -1,10 +1,10 @@
import * as fs from "fs"
import { DesugaringStep } from "../Models/ThemeConfig/Conversion/Conversion"
import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson"
import { QuestionableTagRenderingConfigJson } from "../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import { DesugaringStep } from "../src/Models/ThemeConfig/Conversion/Conversion"
import { LayerConfigJson } from "../src/Models/ThemeConfig/Json/LayerConfigJson"
import { QuestionableTagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import * as fakedom from "fake-dom"
import Script from "./Script"
import { FixedUiElement } from "../UI/Base/FixedUiElement"
import { FixedUiElement } from "../src/UI/Base/FixedUiElement"
class ExtractQuestionHint extends DesugaringStep<QuestionableTagRenderingConfigJson> {
constructor() {

View file

@ -1,26 +1,26 @@
import ScriptUtils from "./ScriptUtils"
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs"
import licenses from "../src/assets/generated/license_info.json"
import { LayoutConfigJson } from "../src/Models/ThemeConfig/Json/LayoutConfigJson"
import { LayerConfigJson } from "../src/Models/ThemeConfig/Json/LayerConfigJson"
import Constants from "../src/Models/Constants"
import ScriptUtils from "./ScriptUtils";
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
import licenses from "../src/assets/generated/license_info.json";
import { LayoutConfigJson } from "../src/Models/ThemeConfig/Json/LayoutConfigJson";
import { LayerConfigJson } from "../src/Models/ThemeConfig/Json/LayerConfigJson";
import Constants from "../src/Models/Constants";
import {
DetectDuplicateFilters,
DoesImageExist,
PrevalidateTheme,
ValidateLayer,
ValidateThemeAndLayers,
} from "../src/Models/ThemeConfig/Conversion/Validation"
import { Translation } from "../src/UI/i18n/Translation"
import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
import PointRenderingConfigJson from "../src/Models/ThemeConfig/Json/PointRenderingConfigJson"
import { PrepareLayer } from "../src/Models/ThemeConfig/Conversion/PrepareLayer"
import { PrepareTheme } from "../src/Models/ThemeConfig/Conversion/PrepareTheme"
import { DesugaringContext } from "../src/Models/ThemeConfig/Conversion/Conversion"
import { Utils } from "../src/Utils"
import Script from "./Script"
import { AllSharedLayers } from "../src/Customizations/AllSharedLayers"
ValidateThemeAndLayers
} from "../src/Models/ThemeConfig/Conversion/Validation";
import { Translation } from "../src/UI/i18n/Translation";
import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson";
import PointRenderingConfigJson from "../src/Models/ThemeConfig/Json/PointRenderingConfigJson";
import { PrepareLayer } from "../src/Models/ThemeConfig/Conversion/PrepareLayer";
import { PrepareTheme } from "../src/Models/ThemeConfig/Conversion/PrepareTheme";
import { DesugaringContext } from "../src/Models/ThemeConfig/Conversion/Conversion";
import { Utils } from "../src/Utils";
import Script from "./Script";
import { AllSharedLayers } from "../src/Customizations/AllSharedLayers";
import {parse as parse_html} from "node-html-parser"
// This scripts scans 'src/assets/layers/*.json' for layer definition files and 'src/assets/themes/*.json' for theme definition files.
// It spits out an overview of those to be used to load them
@ -523,7 +523,10 @@ class LayerOverviewUtils extends Script {
hideFromOverview: t.hideFromOverview ?? false,
shortDescription:
t.shortDescription ??
new Translation(t.description).FirstSentence().translations,
new Translation(t.description)
.FirstSentence()
.OnEveryLanguage(s => parse_html(s).innerText)
.translations,
mustHaveLanguage: t.mustHaveLanguage?.length > 0,
}
})