forked from MapComplete/MapComplete
Performance: don't query for summary if the summaries are not online
This commit is contained in:
parent
0c1f9e8cca
commit
517540face
2 changed files with 18 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
import DynamicTileSource from "./DynamicTileSource"
|
||||
import { Store, UIEventSource } from "../../UIEventSource"
|
||||
import { ImmutableStore, Store, UIEventSource } from "../../UIEventSource"
|
||||
import { BBox } from "../../BBox"
|
||||
import StaticFeatureSource from "../Sources/StaticFeatureSource"
|
||||
import { Feature, Point } from "geojson"
|
||||
|
@ -20,7 +20,7 @@ export class SummaryTileSourceRewriter implements FeatureSource {
|
|||
public readonly totalNumberOfFeatures: Store<number> = this._totalNumberOfFeatures
|
||||
constructor(
|
||||
summarySource: SummaryTileSource,
|
||||
filteredLayers: ReadonlyMap<string, FilteredLayer>
|
||||
filteredLayers: ReadonlyMap<string, FilteredLayer>,
|
||||
) {
|
||||
this.filteredLayers = Array.from(filteredLayers.values()).filter(
|
||||
(l) => !Constants.isPriviliged(l.layerDef)
|
||||
|
@ -73,11 +73,18 @@ export class SummaryTileSource extends DynamicTileSource {
|
|||
zoom: Store<number>
|
||||
},
|
||||
options?: {
|
||||
isActive?: Store<boolean>
|
||||
isActive?: Store<boolean>,
|
||||
availableLayers?: Store<Set<string>>
|
||||
}
|
||||
) {
|
||||
const layersSummed = layers.join("+")
|
||||
const zDiff = 2
|
||||
const layersSummed = (options?.availableLayers??new ImmutableStore(undefined)).map(available => {
|
||||
console.log("Determining 'layersSummed' with currently available:", available)
|
||||
if(available === undefined){
|
||||
return layers.join("+")
|
||||
}
|
||||
return layers.filter(l => available.has(l)).join("+")
|
||||
})
|
||||
super(
|
||||
zoomRounded,
|
||||
0, // minzoom
|
||||
|
@ -85,7 +92,7 @@ export class SummaryTileSource extends DynamicTileSource {
|
|||
const features = SummaryTileSource.downloadTile(
|
||||
tileIndex,
|
||||
cacheserver,
|
||||
layersSummed
|
||||
layersSummed.data
|
||||
)
|
||||
const [z] = Tiles.tile_from_index(tileIndex)
|
||||
return new StaticFeatureSource(
|
||||
|
@ -110,6 +117,9 @@ export class SummaryTileSource extends DynamicTileSource {
|
|||
cacheserver: string,
|
||||
layersSummed: string
|
||||
): Store<Feature<Point>[]> {
|
||||
if(layersSummed === ""){
|
||||
return new ImmutableStore([])
|
||||
}
|
||||
const [z, x, y] = Tiles.tile_from_index(tileIndex)
|
||||
let coordinates = Tiles.centerPointOf(z, x, y)
|
||||
const url = `${cacheserver}/summary/${layersSummed}/${z}/${x}/${y}.json`
|
||||
|
|
|
@ -24,6 +24,7 @@ import { ShowDataLayerOptions } from "../../UI/Map/ShowDataLayerOptions"
|
|||
|
||||
export class WithSpecialLayers extends WithChangesState {
|
||||
readonly favourites: FavouritesFeatureSource
|
||||
private mvtAvailableLayers: Store<Set<string>>
|
||||
/**
|
||||
* When hovering (in the popup) an image, the location of the image will be revealed on the main map.
|
||||
* This store contains those images that should be shown, probably only the currently hovered image
|
||||
|
@ -43,6 +44,7 @@ export class WithSpecialLayers extends WithChangesState {
|
|||
|
||||
constructor(theme: ThemeConfig, mvtAvailableLayers: Store<Set<string>>) {
|
||||
super(theme, mvtAvailableLayers)
|
||||
this.mvtAvailableLayers = mvtAvailableLayers
|
||||
|
||||
this.favourites = new FavouritesFeatureSource(this)
|
||||
|
||||
|
@ -111,6 +113,7 @@ export class WithSpecialLayers extends WithChangesState {
|
|||
this.mapProperties,
|
||||
{
|
||||
isActive: this.mapProperties.zoom.map((z) => z < maxzoom),
|
||||
availableLayers: this.mvtAvailableLayers
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue