Refactoring: move 'featureSummary' to specialLayer handling, disable summary server for now

This commit is contained in:
Pieter Vander Vennet 2024-09-24 17:54:18 +02:00
parent 2a53f99dd5
commit 29dce0d468
6 changed files with 126 additions and 119 deletions

View file

@ -32,7 +32,8 @@
}, },
"mvt_layer_server": "https://cache.mapcomplete.org/public.{type}_{layer}/{z}/{x}/{y}.pbf", "mvt_layer_server": "https://cache.mapcomplete.org/public.{type}_{layer}/{z}/{x}/{y}.pbf",
"#summary_server": "Should be the endpoint; appending status.json should work", "#summary_server": "Should be the endpoint; appending status.json should work",
"summary_server": "https://cache.mapcomplete.org/", "disabled:summary_server": "https://cache.mapcomplete.org/",
"summary_server": null,
"geoip_server": "https://ipinfo.mapcomplete.org/", "geoip_server": "https://ipinfo.mapcomplete.org/",
"error_server": "https://report.mapcomplete.org/report", "error_server": "https://report.mapcomplete.org/report",
"api_keys": { "api_keys": {

View file

@ -2,11 +2,7 @@ import LayoutConfig from "./ThemeConfig/LayoutConfig"
import { SpecialVisualizationState } from "../UI/SpecialVisualization" import { SpecialVisualizationState } from "../UI/SpecialVisualization"
import { Changes } from "../Logic/Osm/Changes" import { Changes } from "../Logic/Osm/Changes"
import { Store, UIEventSource } from "../Logic/UIEventSource" import { Store, UIEventSource } from "../Logic/UIEventSource"
import { import { FeatureSource, IndexedFeatureSource, WritableFeatureSource } from "../Logic/FeatureSource/FeatureSource"
FeatureSource,
IndexedFeatureSource,
WritableFeatureSource
} from "../Logic/FeatureSource/FeatureSource"
import { OsmConnection } from "../Logic/Osm/OsmConnection" import { OsmConnection } from "../Logic/Osm/OsmConnection"
import { ExportableMap, MapProperties } from "./MapProperties" import { ExportableMap, MapProperties } from "./MapProperties"
import LayerState from "../Logic/State/LayerState" import LayerState from "../Logic/State/LayerState"
@ -50,9 +46,7 @@ import BackgroundLayerResetter from "../Logic/Actors/BackgroundLayerResetter"
import SaveFeatureSourceToLocalStorage from "../Logic/FeatureSource/Actors/SaveFeatureSourceToLocalStorage" import SaveFeatureSourceToLocalStorage from "../Logic/FeatureSource/Actors/SaveFeatureSourceToLocalStorage"
import BBoxFeatureSource from "../Logic/FeatureSource/Sources/TouchesBboxFeatureSource" import BBoxFeatureSource from "../Logic/FeatureSource/Sources/TouchesBboxFeatureSource"
import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor" import ThemeViewStateHashActor from "../Logic/Web/ThemeViewStateHashActor"
import NoElementsInViewDetector, { import NoElementsInViewDetector, { FeatureViewState } from "../Logic/Actors/NoElementsInViewDetector"
FeatureViewState
} from "../Logic/Actors/NoElementsInViewDetector"
import FilteredLayer from "./FilteredLayer" import FilteredLayer from "./FilteredLayer"
import { PreferredRasterLayerSelector } from "../Logic/Actors/PreferredRasterLayerSelector" import { PreferredRasterLayerSelector } from "../Logic/Actors/PreferredRasterLayerSelector"
import { ImageUploadManager } from "../Logic/ImageProviders/ImageUploadManager" import { ImageUploadManager } from "../Logic/ImageProviders/ImageUploadManager"
@ -64,7 +58,7 @@ import { GeolocationControlState } from "../UI/BigComponents/GeolocationControl"
import Zoomcontrol from "../UI/Zoomcontrol" import Zoomcontrol from "../UI/Zoomcontrol"
import { import {
SummaryTileSource, SummaryTileSource,
SummaryTileSourceRewriter SummaryTileSourceRewriter,
} from "../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource" } from "../Logic/FeatureSource/TiledFeatureSource/SummaryTileSource"
import summaryLayer from "../assets/generated/layers/summary.json" import summaryLayer from "../assets/generated/layers/summary.json"
import last_click_layerconfig from "../assets/generated/layers/last_click.json" import last_click_layerconfig from "../assets/generated/layers/last_click.json"
@ -120,7 +114,6 @@ export default class ThemeViewState implements SpecialVisualizationState {
readonly closestFeatures: NearbyFeatureSource readonly closestFeatures: NearbyFeatureSource
readonly newFeatures: WritableFeatureSource readonly newFeatures: WritableFeatureSource
readonly layerState: LayerState readonly layerState: LayerState
readonly featureSummary: SummaryTileSourceRewriter
readonly perLayer: ReadonlyMap<string, GeoIndexedStoreForLayer> readonly perLayer: ReadonlyMap<string, GeoIndexedStoreForLayer>
readonly perLayerFiltered: ReadonlyMap<string, FilteringFeatureSource> readonly perLayerFiltered: ReadonlyMap<string, FilteringFeatureSource>
@ -159,7 +152,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
/** /**
* Geocoded images that should be shown on the main map; probably only the currently hovered image * Geocoded images that should be shown on the main map; probably only the currently hovered image
*/ */
public readonly geocodedImages: UIEventSource<Feature[]> = new UIEventSource<Feature[]>([ ]) public readonly geocodedImages: UIEventSource<Feature[]> = new UIEventSource<Feature[]>([])
public readonly searchState: SearchState public readonly searchState: SearchState
@ -169,7 +162,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.featureSwitches = new FeatureSwitchState(layout) this.featureSwitches = new FeatureSwitchState(layout)
this.guistate = new MenuState( this.guistate = new MenuState(
this.featureSwitches.featureSwitchWelcomeMessage.data, this.featureSwitches.featureSwitchWelcomeMessage.data,
layout.id layout.id,
) )
this.map = new UIEventSource<MlMap>(undefined) this.map = new UIEventSource<MlMap>(undefined)
const geolocationState = new GeoLocationState() const geolocationState = new GeoLocationState()
@ -185,14 +178,14 @@ export default class ThemeViewState implements SpecialVisualizationState {
oauth_token: QueryParameters.GetQueryParameter( oauth_token: QueryParameters.GetQueryParameter(
"oauth_token", "oauth_token",
undefined, undefined,
"Used to complete the login" "Used to complete the login",
) ),
}) })
this.userRelatedState = new UserRelatedState( this.userRelatedState = new UserRelatedState(
this.osmConnection, this.osmConnection,
layout, layout,
this.featureSwitches, this.featureSwitches,
this.mapProperties this.mapProperties,
) )
this.userRelatedState.fixateNorth.addCallbackAndRunD((fixated) => { this.userRelatedState.fixateNorth.addCallbackAndRunD((fixated) => {
this.mapProperties.allowRotating.setData(fixated !== "yes") this.mapProperties.allowRotating.setData(fixated !== "yes")
@ -203,20 +196,20 @@ export default class ThemeViewState implements SpecialVisualizationState {
geolocationState, geolocationState,
this.selectedElement, this.selectedElement,
this.mapProperties, this.mapProperties,
this.userRelatedState.gpsLocationHistoryRetentionTime this.userRelatedState.gpsLocationHistoryRetentionTime,
) )
this.geolocationControl = new GeolocationControlState(this.geolocation, this.mapProperties) this.geolocationControl = new GeolocationControlState(this.geolocation, this.mapProperties)
this.availableLayers = AvailableRasterLayers.layersAvailableAt( this.availableLayers = AvailableRasterLayers.layersAvailableAt(
this.mapProperties.location, this.mapProperties.location,
this.osmConnection.isLoggedIn this.osmConnection.isLoggedIn,
) )
this.layerState = new LayerState( this.layerState = new LayerState(
this.osmConnection, this.osmConnection,
layout.layers, layout.layers,
layout.id, layout.id,
this.featureSwitches.featureSwitchLayerDefault this.featureSwitches.featureSwitchLayerDefault,
) )
{ {
@ -225,7 +218,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
const isDisplayed = QueryParameters.GetBooleanQueryParameter( const isDisplayed = QueryParameters.GetBooleanQueryParameter(
"overlay-" + rasterInfo.id, "overlay-" + rasterInfo.id,
rasterInfo.defaultState ?? true, rasterInfo.defaultState ?? true,
"Whether or not overlay layer " + rasterInfo.id + " is shown" "Whether or not overlay layer " + rasterInfo.id + " is shown",
) )
const state = { isDisplayed } const state = { isDisplayed }
overlayLayerStates.set(rasterInfo.id, state) overlayLayerStates.set(rasterInfo.id, state)
@ -250,7 +243,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.osmConnection.Backend(), this.osmConnection.Backend(),
(id) => this.layerState.filteredLayers.get(id).isDisplayed, (id) => this.layerState.filteredLayers.get(id).isDisplayed,
mvtAvailableLayers, mvtAvailableLayers,
this.fullNodeDatabase this.fullNodeDatabase,
) )
let currentViewIndex = 0 let currentViewIndex = 0
@ -265,10 +258,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
bbox.asGeoJson({ bbox.asGeoJson({
zoom: this.mapProperties.zoom.data, zoom: this.mapProperties.zoom.data,
...this.mapProperties.location.data, ...this.mapProperties.location.data,
id: "current_view_" + currentViewIndex id: "current_view_" + currentViewIndex,
}) }),
] ]
}) }),
) )
this.featuresInView = new BBoxFeatureSource(layoutSource, this.mapProperties.bounds) this.featuresInView = new BBoxFeatureSource(layoutSource, this.mapProperties.bounds)
@ -283,22 +276,22 @@ export default class ThemeViewState implements SpecialVisualizationState {
featurePropertiesStore: this.featureProperties, featurePropertiesStore: this.featureProperties,
osmConnection: this.osmConnection, osmConnection: this.osmConnection,
historicalUserLocations: this.geolocation.historicalUserLocations, historicalUserLocations: this.geolocation.historicalUserLocations,
featureSwitches: this.featureSwitches featureSwitches: this.featureSwitches,
}, },
layout?.isLeftRightSensitive() ?? false, layout?.isLeftRightSensitive() ?? false,
(e, extraMsg) => this.reportError(e, extraMsg) (e, extraMsg) => this.reportError(e, extraMsg),
) )
this.historicalUserLocations = this.geolocation.historicalUserLocations this.historicalUserLocations = this.geolocation.historicalUserLocations
this.newFeatures = new NewGeometryFromChangesFeatureSource( this.newFeatures = new NewGeometryFromChangesFeatureSource(
this.changes, this.changes,
layoutSource, layoutSource,
this.featureProperties this.featureProperties,
) )
layoutSource.addSource(this.newFeatures) layoutSource.addSource(this.newFeatures)
const perLayer = new PerLayerFeatureSourceSplitter( const perLayer = new PerLayerFeatureSourceSplitter(
Array.from(this.layerState.filteredLayers.values()).filter( Array.from(this.layerState.filteredLayers.values()).filter(
(l) => l.layerDef?.source !== null (l) => l.layerDef?.source !== null,
), ),
new ChangeGeometryApplicator(this.indexedFeatures, this.changes), new ChangeGeometryApplicator(this.indexedFeatures, this.changes),
{ {
@ -309,10 +302,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
"Got ", "Got ",
features.length, features.length,
"leftover features, such as", "leftover features, such as",
features[0].properties features[0].properties,
) )
} },
} },
) )
this.perLayer = perLayer.perLayer this.perLayer = perLayer.perLayer
} }
@ -352,12 +345,12 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.lastClickObject = new LastClickFeatureSource( this.lastClickObject = new LastClickFeatureSource(
this.layout, this.layout,
this.mapProperties.lastClickLocation, this.mapProperties.lastClickLocation,
this.userRelatedState.addNewFeatureMode this.userRelatedState.addNewFeatureMode,
) )
this.osmObjectDownloader = new OsmObjectDownloader( this.osmObjectDownloader = new OsmObjectDownloader(
this.osmConnection.Backend(), this.osmConnection.Backend(),
this.changes this.changes,
) )
this.perLayerFiltered = this.showNormalDataOn(this.map) this.perLayerFiltered = this.showNormalDataOn(this.map)
@ -367,8 +360,8 @@ export default class ThemeViewState implements SpecialVisualizationState {
{ {
currentZoom: this.mapProperties.zoom, currentZoom: this.mapProperties.zoom,
layerState: this.layerState, layerState: this.layerState,
bounds: this.visualFeedbackViewportBounds bounds: this.visualFeedbackViewportBounds,
} },
) )
this.hasDataInView = new NoElementsInViewDetector(this).hasFeatureInView this.hasDataInView = new NoElementsInViewDetector(this).hasFeatureInView
this.imageUploadManager = new ImageUploadManager( this.imageUploadManager = new ImageUploadManager(
@ -376,14 +369,13 @@ export default class ThemeViewState implements SpecialVisualizationState {
Imgur.singleton, Imgur.singleton,
this.featureProperties, this.featureProperties,
this.osmConnection, this.osmConnection,
this.changes this.changes,
) )
this.favourites = new FavouritesFeatureSource(this) this.favourites = new FavouritesFeatureSource(this)
const longAgo = new Date() const longAgo = new Date()
longAgo.setTime(new Date().getTime() - 5 * 365 * 24 * 60 * 60 * 1000) longAgo.setTime(new Date().getTime() - 5 * 365 * 24 * 60 * 60 * 1000)
this.nearbyImageSearcher = new CombinedFetcher(50, longAgo, this.indexedFeatures) this.nearbyImageSearcher = new CombinedFetcher(50, longAgo, this.indexedFeatures)
this.featureSummary = this.setupSummaryLayer()
this.toCacheSavers = layout.enableCache ? this.initSaveToLocalStorage() : undefined this.toCacheSavers = layout.enableCache ? this.initSaveToLocalStorage() : undefined
this.searchState = new SearchState(this) this.searchState = new SearchState(this)
@ -424,7 +416,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
LayoutSource.fromCacheZoomLevel, LayoutSource.fromCacheZoomLevel,
fs, fs,
this.featureProperties, this.featureProperties,
fs.layer.layerDef.maxAgeOfCache fs.layer.layerDef.maxAgeOfCache,
) )
toLocalStorage.set(layerId, storage) toLocalStorage.set(layerId, storage)
}) })
@ -437,7 +429,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
const doShowLayer = this.mapProperties.zoom.map( const doShowLayer = this.mapProperties.zoom.map(
(z) => (z) =>
(fs.layer.isDisplayed?.data ?? true) && z >= (fs.layer.layerDef?.minzoom ?? 0), (fs.layer.isDisplayed?.data ?? true) && z >= (fs.layer.layerDef?.minzoom ?? 0),
[fs.layer.isDisplayed] [fs.layer.isDisplayed],
) )
if (!doShowLayer.data && this.featureSwitches.featureSwitchFilter.data === false) { if (!doShowLayer.data && this.featureSwitches.featureSwitchFilter.data === false) {
@ -454,7 +446,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
fs.layer, fs.layer,
fs, fs,
(id) => this.featureProperties.getStore(id), (id) => this.featureProperties.getStore(id),
this.layerState.globalFilters this.layerState.globalFilters,
) )
filteringFeatureSource.set(layerName, filtered) filteringFeatureSource.set(layerName, filtered)
@ -464,7 +456,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
doShowLayer, doShowLayer,
metaTags: this.userRelatedState.preferencesAsTags, metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement, selectedElement: this.selectedElement,
fetchStore: (id) => this.featureProperties.getStore(id) fetchStore: (id) => this.featureProperties.getStore(id),
}) })
}) })
return filteringFeatureSource return filteringFeatureSource
@ -491,7 +483,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
doShowLayer: flayerGps.isDisplayed, doShowLayer: flayerGps.isDisplayed,
layer: flayerGps.layerDef, layer: flayerGps.layerDef,
metaTags: this.userRelatedState.preferencesAsTags, metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement selectedElement: this.selectedElement,
}) })
} }
@ -588,7 +580,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ {
nomod: " ", nomod: " ",
onUp: true onUp: true,
}, },
docs.selectItem, docs.selectItem,
() => { () => {
@ -602,7 +594,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
return return
} }
this.selectClosestAtCenter(0) this.selectClosestAtCenter(0)
} },
) )
for (let i = 1; i < 9; i++) { for (let i = 1; i < 9; i++) {
@ -617,10 +609,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ {
nomod: "" + i, nomod: "" + i,
onUp: true onUp: true,
}, },
doc, doc,
() => this.selectClosestAtCenter(i - 1) () => this.selectClosestAtCenter(i - 1),
) )
} }
@ -636,25 +628,25 @@ export default class ThemeViewState implements SpecialVisualizationState {
} }
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ {
nomod: "b" nomod: "b",
}, },
docs.openLayersPanel, docs.openLayersPanel,
() => { () => {
if (this.featureSwitches.featureSwitchBackgroundSelection.data) { if (this.featureSwitches.featureSwitchBackgroundSelection.data) {
this.guistate.pageStates.background.setData(true) this.guistate.pageStates.background.setData(true)
} }
} },
) )
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ {
nomod: "s" nomod: "s",
}, },
Translations.t.hotkeyDocumentation.openFilterPanel, Translations.t.hotkeyDocumentation.openFilterPanel,
() => { () => {
if (this.featureSwitches.featureSwitchFilter.data) { if (this.featureSwitches.featureSwitchFilter.data) {
this.guistate.openFilterView() this.guistate.openFilterView()
} }
} },
) )
const setLayerCategory = (category: EliCategory, skipLayers: number = 0) => { const setLayerCategory = (category: EliCategory, skipLayers: number = 0) => {
const timeOfCall = new Date() const timeOfCall = new Date()
@ -669,7 +661,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
available, available,
category, category,
current.data, current.data,
skipLayers skipLayers,
) )
if (!best) { if (!best) {
return return
@ -682,50 +674,50 @@ export default class ThemeViewState implements SpecialVisualizationState {
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ nomod: "O" }, { nomod: "O" },
Translations.t.hotkeyDocumentation.selectOsmbasedmap, Translations.t.hotkeyDocumentation.selectOsmbasedmap,
() => setLayerCategory("osmbasedmap") () => setLayerCategory("osmbasedmap"),
) )
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ nomod: "M" }, { nomod: "M" },
Translations.t.hotkeyDocumentation.selectMap, Translations.t.hotkeyDocumentation.selectMap,
() => setLayerCategory("map") () => setLayerCategory("map"),
) )
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ nomod: "P" }, { nomod: "P" },
Translations.t.hotkeyDocumentation.selectAerial, Translations.t.hotkeyDocumentation.selectAerial,
() => setLayerCategory("photo") () => setLayerCategory("photo"),
) )
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ shift: "O" }, { shift: "O" },
Translations.t.hotkeyDocumentation.selectOsmbasedmap, Translations.t.hotkeyDocumentation.selectOsmbasedmap,
() => setLayerCategory("osmbasedmap", 2) () => setLayerCategory("osmbasedmap", 2),
) )
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ shift: "M" }, { shift: "M" },
Translations.t.hotkeyDocumentation.selectMap, Translations.t.hotkeyDocumentation.selectMap,
() => setLayerCategory("map", 2) () => setLayerCategory("map", 2),
) )
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ shift: "P" }, { shift: "P" },
Translations.t.hotkeyDocumentation.selectAerial, Translations.t.hotkeyDocumentation.selectAerial,
() => setLayerCategory("photo", 2) () => setLayerCategory("photo", 2),
) )
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ nomod: "L" }, { nomod: "L" },
Translations.t.hotkeyDocumentation.geolocate, Translations.t.hotkeyDocumentation.geolocate,
() => { () => {
this.geolocationControl.handleClick() this.geolocationControl.handleClick()
} },
) )
return true return true
}) })
Hotkeys.RegisterHotkey( Hotkeys.RegisterHotkey(
{ {
shift: "T" shift: "T",
}, },
Translations.t.hotkeyDocumentation.translationMode, Translations.t.hotkeyDocumentation.translationMode,
() => { () => {
@ -735,35 +727,39 @@ export default class ThemeViewState implements SpecialVisualizationState {
} else { } else {
tm.setData("false") tm.setData("false")
} }
} },
) )
} }
private setupSummaryLayer(): SummaryTileSourceRewriter { private setupSummaryLayer(): SummaryTileSourceRewriter | undefined {
/** /**
* MaxZoom for the summary layer * MaxZoom for the summary layer
*/ */
const normalLayers = this.layout.layers.filter( const normalLayers = this.layout.layers.filter(
(l) => (l) =>
Constants.priviliged_layers.indexOf(<any>l.id) < 0 && Constants.priviliged_layers.indexOf(<any>l.id) < 0 &&
!l.id.startsWith("note_import") !l.id.startsWith("note_import"),
) )
const maxzoom = Math.min(...normalLayers.map((l) => l.minzoom)) const maxzoom = Math.min(...normalLayers.map((l) => l.minzoom))
const layers = this.layout.layers.filter( const layers = this.layout.layers.filter(
(l) => (l) =>
Constants.priviliged_layers.indexOf(<any>l.id) < 0 && Constants.priviliged_layers.indexOf(<any>l.id) < 0 &&
l.source.geojsonSource === undefined && l.source.geojsonSource === undefined &&
l.doCount l.doCount,
) )
if (!Constants.SummaryServer || layers.length === 0) {
return undefined
}
const summaryTileSource = new SummaryTileSource( const summaryTileSource = new SummaryTileSource(
Constants.SummaryServer, Constants.SummaryServer,
layers.map((l) => l.id), layers.map((l) => l.id),
this.mapProperties.zoom.map((z) => Math.max(Math.floor(z), 0)), this.mapProperties.zoom.map((z) => Math.max(Math.floor(z), 0)),
this.mapProperties, this.mapProperties,
{ {
isActive: this.mapProperties.zoom.map((z) => z < maxzoom) isActive: this.mapProperties.zoom.map((z) => z < maxzoom),
} },
) )
return new SummaryTileSourceRewriter(summaryTileSource, this.layerState.filteredLayers) return new SummaryTileSourceRewriter(summaryTileSource, this.layerState.filteredLayers)
@ -785,18 +781,27 @@ export default class ThemeViewState implements SpecialVisualizationState {
gps_track: this.geolocation.historicalUserLocationsTrack, gps_track: this.geolocation.historicalUserLocationsTrack,
geocoded_image: new StaticFeatureSource(this.geocodedImages), geocoded_image: new StaticFeatureSource(this.geocodedImages),
selected_element: new StaticFeatureSource( selected_element: new StaticFeatureSource(
this.selectedElement.map((f) => (f === undefined ? empty : [f])) this.selectedElement.map((f) => (f === undefined ? empty : [f])),
), ),
range: new StaticFeatureSource( range: new StaticFeatureSource(
this.mapProperties.maxbounds.map((bbox) => this.mapProperties.maxbounds.map((bbox) =>
bbox === undefined ? empty : <Feature[]>[bbox.asGeoJson({ id: "range" })] bbox === undefined ? empty : <Feature[]>[bbox.asGeoJson({ id: "range" })],
) ),
), ),
current_view: this.currentView, current_view: this.currentView,
favourite: this.favourites, favourite: this.favourites,
summary: this.featureSummary, summary: this.setupSummaryLayer(),
last_click: this.lastClickObject, last_click: this.lastClickObject,
search: this.searchState.locationResults search: this.searchState.locationResults,
}
if (specialLayers.summary) {
new ShowDataLayer(this.map, {
features: specialLayers.summary,
layer: new LayerConfig(<LayerConfigJson>summaryLayer, "summaryLayer"),
// doShowLayer: this.mapProperties.zoom.map((z) => z < maxzoom),
selectedElement: this.selectedElement,
})
} }
this.closestFeatures.registerSource(specialLayers.favourite, "favourite") this.closestFeatures.registerSource(specialLayers.favourite, "favourite")
@ -806,7 +811,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
ShowDataLayer.showRange( ShowDataLayer.showRange(
this.map, this.map,
new StaticFeatureSource([bbox.asGeoJson({ id: "range" })]), new StaticFeatureSource([bbox.asGeoJson({ id: "range" })]),
this.featureSwitches.featureSwitchIsTesting this.featureSwitches.featureSwitchIsTesting,
) )
} }
const currentViewLayer = this.layout.layers.find((l) => l.id === "current_view") const currentViewLayer = this.layout.layers.find((l) => l.id === "current_view")
@ -820,7 +825,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
currentViewLayer, currentViewLayer,
this.layout, this.layout,
this.osmObjectDownloader, this.osmObjectDownloader,
this.featureProperties this.featureProperties,
) )
}) })
} }
@ -838,7 +843,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.layerState.filteredLayers.forEach((flayer) => { this.layerState.filteredLayers.forEach((flayer) => {
const id = flayer.layerDef.id const id = flayer.layerDef.id
const features: FeatureSource = specialLayers[id] const features: FeatureSource = specialLayers[id]
if (features === undefined) { if (!features?.features) {
return return
} }
if (id === "summary" || id === "last_click") { if (id === "summary" || id === "last_click") {
@ -851,7 +856,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
doShowLayer: flayer.isDisplayed, doShowLayer: flayer.isDisplayed,
layer: flayer.layerDef, layer: flayer.layerDef,
metaTags: this.userRelatedState.preferencesAsTags, metaTags: this.userRelatedState.preferencesAsTags,
selectedElement: this.selectedElement selectedElement: this.selectedElement,
} }
if (flayer.layerDef.id === "search") { if (flayer.layerDef.id === "search") {
@ -862,44 +867,41 @@ export default class ThemeViewState implements SpecialVisualizationState {
} }
new ShowDataLayer(this.map, options) new ShowDataLayer(this.map, options)
}) })
const summaryLayerConfig = new LayerConfig(<LayerConfigJson>summaryLayer, "summaryLayer")
new ShowDataLayer(this.map, {
features: specialLayers.summary,
layer: summaryLayerConfig,
// doShowLayer: this.mapProperties.zoom.map((z) => z < maxzoom),
selectedElement: this.selectedElement
})
const lastClickLayerConfig = new LayerConfig( // last click
<LayerConfigJson>last_click_layerconfig, {
"last_click" const lastClickLayerConfig = new LayerConfig(
) <LayerConfigJson>last_click_layerconfig,
const lastClickFiltered = "last_click",
lastClickLayerConfig.isShown === undefined )
? specialLayers.last_click const lastClickFiltered =
: specialLayers.last_click.features.mapD((fs) => lastClickLayerConfig.isShown === undefined
fs.filter((f) => { ? specialLayers.last_click
const matches = lastClickLayerConfig.isShown.matchesProperties( : specialLayers.last_click.features.mapD((fs) =>
f.properties fs.filter((f) => {
) const matches = lastClickLayerConfig.isShown.matchesProperties(
console.debug("LastClick ", f, "matches", matches) f.properties,
return matches )
console.debug("LastClick ", f, "matches", matches)
return matches
}),
)
// show last click = new point/note marker
new ShowDataLayer(this.map, {
features: new StaticFeatureSource(lastClickFiltered),
layer: lastClickLayerConfig,
onClick: (feature) => {
if (this.mapProperties.zoom.data >= Constants.minZoomLevelToAddNewPoint) {
this.selectedElement.setData(feature)
return
}
this.map.data.flyTo({
zoom: Constants.minZoomLevelToAddNewPoint,
center: GeoOperations.centerpointCoordinates(feature),
}) })
) },
new ShowDataLayer(this.map, { })
features: new StaticFeatureSource(lastClickFiltered), }
layer: lastClickLayerConfig,
onClick: (feature) => {
if (this.mapProperties.zoom.data >= Constants.minZoomLevelToAddNewPoint) {
this.selectedElement.setData(feature)
return
}
this.map.data.flyTo({
zoom: Constants.minZoomLevelToAddNewPoint,
center: GeoOperations.centerpointCoordinates(feature)
})
}
})
} }
/** /**
@ -935,13 +937,13 @@ export default class ThemeViewState implements SpecialVisualizationState {
selected?.properties?.alt_name, selected?.properties?.local_name, selected?.properties?.alt_name, selected?.properties?.local_name,
layer?.title.GetRenderValue(selected?.properties ?? {}).txt, layer?.title.GetRenderValue(selected?.properties ?? {}).txt,
selected.properties.display_name, selected.properties.display_name,
selected.properties.id selected.properties.id,
] ]
const r = <GeocodeResult>{ const r = <GeocodeResult>{
feature: selected, feature: selected,
display_name: nameOptions.find(opt => opt !== undefined), display_name: nameOptions.find(opt => opt !== undefined),
osm_id, osm_type, osm_id, osm_type,
lon, lat lon, lat,
} }
this.userRelatedState.recentlyVisitedSearch.add(r) this.userRelatedState.recentlyVisitedSearch.add(r)
}) })
@ -960,7 +962,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.mapProperties.rasterLayer, this.mapProperties.rasterLayer,
this.availableLayers, this.availableLayers,
this.featureSwitches.backgroundLayerId, this.featureSwitches.backgroundLayerId,
this.userRelatedState.preferredBackgroundLayer this.userRelatedState.preferredBackgroundLayer,
) )
} }
@ -1007,7 +1009,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
? ">>> _Not_ reporting error to report server as testmode is on" ? ">>> _Not_ reporting error to report server as testmode is on"
: ">>> Reporting error to", : ">>> Reporting error to",
Constants.ErrorReportServer, Constants.ErrorReportServer,
message message,
) )
if (isTesting) { if (isTesting) {
return return
@ -1049,8 +1051,8 @@ export default class ThemeViewState implements SpecialVisualizationState {
userid: this.osmConnection.userDetails.data?.uid, userid: this.osmConnection.userDetails.data?.uid,
pendingChanges: this.changes.pendingChanges.data, pendingChanges: this.changes.pendingChanges.data,
previousChanges: this.changes.allChanges.data, previousChanges: this.changes.allChanges.data,
changeRewrites: Utils.MapToObj(this.changes._changesetHandler._remappings) changeRewrites: Utils.MapToObj(this.changes._changesetHandler._remappings),
}) }),
}) })
} catch (e) { } catch (e) {
console.error("Could not upload an error report") console.error("Could not upload an error report")

View file

@ -1,7 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { SpecialVisualizationState } from "../SpecialVisualization" import type { SpecialVisualizationState } from "../SpecialVisualization"
import Tr from "../Base/Tr.svelte" import Tr from "../Base/Tr.svelte"
import { createEventDispatcher } from "svelte"
import Icon from "../Map/Icon.svelte" import Icon from "../Map/Icon.svelte"
import ToSvelte from "../Base/ToSvelte.svelte" import ToSvelte from "../Base/ToSvelte.svelte"
import type { FilterSearchResult } from "../../Logic/Search/FilterSearch" import type { FilterSearchResult } from "../../Logic/Search/FilterSearch"

View file

@ -37,7 +37,6 @@ export interface SpecialVisualizationState {
readonly featureSwitches: FeatureSwitchState readonly featureSwitches: FeatureSwitchState
readonly layerState: LayerState readonly layerState: LayerState
readonly featureSummary: SummaryTileSourceRewriter
readonly featureProperties: { readonly featureProperties: {
getStore(id: string): UIEventSource<Record<string, string>>, getStore(id: string): UIEventSource<Record<string, string>>,
trackFeature?(feature: { properties: OsmTags }) trackFeature?(feature: { properties: OsmTags })

View file

@ -27,6 +27,9 @@ async function timeout(timeMS: number): Promise<{ layers: string[] }> {
} }
async function getAvailableLayers(): Promise<Set<string>> { async function getAvailableLayers(): Promise<Set<string>> {
if(!Constants.SummaryServer){
return new Set<string>()
}
try { try {
const host = new URL(Constants.SummaryServer).host const host = new URL(Constants.SummaryServer).host
const status: { layers: string[] } = await Promise.any([ const status: { layers: string[] } = await Promise.any([

View file

@ -25,8 +25,11 @@ async function timeout(timeMS: number): Promise<{ layers: string[] }> {
async function getAvailableLayers(): Promise<Set<string>> { async function getAvailableLayers(): Promise<Set<string>> {
if(!Constants.SummaryServer){
return new Set<string>()
}
try { try {
const host = new URL(Constants.VectorTileServer).host const host = new URL(Constants.SummaryServer).host
const status = await Promise.any([ const status = await Promise.any([
Utils.downloadJson("https://" + host + "/summary/status.json"), Utils.downloadJson("https://" + host + "/summary/status.json"),
timeout(0) timeout(0)