forked from MapComplete/MapComplete
More refactoring of the featurepipeline, introduction of fetching data from the OSM-API directly per tile, personal theme refactoring
This commit is contained in:
parent
0a9e7c0b36
commit
41a2a79fe9
48 changed files with 746 additions and 590 deletions
|
@ -1,8 +1,8 @@
|
|||
import BaseUIElement from "../BaseUIElement";
|
||||
import Loc from "../../Models/Loc";
|
||||
import BaseLayer from "../../Models/BaseLayer";
|
||||
import {BBox} from "../../Logic/GeoOperations";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
export interface MinimapOptions {
|
||||
background?: UIEventSource<BaseLayer>,
|
||||
|
|
|
@ -4,10 +4,10 @@ import {UIEventSource} from "../../Logic/UIEventSource";
|
|||
import Loc from "../../Models/Loc";
|
||||
import BaseLayer from "../../Models/BaseLayer";
|
||||
import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers";
|
||||
import {BBox} from "../../Logic/GeoOperations";
|
||||
import * as L from "leaflet";
|
||||
import {Map} from "leaflet";
|
||||
import Minimap, {MinimapObj, MinimapOptions} from "./Minimap";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
export default class MinimapImplementation extends BaseUIElement implements MinimapObj {
|
||||
private static _nextId = 0;
|
||||
|
|
|
@ -7,7 +7,7 @@ import Constants from "../../Models/Constants";
|
|||
import Loc from "../../Models/Loc";
|
||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
||||
import {BBox} from "../../Logic/GeoOperations";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
/**
|
||||
* The bottom right attribution panel in the leaflet map
|
||||
|
|
|
@ -5,7 +5,7 @@ import State from "../../State";
|
|||
import {Utils} from "../../Utils";
|
||||
import Combine from "../Base/Combine";
|
||||
import CheckBoxes from "../Input/Checkboxes";
|
||||
import {BBox, GeoOperations} from "../../Logic/GeoOperations";
|
||||
import {GeoOperations} from "../../Logic/GeoOperations";
|
||||
import Toggle from "../Input/Toggle";
|
||||
import Title from "../Base/Title";
|
||||
import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline";
|
||||
|
@ -13,6 +13,7 @@ import {UIEventSource} from "../../Logic/UIEventSource";
|
|||
import SimpleMetaTagger from "../../Logic/SimpleMetaTagger";
|
||||
import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig";
|
||||
import {meta} from "@turf/turf";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
export class DownloadPanel extends Toggle {
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import State from "../../State";
|
||||
import ThemeIntroductionPanel from "./ThemeIntroductionPanel";
|
||||
import * as personal from "../../assets/themes/personal/personal.json";
|
||||
import PersonalLayersPanel from "./PersonalLayersPanel";
|
||||
import Svg from "../../Svg";
|
||||
import Translations from "../i18n/Translations";
|
||||
import ShareScreen from "./ShareScreen";
|
||||
|
@ -32,9 +30,7 @@ export default class FullWelcomePaneWithTabs extends ScrollableFullScreen {
|
|||
private static ConstructBaseTabs(layoutToUse: LayoutConfig, isShown: UIEventSource<boolean>): { header: string | BaseUIElement; content: BaseUIElement }[] {
|
||||
|
||||
let welcome: BaseUIElement = new ThemeIntroductionPanel(isShown);
|
||||
if (layoutToUse.id === personal.id) {
|
||||
welcome = new PersonalLayersPanel();
|
||||
}
|
||||
|
||||
const tabs: { header: string | BaseUIElement, content: BaseUIElement }[] = [
|
||||
{header: `<img src='${layoutToUse.icon}'>`, content: welcome},
|
||||
{
|
||||
|
|
|
@ -11,8 +11,8 @@ import AllDownloads from "./AllDownloads";
|
|||
import FilterView from "./FilterView";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline";
|
||||
import {BBox} from "../../Logic/GeoOperations";
|
||||
import Loc from "../../Models/Loc";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
export default class LeftControls extends Combine {
|
||||
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
import {AllKnownLayouts} from "../../Customizations/AllKnownLayouts";
|
||||
import Svg from "../../Svg";
|
||||
import State from "../../State";
|
||||
import Combine from "../Base/Combine";
|
||||
import Toggle from "../Input/Toggle";
|
||||
import {SubtleButton} from "../Base/SubtleButton";
|
||||
import Translations from "../i18n/Translations";
|
||||
import BaseUIElement from "../BaseUIElement";
|
||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
|
||||
|
||||
export default class PersonalLayersPanel extends VariableUiElement {
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
State.state.installedThemes.map(installedThemes => {
|
||||
const t = Translations.t.favourite;
|
||||
|
||||
// Lets get all the layers
|
||||
const allThemes = AllKnownLayouts.layoutsList.concat(installedThemes.map(layout => layout.layout))
|
||||
.filter(theme => !theme.hideFromOverview)
|
||||
|
||||
const allLayers = []
|
||||
{
|
||||
const seenLayers = new Set<string>()
|
||||
for (const layers of allThemes.map(theme => theme.layers)) {
|
||||
for (const layer of layers) {
|
||||
if (seenLayers.has(layer.id)) {
|
||||
continue
|
||||
}
|
||||
seenLayers.add(layer.id)
|
||||
allLayers.push(layer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Time to create a panel based on them!
|
||||
const panel: BaseUIElement = new Combine(allLayers.map(PersonalLayersPanel.CreateLayerToggle));
|
||||
|
||||
|
||||
return new Toggle(
|
||||
new Combine([
|
||||
t.panelIntro.Clone(),
|
||||
panel
|
||||
]).SetClass("flex flex-col"),
|
||||
new SubtleButton(
|
||||
Svg.osm_logo_ui(),
|
||||
t.loginNeeded.Clone().SetClass("text-center")
|
||||
).onClick(() => State.state.osmConnection.AttemptLogin()),
|
||||
State.state.osmConnection.isLoggedIn
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
/***
|
||||
* Creates a toggle for the given layer, which'll update State.state.favouriteLayers right away
|
||||
* @param layer
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
private static CreateLayerToggle(layer: LayerConfig): Toggle {
|
||||
let icon: BaseUIElement = new Combine([layer.GenerateLeafletStyle(
|
||||
new UIEventSource<any>({id: "node/-1"}),
|
||||
false
|
||||
).icon.html]).SetClass("relative")
|
||||
let iconUnset = new Combine([layer.GenerateLeafletStyle(
|
||||
new UIEventSource<any>({id: "node/-1"}),
|
||||
false
|
||||
).icon.html]).SetClass("relative")
|
||||
|
||||
iconUnset.SetStyle("opacity:0.1")
|
||||
|
||||
let name = layer.name;
|
||||
if (name === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const content = new Combine([
|
||||
Translations.WT(name).Clone().SetClass("font-bold"),
|
||||
Translations.WT(layer.description)?.Clone()
|
||||
]).SetClass("flex flex-col")
|
||||
|
||||
const contentUnselected = new Combine([
|
||||
Translations.WT(name).Clone().SetClass("font-bold"),
|
||||
Translations.WT(layer.description)?.Clone()
|
||||
]).SetClass("flex flex-col line-through")
|
||||
|
||||
return new Toggle(
|
||||
new SubtleButton(
|
||||
icon,
|
||||
content),
|
||||
new SubtleButton(
|
||||
iconUnset,
|
||||
contentUnselected
|
||||
),
|
||||
State.state.favouriteLayers.map(favLayers => {
|
||||
return favLayers.indexOf(layer.id) >= 0
|
||||
}, [], (selected, current) => {
|
||||
if (!selected && current.indexOf(layer.id) <= 0) {
|
||||
// Not selected and not contained: nothing to change: we return current as is
|
||||
return current;
|
||||
}
|
||||
if (selected && current.indexOf(layer.id) >= 0) {
|
||||
// Selected and contained: this is fine!
|
||||
return current;
|
||||
}
|
||||
const clone = [...current]
|
||||
if (selected) {
|
||||
clone.push(layer.id)
|
||||
} else {
|
||||
clone.splice(clone.indexOf(layer.id), 1)
|
||||
}
|
||||
return clone
|
||||
})
|
||||
).ToggleOnClick();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ import {OsmObject, OsmWay} from "../../Logic/Osm/OsmObject";
|
|||
import PresetConfig from "../../Models/ThemeConfig/PresetConfig";
|
||||
import FilteredLayer from "../../Models/FilteredLayer";
|
||||
import {And} from "../../Logic/Tags/And";
|
||||
import {BBox} from "../../Logic/GeoOperations";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
/*
|
||||
* The SimpleAddUI is a single panel, which can have multiple states:
|
||||
|
|
|
@ -5,7 +5,6 @@ import {SimpleMapScreenshoter} from "leaflet-simple-map-screenshoter";
|
|||
import {UIEventSource} from "../Logic/UIEventSource";
|
||||
import Minimap from "./Base/Minimap";
|
||||
import Loc from "../Models/Loc";
|
||||
import {BBox} from "../Logic/GeoOperations";
|
||||
import BaseLayer from "../Models/BaseLayer";
|
||||
import {FixedUiElement} from "./Base/FixedUiElement";
|
||||
import Translations from "./i18n/Translations";
|
||||
|
@ -14,6 +13,7 @@ import Constants from "../Models/Constants";
|
|||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
||||
import FeaturePipeline from "../Logic/FeatureSource/FeaturePipeline";
|
||||
import ShowDataLayer from "./ShowDataLayer/ShowDataLayer";
|
||||
import {BBox} from "../Logic/BBox";
|
||||
/**
|
||||
* Creates screenshoter to take png screenshot
|
||||
* Creates jspdf and downloads it
|
||||
|
|
|
@ -7,11 +7,12 @@ import Combine from "../Base/Combine";
|
|||
import Svg from "../../Svg";
|
||||
import State from "../../State";
|
||||
import AvailableBaseLayers from "../../Logic/Actors/AvailableBaseLayers";
|
||||
import {BBox, GeoOperations} from "../../Logic/GeoOperations";
|
||||
import {GeoOperations} from "../../Logic/GeoOperations";
|
||||
import ShowDataLayer from "../ShowDataLayer/ShowDataLayer";
|
||||
import ShowDataMultiLayer from "../ShowDataLayer/ShowDataMultiLayer";
|
||||
import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource";
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
export default class LocationInput extends InputElement<Loc> {
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import {SubtleButton} from "../Base/SubtleButton";
|
|||
import Minimap from "../Base/Minimap";
|
||||
import State from "../../State";
|
||||
import ShowDataLayer from "../ShowDataLayer/ShowDataLayer";
|
||||
import {BBox, GeoOperations} from "../../Logic/GeoOperations";
|
||||
import {GeoOperations} from "../../Logic/GeoOperations";
|
||||
import {LeafletMouseEvent} from "leaflet";
|
||||
import Combine from "../Base/Combine";
|
||||
import {Button} from "../Base/Button";
|
||||
|
@ -15,6 +15,7 @@ import Title from "../Base/Title";
|
|||
import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource";
|
||||
import ShowDataMultiLayer from "../ShowDataLayer/ShowDataMultiLayer";
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
export default class SplitRoadWizard extends Toggle {
|
||||
private static splitLayerStyling = new LayerConfig({
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import FeatureSource, {FeatureSourceForLayer, Tiled} from "../../Logic/FeatureSource/FeatureSource";
|
||||
import {BBox} from "../../Logic/GeoOperations";
|
||||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
|
||||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {Tiles} from "../../Models/TileRange";
|
||||
import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource";
|
||||
import {BBox} from "../../Logic/BBox";
|
||||
|
||||
export class TileHierarchyAggregator implements FeatureSource {
|
||||
private _parent: TileHierarchyAggregator;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue