Add assets for entrances, add first dependency injection

This commit is contained in:
Pieter Vander Vennet 2021-12-04 21:51:53 +01:00
commit 8e40d76281
13 changed files with 1735 additions and 48 deletions

View file

@ -39,15 +39,23 @@ export class AllKnownLayouts {
throw "Priviliged layer definition not found: " + id
}
}
const allLayers: LayerConfig[] = Array.from(AllKnownLayers.sharedLayers.values())
.filter(layer => AllKnownLayers.priviliged_layers.indexOf(layer.id) < 0)
const builtinLayerIds: Set<string> = new Set<string>()
allLayers.forEach(l => builtinLayerIds.add(l.id))
const themesPerLayer = new Map<string, string[]>()
for (const layout of Array.from(AllKnownLayouts.allKnownLayouts.values())) {
if(layout.hideFromOverview){
if (layout.hideFromOverview) {
continue
}
for (const layer of layout.layers) {
if (!builtinLayerIds.has(layer.id)) {
continue
}
if (!themesPerLayer.has(layer.id)) {
themesPerLayer.set(layer.id, [])
}
@ -57,8 +65,9 @@ export class AllKnownLayouts {
let popularLayerCutoff = 2;
const popupalLayers = allLayers.filter((layer) => themesPerLayer.get(layer.id)?.length >= 2)
.filter(layer => AllKnownLayers.priviliged_layers.indexOf(layer.id) < 0)
const popuparLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length >= 2)
const unpopularLayers = allLayers.filter(layer => themesPerLayer.get(layer.id)?.length < 2)
return new Combine([
new Title("Special and other useful layers", 1),
@ -68,10 +77,15 @@ export class AllKnownLayouts {
...AllKnownLayers.priviliged_layers
.map(id => AllKnownLayers.sharedLayers.get(id))
.map((l) => l.GenerateDocumentation(themesPerLayer.get(l.id), AllKnownLayers.added_by_default.indexOf(l.id) >= 0, AllKnownLayers.no_include.indexOf(l.id) < 0)),
new Title("Frequently reused layers", 1),
"The following layers are used by at least "+popularLayerCutoff+" mapcomplete themes and might be interesting for your custom theme too",
new List(popupalLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
...popupalLayers.map((layer) => layer.GenerateDocumentation(themesPerLayer.get(layer.id)))
new Title("Normal layers", 1),
"The following layers are included in MapComplete",
new Title("Frequently reused layers", 2),
"The following layers are used by at least " + popularLayerCutoff + " mapcomplete themes and might be interesting for your custom theme too",
new List(popuparLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
...popuparLayers.map((layer) => layer.GenerateDocumentation(themesPerLayer.get(layer.id))),
new List(unpopularLayers.map(layer => "[" + layer.id + "](#" + layer.id + ")")),
...unpopularLayers.map(layer => layer.GenerateDocumentation(themesPerLayer.get(layer.id))
)
])

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,7 @@ export default class FeatureSwitchState {
public readonly featureSwitchUserbadge: UIEventSource<boolean>;
public readonly featureSwitchSearch: UIEventSource<boolean>;
public readonly featureSwitchBackgroundSlection: UIEventSource<boolean>;
public readonly featureSwitchBackgroundSelection: UIEventSource<boolean>;
public readonly featureSwitchAddNew: UIEventSource<boolean>;
public readonly featureSwitchWelcomeMessage: UIEventSource<boolean>;
public readonly featureSwitchIframePopoutEnabled: UIEventSource<boolean>;
@ -72,7 +72,7 @@ export default class FeatureSwitchState {
(layoutToUse) => layoutToUse?.enableSearch ?? true,
"Disables/Enables the search bar"
);
this.featureSwitchBackgroundSlection = featSw(
this.featureSwitchBackgroundSelection = featSw(
"fs-background",
(layoutToUse) => layoutToUse?.enableBackgroundLayerSelection ?? true,
"Disables/Enables the background layer control"

View file

@ -1,7 +1,7 @@
import {Translation} from "../../UI/i18n/Translation";
import SourceConfig from "./SourceConfig";
import TagRenderingConfig from "./TagRenderingConfig";
import PresetConfig from "./PresetConfig";
import PresetConfig, {PreciseInput} from "./PresetConfig";
import {LayerConfigJson} from "./Json/LayerConfigJson";
import Translations from "../../UI/i18n/Translations";
import {TagUtils} from "../../Logic/Tags/TagUtils";
@ -26,19 +26,19 @@ import * as icons from "../../assets/tagRenderings/icons.json"
export default class LayerConfig extends WithContextLoader {
id: string;
name: Translation;
description: Translation;
source: SourceConfig;
calculatedTags: [string, string][];
doNotDownload: boolean;
passAllFeatures: boolean;
isShown: TagRenderingConfig;
minzoom: number;
minzoomVisible: number;
maxzoom: number;
title?: TagRenderingConfig;
titleIcons: TagRenderingConfig[];
public readonly id: string;
public readonly name: Translation;
public readonly description: Translation;
public readonly source: SourceConfig;
public readonly calculatedTags: [string, string][];
public readonly doNotDownload: boolean;
public readonly passAllFeatures: boolean;
public readonly isShown: TagRenderingConfig;
public readonly minzoom: number;
public readonly minzoomVisible: number;
public readonly maxzoom: number;
public readonly title?: TagRenderingConfig;
public readonly titleIcons: TagRenderingConfig[];
public readonly mapRendering: PointRenderingConfig[]
public readonly lineRendering: LineRenderingConfig[]
@ -53,10 +53,10 @@ export default class LayerConfig extends WithContextLoader {
*/
public readonly maxAgeOfCache: number
presets: PresetConfig[];
public readonly presets: PresetConfig[];
tagRenderings: TagRenderingConfig[];
filters: FilterConfig[];
public readonly tagRenderings: TagRenderingConfig[];
public readonly filters: FilterConfig[];
constructor(
json: LayerConfigJson,
@ -153,8 +153,7 @@ export default class LayerConfig extends WithContextLoader {
throw "Presets should be a list of items (at " + context + ")"
}
this.presets = (json.presets ?? []).map((pr, i) => {
let preciseInput: any = {
let preciseInput: PreciseInput = {
preferredBackground: ["photo"],
snapToLayers: undefined,
maxSnapDistance: undefined
@ -165,6 +164,7 @@ export default class LayerConfig extends WithContextLoader {
preferredBackground: undefined
}
}
let snapToLayers: string[];
if (typeof pr.preciseInput.snapToLayer === "string") {
snapToLayers = [pr.preciseInput.snapToLayer]
@ -180,7 +180,7 @@ export default class LayerConfig extends WithContextLoader {
}
preciseInput = {
preferredBackground: preferredBackground,
snapToLayers: snapToLayers,
snapToLayers,
maxSnapDistance: pr.preciseInput.maxSnapDistance ?? 10
}
}
@ -441,6 +441,10 @@ export default class LayerConfig extends WithContextLoader {
]
}
for (const dep of Array.from(this.getDependencies())) {
extraProps.push(new Combine(["This layer will automatically load ", new Link(dep, "#"+dep)," into the layout as it depends on it."]))
}
return new Combine([
new Title(this.id, 3),
this.description,
@ -480,4 +484,23 @@ export default class LayerConfig extends WithContextLoader {
public isLeftRightSensitive(): boolean {
return this.lineRendering.some(lr => lr.leftRightSensitive)
}
/**
* Returns a set of all other layer-ids that this layer needs to function.
* E.g. if this layers does snap to another layer in the preset, this other layer id will be mentioned
*/
public getDependencies(): Set<string>{
const deps = new Set<string>()
for (const preset of this.presets ?? []) {
if(preset.preciseInput?.snapToLayers === undefined){
continue
}
preset.preciseInput?.snapToLayers?.forEach(id => {
deps.add(id);
})
}
return deps
}
}

View file

@ -166,7 +166,7 @@ export default class LayoutConfig {
return
} else {
const shared = AllKnownLayers.sharedLayers.get(layer)
if(shared === undefined){
if (shared === undefined) {
throw `Shared layer ${layer} not found (at ${context}.layers[${i}])`
}
result.push(shared)
@ -212,17 +212,38 @@ export default class LayoutConfig {
})
});
// Some special layers which are always included by default
for (const defaultLayer of AllKnownLayers.added_by_default) {
if(result.some(l => l?.id === defaultLayer)){
if (result.some(l => l?.id === defaultLayer)) {
continue; // Already added
}
result.push(AllKnownLayers.sharedLayers.get(defaultLayer))
const sharedLayer = AllKnownLayers.sharedLayers.get(defaultLayer)
if (sharedLayer !== undefined) {
result.push(sharedLayer)
}
}
let unmetDependencies: { dependency: string, layer: string }[] = []
do {
const dependencies: { dependency: string, layer: string }[] = [].concat(...result.map(l => Array.from(l.getDependencies()).map(d => ({
dependency: d,
layer: l.id
}))))
const loadedLayers = new Set(result.map(r => r.id))
unmetDependencies = dependencies.filter(dep => !loadedLayers.has(dep.dependency))
for (const unmetDependency of unmetDependencies) {
console.log("Recursively loading unmet dependency ", unmetDependency.dependency, "(needed by " + unmetDependency.layer + ")")
const dep = AllKnownLayers.sharedLayers.get(unmetDependency.dependency)
if (dep === undefined) {
throw "The layer '" + unmetDependency.layer + "' needs '" + unmetDependency.dependency + "' to be loaded, but it could not be found as builtin layer (at " + context + ")"
}
result.unshift(dep)
unmetDependencies = unmetDependencies.filter(d => d.dependency !== unmetDependency.dependency)
}
} while (unmetDependencies.length > 0)
return {layers: result, extractAllNodes: exportAllNodes}
}
@ -302,9 +323,9 @@ export default class LayoutConfig {
public isLeftRightSensitive() {
return this.layers.some(l => l.isLeftRightSensitive())
}
public getMatchingLayer(tags: any) : LayerConfig | undefined{
if(tags === undefined){
public getMatchingLayer(tags: any): LayerConfig | undefined {
if (tags === undefined) {
return undefined
}
for (const layer of this.layers) {

View file

@ -1,6 +1,12 @@
import {Translation} from "../../UI/i18n/Translation";
import {Tag} from "../../Logic/Tags/Tag";
export interface PreciseInput {
preferredBackground?: string[],
snapToLayers?: string[],
maxSnapDistance?: number
}
export default interface PresetConfig {
title: Translation,
tags: Tag[],
@ -8,9 +14,5 @@ export default interface PresetConfig {
/**
* If precise input is set, then an extra map is shown in which the user can drag the map to the precise location
*/
preciseInput?: {
preferredBackground?: string[],
snapToLayers?: string[],
maxSnapDistance?: number
}
preciseInput?: PreciseInput
}

View file

@ -20,7 +20,7 @@ export default class FilterView extends VariableUiElement {
const backgroundSelector = new Toggle(
new BackgroundSelector(),
undefined,
State.state.featureSwitchBackgroundSlection
State.state.featureSwitchBackgroundSelection
)
super(
filteredLayer.map((filteredLayers) => {

View file

@ -19,6 +19,7 @@ import BackgroundMapSwitch from "./BackgroundMapSwitch";
export default class LeftControls extends Combine {
constructor(state: {
featureSwitchBackgroundSelection: UIEventSource<boolean>;
layoutToUse: LayoutConfig,
featurePipeline: FeaturePipeline,
currentBounds: UIEventSource<BBox>,
@ -74,10 +75,16 @@ export default class LeftControls extends Combine {
undefined,
state.featureSwitchFilter
);
const mapSwitch = new Toggle(
new BackgroundMapSwitch(state, state.backgroundLayer),
undefined,
state.featureSwitchBackgroundSelection
)
super([filterButton,
downloadButtonn,
new BackgroundMapSwitch(state, state.backgroundLayer)
mapSwitch
])
this.SetClass("flex flex-col")

View file

@ -18,7 +18,7 @@ export class DefaultGuiState {
this.welcomeMessageOpenedTab = UIEventSource.asFloat(QueryParameters.GetQueryParameter(
"tab",
"0",
`The tab that is shown in the welcome-message. 0 = the explanation of the theme,1 = OSM-credits, 2 = sharescreen, 3 = more themes, 4 = about mapcomplete (user must be logged in and have >${Constants.userJourney.mapCompleteHelpUnlock} changesets)`
`The tab that is shown in the welcome-message.`
));
this.welcomeMessageIsOpened = QueryParameters.GetBooleanQueryParameter(
"welcome-control-toggle",

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:version="1.0rc1 (09960d6, 2020-04-09)"
height="100"
width="100"
sodipodi:docname="noun_Door_1512154.svg"
id="svg985"
viewBox="0 0 100 100"
y="0px"
x="0px"
version="1.1">
<metadata
id="metadata991">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs989" />
<sodipodi:namedview
inkscape:current-layer="svg985"
inkscape:window-maximized="0"
inkscape:window-y="13"
inkscape:window-x="19"
inkscape:cy="62.5"
inkscape:cx="46.363636"
inkscape:zoom="2.2"
showgrid="false"
id="namedview987"
inkscape:window-height="480"
inkscape:window-width="850"
inkscape:pageshadow="2"
inkscape:pageopacity="0"
guidetolerance="10"
gridtolerance="10"
objecttolerance="10"
borderopacity="1"
bordercolor="#666666"
pagecolor="#ffffff" />
<g
id="g979"
transform="matrix(1.098403,0,0,1.098403,-4.8856189,-1050.6679)">
<path
inkscape:connector-curvature="0"
id="path977"
overflow="visible"
display="inline"
visibility="visible"
marker="none"
stroke="none"
fill-opacity="1"
fill="#000000"
d="m 19.895978,958.36667 a 0.99873128,0.99999802 0 0 0 -0.8114,0.9999 v 84.99133 h -8.9877 a 0.99873128,0.99999802 0 0 0 -0.1872001,0 1.0030103,1.0042825 0 1 0 0.1872001,1.9998 h 79.8905 a 0.99873128,0.99999802 0 1 0 0,-1.9998 h -8.9877 v -84.99133 a 0.99873128,0.99999802 0 0 0 -0.9986,-0.9999 h -59.9179 a 0.99873128,0.99999802 0 0 0 -0.1872,0 z m 1.1858,1.9998 h 57.9207 v 83.99143 h -5.9918 v -76.99213 a 0.99873128,0.99999802 0 0 0 -0.9987,-0.9999 h -43.9397 a 0.99873128,0.99999802 0 0 0 -0.1873,0 0.99873128,0.99999802 0 0 0 -0.8114,0.9999 v 76.99213 h -5.9918 z m 7.9891,7.9992 h 41.9425 v 75.99223 h -41.9425 z m 32.9548,36.49623 c -0.7386,0 -1.3708,0.4031 -1.7164,0.9999 h -4.2754 a 0.99873128,0.99999802 0 0 0 -0.1872,0 1.0030202,1.0042924 0 0 0 0.1872,1.9998 h 4.2754 c 0.3456,0.5969 0.9778,0.9999 1.7164,0.9999 1.103,0 1.9973,-0.8954 1.9973,-1.9998 0,-1.1045 -0.8943,-1.9998 -1.9973,-1.9998 z"
style="color:#000000;text-indent:0;text-transform:none;direction:ltr;baseline-shift:baseline;enable-background:accumulate" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32mm"
height="32mm"
viewBox="0 0 113.38583 113.38583"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="emergency_door.svg"
inkscape:export-filename="/home/adrien/Documents/Programmation/Web/panieravide.github.io/levelup/img/door.png"
inkscape:export-xdpi="25.4"
inkscape:export-ydpi="25.4">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="17.362557"
inkscape:cy="53.453701"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1600"
inkscape:window-height="843"
inkscape:window-x="1920"
inkscape:window-y="568"
inkscape:window-maximized="1"
showguides="false" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-938.97638)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2.00000024;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 0,1031.3622 114.00001,0"
id="path4138"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<rect
style="opacity:1;fill:#e2e2e2;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:2.00000024;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4136-8"
width="60.000004"
height="80.000008"
x="34.500004"
y="951.36212" />
<g
id="g4150"
transform="matrix(1.0676647,0,0,1.0676647,3.6639253,-75.770373)"
style="stroke:#ffffff;stroke-opacity:1;stroke-width:0.9366237;stroke-miterlimit:4;stroke-dasharray:none;fill:#019501;fill-opacity:1">
<path
sodipodi:nodetypes="acccccccccccsscccsccscccccccccccccccaa"
id="path4142"
d="m 68.306561,997.51621 c -0.860179,-1.02295 -3.90737,-0.8997 -3.90737,-0.8997 l -4.107632,0 -2.888536,-3.32659 c -1.587556,-1.82228 -3.816505,-4.2996 -4.944625,-5.51551 l -2.06064,-2.21759 -10.080305,-0.14192 c -8.582362,-0.12828 -10.357334,-0.0368 -11.812973,0.65368 -2.9186,1.80372 -3.923351,4.81999 -5.429991,7.37782 -2.844868,4.81179 -2.827582,6.35841 0.07096,7.2782 3.773223,-0.5747 4.728773,-4.42983 6.354323,-7.12172 l 1.748132,-2.88581 3.156009,0 c 1.895061,0 3.170111,0.21335 3.170111,0.52585 0,0.51903 -3.344333,7.89048 -4.691254,10.35048 -0.434873,0.7915 -0.928426,4.1168 -1.265042,8.5838 -0.302501,4.0121 -0.62911,7.5829 -0.725091,7.9196 -0.130553,0.4594 -2.172087,0.6095 -8.088354,0.6095 -10.00024,0 -11.499088,0.5914 -12.765035,5.0038 l -0.3984807,1.3783 13.2062767,0 c 12.6486,0 13.252235,-0.036 14.144269,-0.9962 0.786502,-0.8416 0.982558,-2.1107 1.279145,-8.2153 0.325699,-6.6959 0.596812,-8.47 1.109016,-7.2327 0.111902,0.2684 3.009536,6.0091 6.437568,12.7505 3.998459,7.8513 6.691392,12.5822 7.491993,13.1599 0.982557,0.705 1.969663,0.8688 4.52158,0.7551 l 3.256995,-0.1547 -6.327484,-12.7505 c -3.479886,-7.0189 -6.800563,-13.7785 -7.37827,-15.0112 l -1.05079,-2.2472 2.315376,-5.0042 c 1.278234,-2.75118 2.451844,-4.98513 2.615603,-4.96147 0.163759,0.0246 1.646691,1.61985 3.284286,3.55403 l 2.984061,3.52314 5.49049,0.1455 c 0,0 4.349574,0.3122 5.48594,-1.1729 0.753414,-0.9846 0.597657,-2.76508 -0.200261,-3.71399 z"
style="fill:#019501;stroke:#ffffff;stroke-opacity:1;stroke-width:0.9366237;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1"
inkscape:connector-curvature="0" />
<circle
r="5.9375"
cy="977.94257"
cx="49.653049"
id="path4148"
style="opacity:1;fill:#019501;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.9366237;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -0,0 +1,22 @@
[
{
"path": "door.svg",
"license": "CC-BY 3.0 Unported",
"authors": [
"Icons Bazaar"
],
"sources": [
"https://commons.wikimedia.org/wiki/File:Noun_Project_Door_icon_1512154.svg"
]
},
{
"path": "emergency_door.svg",
"license": "CC-BY-SA 4.0 international",
"authors": [
"PanierAvide"
],
"sources": [
"https://commons.wikimedia.org/wiki/File:Emergency_door_icon.svg"
]
}
]

View file

@ -0,0 +1,12 @@
[
{
"path": "logo.svg",
"license": "GPL",
"authors": [
"sebkur"
],
"sources": [
"https://github.com/mobanisto/MapComplete/commit/1aeb1fdb5b09908d67907f3c816152bfebfdcc79"
]
}
]