forked from MapComplete/MapComplete
refactoring: more state splitting, basic layoutFeatureSource
This commit is contained in:
parent
8e2f04c0d0
commit
b94a8f5745
54 changed files with 1067 additions and 1969 deletions
|
@ -11,7 +11,6 @@
|
|||
import { QueryParameters } from "../Logic/Web/QueryParameters";
|
||||
import UserRelatedState from "../Logic/State/UserRelatedState";
|
||||
import GeoLocationHandler from "../Logic/Actors/GeoLocationHandler";
|
||||
import { ElementStorage } from "../Logic/ElementStorage";
|
||||
import { Changes } from "../Logic/Osm/Changes";
|
||||
import ChangeToElementsActor from "../Logic/Actors/ChangeToElementsActor";
|
||||
import PendingChangesUploader from "../Logic/Actors/PendingChangesUploader";
|
||||
|
@ -28,6 +27,12 @@
|
|||
import LayerState from "../Logic/State/LayerState";
|
||||
import Constants from "../Models/Constants";
|
||||
import type { Feature } from "geojson";
|
||||
import FeaturePropertiesStore from "../Logic/FeatureSource/Actors/FeaturePropertiesStore";
|
||||
import ShowDataMultiLayer from "./Map/ShowDataMultiLayer";
|
||||
import { Or } from "../Logic/Tags/Or";
|
||||
import LayoutSource from "../Logic/FeatureSource/LayoutSource";
|
||||
import { type OsmTags } from "../Models/OsmFeature";
|
||||
|
||||
export let layout: LayoutConfig;
|
||||
|
||||
const maplibremap: UIEventSource<MlMap> = new UIEventSource<MlMap>(undefined);
|
||||
|
@ -49,16 +54,34 @@
|
|||
});
|
||||
const userRelatedState = new UserRelatedState(osmConnection, layout?.language);
|
||||
const selectedElement = new UIEventSource<Feature | undefined>(undefined, "Selected element");
|
||||
selectedElement.addCallbackAndRunD(s => console.log("Selected element:", s))
|
||||
const geolocation = new GeoLocationHandler(geolocationState, selectedElement, mapproperties, userRelatedState.gpsLocationHistoryRetentionTime);
|
||||
|
||||
const allElements = new ElementStorage();
|
||||
const tags = new Or(layout.layers.filter(l => l.source !== null&& Constants.priviliged_layers.indexOf(l.id) < 0 && l.source.geojsonSource === undefined).map(l => l.source.osmTags ))
|
||||
const layerState = new LayerState(osmConnection, layout.layers, layout.id)
|
||||
|
||||
const indexedElements = new LayoutSource(layout.layers, featureSwitches, new StaticFeatureSource([]), mapproperties, osmConnection.Backend(),
|
||||
(id) => layerState.filteredLayers.get(id).isDisplayed
|
||||
)
|
||||
|
||||
const allElements = new FeaturePropertiesStore(indexedElements)
|
||||
const changes = new Changes({
|
||||
allElements,
|
||||
dryRun: featureSwitches.featureSwitchIsTesting,
|
||||
allElements: indexedElements,
|
||||
featurePropertiesStore: allElements,
|
||||
osmConnection,
|
||||
historicalUserLocations: geolocation.historicalUserLocations
|
||||
}, layout?.isLeftRightSensitive() ?? false);
|
||||
console.log("Setting up layerstate...")
|
||||
const layerState = new LayerState(osmConnection, layout.layers, layout.id)
|
||||
|
||||
new ShowDataMultiLayer(maplibremap, {
|
||||
layers: Array.from(layerState.filteredLayers.values()),
|
||||
features: indexedElements,
|
||||
fetchStore: id => <UIEventSource<OsmTags>> allElements.getStore(id),
|
||||
selectedElement,
|
||||
globalFilters: layerState.globalFilters
|
||||
})
|
||||
|
||||
|
||||
{
|
||||
// Various actors that we don't need to reference
|
||||
// TODO enable new TitleHandler(selectedElement,layout,allElements)
|
||||
|
@ -98,7 +121,7 @@
|
|||
current_view: new StaticFeatureSource(mapproperties.bounds.map(bbox => bbox === undefined ? empty : <Feature[]> [bbox.asGeoJson({id:"current_view"})])),
|
||||
}
|
||||
layerState.filteredLayers.get("range")?.isDisplayed?.syncWith(featureSwitches.featureSwitchIsTesting, true)
|
||||
console.log("RAnge fs", specialLayers.range)
|
||||
|
||||
specialLayers.range.features.addCallbackAndRun(fs => console.log("Range.features:", JSON.stringify(fs)))
|
||||
layerState.filteredLayers.forEach((flayer) => {
|
||||
const features = specialLayers[flayer.layerDef.id]
|
||||
|
@ -116,7 +139,8 @@ console.log("RAnge fs", specialLayers.range)
|
|||
</script>
|
||||
|
||||
|
||||
<div class="h-screen w-screen absolute top-0 left-0 border-3 border-red-500">
|
||||
<div class="h-screen w-screen absolute top-0 left-0 flex">
|
||||
<div id="fullscreen" class="transition-all transition-duration-500" style="border: 2px solid red">Hello world</div>
|
||||
<MaplibreMap class="w-full h-full border border-black" map={maplibremap}></MaplibreMap>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue