forked from MapComplete/MapComplete
Optimizing trees theme and clustering
This commit is contained in:
parent
5ac035be20
commit
8fca373437
11 changed files with 125 additions and 67 deletions
|
@ -58,7 +58,7 @@ export default class FeaturePipeline {
|
|||
private readonly freshnesses = new Map<string, TileFreshnessCalculator>();
|
||||
|
||||
private readonly oldestAllowedDate: Date = new Date(new Date().getTime() - 60 * 60 * 24 * 30 * 1000);
|
||||
private readonly osmSourceZoomLevel = 15
|
||||
private readonly osmSourceZoomLevel
|
||||
|
||||
constructor(
|
||||
handleFeatureSource: (source: FeatureSourceForLayer & Tiled) => void,
|
||||
|
@ -74,10 +74,12 @@ export default class FeaturePipeline {
|
|||
readonly overpassMaxZoom: UIEventSource<number>;
|
||||
readonly osmConnection: OsmConnection
|
||||
readonly currentBounds: UIEventSource<BBox>,
|
||||
readonly osmApiTileSize: UIEventSource<number>
|
||||
}) {
|
||||
this.state = state;
|
||||
|
||||
const self = this
|
||||
this.osmSourceZoomLevel = state.osmApiTileSize.data;
|
||||
// milliseconds
|
||||
const useOsmApi = state.locationControl.map(l => l.zoom > (state.overpassMaxZoom.data ?? 12))
|
||||
this.relationTracker = new RelationsTracker()
|
||||
|
@ -275,18 +277,19 @@ export default class FeaturePipeline {
|
|||
private getNeededTilesFromOsm(isSufficientlyZoomed: UIEventSource<boolean>): UIEventSource<number[]> {
|
||||
const self = this
|
||||
return this.state.currentBounds.map(bbox => {
|
||||
console.log("Current bbox is", bbox)
|
||||
if (bbox === undefined) {
|
||||
return undefined
|
||||
return []
|
||||
}
|
||||
if (!isSufficientlyZoomed.data) {
|
||||
return undefined;
|
||||
return [];
|
||||
}
|
||||
const osmSourceZoomLevel = self.osmSourceZoomLevel
|
||||
const range = bbox.containingTileRange(osmSourceZoomLevel)
|
||||
const tileIndexes = []
|
||||
if (range.total >= 100) {
|
||||
// Too much tiles!
|
||||
return []
|
||||
return undefined
|
||||
}
|
||||
Tiles.MapRange(range, (x, y) => {
|
||||
const i = Tiles.tile_index(osmSourceZoomLevel, x, y);
|
||||
|
@ -299,7 +302,7 @@ export default class FeaturePipeline {
|
|||
tileIndexes.push(i)
|
||||
})
|
||||
return tileIndexes
|
||||
})
|
||||
}, [isSufficientlyZoomed])
|
||||
}
|
||||
|
||||
private initOverpassUpdater(state: {
|
||||
|
|
|
@ -8,10 +8,6 @@ import {UIEventSource} from "../UIEventSource";
|
|||
import MapState from "./MapState";
|
||||
import SelectedFeatureHandler from "../Actors/SelectedFeatureHandler";
|
||||
import Hash from "../Web/Hash";
|
||||
import ScrollableFullScreen from "../../UI/Base/ScrollableFullScreen";
|
||||
import Translations from "../../UI/i18n/Translations";
|
||||
import SimpleAddUI from "../../UI/BigComponents/SimpleAddUI";
|
||||
import StrayClickHandler from "../Actors/StrayClickHandler";
|
||||
|
||||
export default class FeaturePipelineState extends MapState {
|
||||
|
||||
|
@ -25,7 +21,7 @@ export default class FeaturePipelineState extends MapState {
|
|||
super(layoutToUse);
|
||||
|
||||
const clustering = layoutToUse.clustering
|
||||
this.featureAggregator = TileHierarchyAggregator.createHierarchy();
|
||||
this.featureAggregator = TileHierarchyAggregator.createHierarchy(this);
|
||||
const clusterCounter = this.featureAggregator
|
||||
const self = this;
|
||||
this.featurePipeline = new FeaturePipeline(
|
||||
|
@ -117,12 +113,9 @@ export default class FeaturePipelineState extends MapState {
|
|||
features: this.featureAggregator.getCountsForZoom(clustering, this.locationControl, clustering.minNeededElements),
|
||||
leafletMap: leafletMap,
|
||||
layerToShow: ShowTileInfo.styling,
|
||||
enablePopups: false,
|
||||
enablePopups: this.featureSwitchIsDebugging.data,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -83,6 +83,7 @@ export default class UserRelatedState extends ElementsState {
|
|||
|
||||
|
||||
this.InitializeLanguage();
|
||||
this.initHomeLocation()
|
||||
new SelectedElementTagsUpdater(this)
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue