forked from MapComplete/MapComplete
Housekeeping
This commit is contained in:
parent
4ad1e67f6e
commit
da615acfb1
55 changed files with 1772 additions and 1455 deletions
|
|
@ -84,7 +84,11 @@ export class SummaryTileSource extends DynamicTileSource {
|
|||
zoomRounded,
|
||||
0, // minzoom
|
||||
(tileIndex) => {
|
||||
const features = SummaryTileSource.downloadTile(tileIndex, cacheserver, layersSummed)
|
||||
const features = SummaryTileSource.downloadTile(
|
||||
tileIndex,
|
||||
cacheserver,
|
||||
layersSummed
|
||||
)
|
||||
const [z] = Tiles.tile_from_index(tileIndex)
|
||||
return new StaticFeatureSource(
|
||||
features.map(
|
||||
|
|
@ -103,7 +107,11 @@ export class SummaryTileSource extends DynamicTileSource {
|
|||
)
|
||||
}
|
||||
|
||||
public static downloadTile(tileIndex: number, cacheserver: string, layersSummed: string): Store<Feature<Point>[]>{
|
||||
public static downloadTile(
|
||||
tileIndex: number,
|
||||
cacheserver: string,
|
||||
layersSummed: string
|
||||
): Store<Feature<Point>[]> {
|
||||
const [z, x, y] = Tiles.tile_from_index(tileIndex)
|
||||
let coordinates = Tiles.centerPointOf(z, x, y)
|
||||
const url = `${cacheserver}/${layersSummed}/${z}/${x}/${y}.json`
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ class FeatureSwitchUtils {
|
|||
key,
|
||||
"" + defaultValue,
|
||||
documentation,
|
||||
{ stackOffset: -1 },
|
||||
{ stackOffset: -1 }
|
||||
)
|
||||
|
||||
// It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened
|
||||
return queryParam.sync(
|
||||
(str) => (str === undefined ? defaultValue : str !== "false"),
|
||||
[],
|
||||
(b) => (b == defaultValue ? undefined : "" + b),
|
||||
(b) => (b == defaultValue ? undefined : "" + b)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ export class OsmConnectionFeatureSwitches {
|
|||
this.featureSwitchFakeUser = QueryParameters.GetBooleanQueryParameter(
|
||||
"fake-user",
|
||||
false,
|
||||
"If true, 'dryrun' mode is activated and a fake user account is loaded",
|
||||
"If true, 'dryrun' mode is activated and a fake user account is loaded"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -99,14 +99,14 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches {
|
|||
this.featureSwitchEnableLogin = FeatureSwitchUtils.initSwitch(
|
||||
"fs-enable-login",
|
||||
layoutToUse?.enableUserBadge ?? true,
|
||||
"Disables/Enables logging in and thus disables editing all together. This effectively puts MapComplete into read-only mode.",
|
||||
"Disables/Enables logging in and thus disables editing all together. This effectively puts MapComplete into read-only mode."
|
||||
)
|
||||
{
|
||||
if (QueryParameters.wasInitialized("fs-userbadge")) {
|
||||
// userbadge is the legacy name for 'enable-login'
|
||||
this.featureSwitchEnableLogin.setData(
|
||||
QueryParameters.GetBooleanQueryParameter("fs-userbadge", undefined, "Legacy")
|
||||
.data,
|
||||
.data
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -114,64 +114,66 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches {
|
|||
this.featureSwitchSearch = FeatureSwitchUtils.initSwitch(
|
||||
"fs-search",
|
||||
layoutToUse?.enableSearch ?? true,
|
||||
"Disables/Enables the search bar",
|
||||
"Disables/Enables the search bar"
|
||||
)
|
||||
this.featureSwitchBackgroundSelection = FeatureSwitchUtils.initSwitch(
|
||||
"fs-background",
|
||||
layoutToUse?.enableBackgroundLayerSelection ?? true,
|
||||
"Disables/Enables the background layer control where a user can enable e.g. aerial imagery",
|
||||
"Disables/Enables the background layer control where a user can enable e.g. aerial imagery"
|
||||
)
|
||||
|
||||
this.featureSwitchFilter = FeatureSwitchUtils.initSwitch(
|
||||
"fs-filter",
|
||||
layoutToUse?.enableLayers ?? true,
|
||||
"Disables/Enables the filter view where a user can enable/disable MapComplete-layers or filter for certain properties",
|
||||
"Disables/Enables the filter view where a user can enable/disable MapComplete-layers or filter for certain properties"
|
||||
)
|
||||
|
||||
this.featureSwitchWelcomeMessage = FeatureSwitchUtils.initSwitch(
|
||||
"fs-welcome-message",
|
||||
true,
|
||||
"Disables/enables the help menu or welcome message",
|
||||
"Disables/enables the help menu or welcome message"
|
||||
)
|
||||
this.featureSwitchCommunityIndex = FeatureSwitchUtils.initSwitch(
|
||||
"fs-community-index",
|
||||
this.featureSwitchEnableLogin.data,
|
||||
"Disables/enables the button to get in touch with the community",
|
||||
"Disables/enables the button to get in touch with the community"
|
||||
)
|
||||
this.featureSwitchExtraLinkEnabled = FeatureSwitchUtils.initSwitch(
|
||||
"fs-iframe-popout",
|
||||
true,
|
||||
"Disables/Enables the extraLink button. By default, if in iframe mode and the welcome message is hidden, a popout button to the full mapcomplete instance is shown instead (unless disabled with this switch or another extraLink button is enabled)",
|
||||
"Disables/Enables the extraLink button. By default, if in iframe mode and the welcome message is hidden, a popout button to the full mapcomplete instance is shown instead (unless disabled with this switch or another extraLink button is enabled)"
|
||||
)
|
||||
this.featureSwitchBackToThemeOverview = FeatureSwitchUtils.initSwitch(
|
||||
"fs-homepage-link",
|
||||
layoutToUse?.enableMoreQuests ?? true,
|
||||
"Disables/Enables the various links which go back to the index page with the theme overview",
|
||||
"Disables/Enables the various links which go back to the index page with the theme overview"
|
||||
)
|
||||
this.featureSwitchShareScreen = FeatureSwitchUtils.initSwitch(
|
||||
"fs-share-screen",
|
||||
layoutToUse?.enableShareScreen ?? true,
|
||||
"Disables/Enables the 'Share-screen'-tab in the welcome message",
|
||||
"Disables/Enables the 'Share-screen'-tab in the welcome message"
|
||||
)
|
||||
this.featureSwitchGeolocation = FeatureSwitchUtils.initSwitch(
|
||||
"fs-geolocation",
|
||||
layoutToUse?.enableGeolocation ?? true,
|
||||
"Disables/Enables the geolocation button",
|
||||
"Disables/Enables the geolocation button"
|
||||
)
|
||||
|
||||
this.featureSwitchLayerDefault = QueryParameters.GetBooleanQueryParameter("fs-layers-enabled", true,
|
||||
"If set to false, all layers will be disabled - except the explicitly enabled layers",
|
||||
this.featureSwitchLayerDefault = QueryParameters.GetBooleanQueryParameter(
|
||||
"fs-layers-enabled",
|
||||
true,
|
||||
"If set to false, all layers will be disabled - except the explicitly enabled layers"
|
||||
)
|
||||
this.featureSwitchShowAllQuestions = FeatureSwitchUtils.initSwitch(
|
||||
"fs-all-questions",
|
||||
layoutToUse?.enableShowAllQuestions ?? false,
|
||||
"Always show all questions",
|
||||
"Always show all questions"
|
||||
)
|
||||
|
||||
this.featureSwitchEnableExport = FeatureSwitchUtils.initSwitch(
|
||||
"fs-export",
|
||||
layoutToUse?.enableExportButton ?? true,
|
||||
"Enable the export as GeoJSON and CSV button",
|
||||
"Enable the export as GeoJSON and CSV button"
|
||||
)
|
||||
|
||||
let testingDefaultValue = false
|
||||
|
|
@ -185,60 +187,59 @@ export default class FeatureSwitchState extends OsmConnectionFeatureSwitches {
|
|||
this.featureSwitchIsTesting = QueryParameters.GetBooleanQueryParameter(
|
||||
"test",
|
||||
testingDefaultValue,
|
||||
"If true, 'dryrun' mode is activated. The app will behave as normal, except that changes to OSM will be printed onto the console instead of actually uploaded to osm.org",
|
||||
"If true, 'dryrun' mode is activated. The app will behave as normal, except that changes to OSM will be printed onto the console instead of actually uploaded to osm.org"
|
||||
)
|
||||
|
||||
this.featureSwitchIsDebugging = QueryParameters.GetBooleanQueryParameter(
|
||||
"debug",
|
||||
false,
|
||||
"If true, shows some extra debugging help such as all the available tags on every object",
|
||||
"If true, shows some extra debugging help such as all the available tags on every object"
|
||||
)
|
||||
|
||||
this.featureSwitchMorePrivacy = QueryParameters.GetBooleanQueryParameter(
|
||||
"moreprivacy",
|
||||
layoutToUse.enableMorePrivacy,
|
||||
"If true, the location distance indication will not be written to the changeset and other privacy enhancing measures might be taken.",
|
||||
"If true, the location distance indication will not be written to the changeset and other privacy enhancing measures might be taken."
|
||||
)
|
||||
|
||||
this.overpassUrl = QueryParameters.GetQueryParameter(
|
||||
"overpassUrl",
|
||||
(layoutToUse?.overpassUrl ?? Constants.defaultOverpassUrls).join(","),
|
||||
"Point mapcomplete to a different overpass-instance. Example: https://overpass-api.de/api/interpreter",
|
||||
"Point mapcomplete to a different overpass-instance. Example: https://overpass-api.de/api/interpreter"
|
||||
).sync(
|
||||
(param) => param?.split(","),
|
||||
[],
|
||||
(urls) => urls?.join(","),
|
||||
(urls) => urls?.join(",")
|
||||
)
|
||||
|
||||
this.overpassTimeout = UIEventSource.asInt(
|
||||
QueryParameters.GetQueryParameter(
|
||||
"overpassTimeout",
|
||||
"" + layoutToUse?.overpassTimeout,
|
||||
"Set a different timeout (in seconds) for queries in overpass",
|
||||
),
|
||||
"Set a different timeout (in seconds) for queries in overpass"
|
||||
)
|
||||
)
|
||||
|
||||
this.overpassMaxZoom = UIEventSource.asFloat(
|
||||
QueryParameters.GetQueryParameter(
|
||||
"overpassMaxZoom",
|
||||
"" + layoutToUse?.overpassMaxZoom,
|
||||
" point to switch between OSM-api and overpass",
|
||||
),
|
||||
" point to switch between OSM-api and overpass"
|
||||
)
|
||||
)
|
||||
|
||||
this.osmApiTileSize = UIEventSource.asInt(
|
||||
QueryParameters.GetQueryParameter(
|
||||
"osmApiTileSize",
|
||||
"" + layoutToUse?.osmApiTileSize,
|
||||
"Tilesize when the OSM-API is used to fetch data within a BBOX",
|
||||
),
|
||||
"Tilesize when the OSM-API is used to fetch data within a BBOX"
|
||||
)
|
||||
)
|
||||
|
||||
this.backgroundLayerId = QueryParameters.GetQueryParameter(
|
||||
"background",
|
||||
layoutToUse?.defaultBackgroundId,
|
||||
"The id of the background layer to start with",
|
||||
"The id of the background layer to start with"
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,13 +35,23 @@ export default class LayerState {
|
|||
* @param context
|
||||
* @param layersEnabledByDefault
|
||||
*/
|
||||
constructor(osmConnection: OsmConnection, layers: LayerConfig[], context: string, layersEnabledByDefault: Store<boolean>) {
|
||||
constructor(
|
||||
osmConnection: OsmConnection,
|
||||
layers: LayerConfig[],
|
||||
context: string,
|
||||
layersEnabledByDefault: Store<boolean>
|
||||
) {
|
||||
this.osmConnection = osmConnection
|
||||
const filteredLayers = new Map()
|
||||
for (const layer of layers) {
|
||||
filteredLayers.set(
|
||||
layer.id,
|
||||
FilteredLayer.initLinkedState(layer, context, this.osmConnection, layersEnabledByDefault)
|
||||
FilteredLayer.initLinkedState(
|
||||
layer,
|
||||
context,
|
||||
this.osmConnection,
|
||||
layersEnabledByDefault
|
||||
)
|
||||
)
|
||||
}
|
||||
this.filteredLayers = filteredLayers
|
||||
|
|
|
|||
|
|
@ -1,14 +1,42 @@
|
|||
import { Utils } from "../../Utils"
|
||||
/** This code is autogenerated - do not edit. Edit ./assets/layers/usersettings/usersettings.json instead */
|
||||
export class ThemeMetaTagging {
|
||||
public static readonly themeName = "usersettings"
|
||||
public static readonly themeName = "usersettings"
|
||||
|
||||
public metaTaggging_for_usersettings(feat: {properties: Record<string, string>}) {
|
||||
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_md', () => feat.properties._description.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)?.at(1) )
|
||||
Utils.AddLazyProperty(feat.properties, '_d', () => feat.properties._description?.replace(/</g,'<')?.replace(/>/g,'>') ?? '' )
|
||||
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate_a', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) )
|
||||
Utils.AddLazyProperty(feat.properties, '_mastodon_link', () => (feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName("a")).filter(a => a.getAttribute("rel")?.indexOf('me') >= 0)[0]?.href})(feat) )
|
||||
Utils.AddLazyProperty(feat.properties, '_mastodon_candidate', () => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a )
|
||||
feat.properties['__current_backgroun'] = 'initial_value'
|
||||
}
|
||||
}
|
||||
public metaTaggging_for_usersettings(feat: { properties: Record<string, string> }) {
|
||||
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_md", () =>
|
||||
feat.properties._description
|
||||
.match(/\[[^\]]*\]\((.*(mastodon|en.osm.town).*)\).*/)
|
||||
?.at(1)
|
||||
)
|
||||
Utils.AddLazyProperty(
|
||||
feat.properties,
|
||||
"_d",
|
||||
() => feat.properties._description?.replace(/</g, "<")?.replace(/>/g, ">") ?? ""
|
||||
)
|
||||
Utils.AddLazyProperty(feat.properties, "_mastodon_candidate_a", () =>
|
||||
((feat) => {
|
||||
const e = document.createElement("div")
|
||||
e.innerHTML = feat.properties._d
|
||||
return Array.from(e.getElementsByTagName("a")).filter(
|
||||
(a) => a.href.match(/mastodon|en.osm.town/) !== null
|
||||
)[0]?.href
|
||||
})(feat)
|
||||
)
|
||||
Utils.AddLazyProperty(feat.properties, "_mastodon_link", () =>
|
||||
((feat) => {
|
||||
const e = document.createElement("div")
|
||||
e.innerHTML = feat.properties._d
|
||||
return Array.from(e.getElementsByTagName("a")).filter(
|
||||
(a) => a.getAttribute("rel")?.indexOf("me") >= 0
|
||||
)[0]?.href
|
||||
})(feat)
|
||||
)
|
||||
Utils.AddLazyProperty(
|
||||
feat.properties,
|
||||
"_mastodon_candidate",
|
||||
() => feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a
|
||||
)
|
||||
feat.properties["__current_backgroun"] = "initial_value"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue