forked from MapComplete/MapComplete
refactoring
This commit is contained in:
parent
b94a8f5745
commit
5d0fe31c41
114 changed files with 2412 additions and 2958 deletions
|
@ -0,0 +1,36 @@
|
|||
import FeatureSource, { Tiled } from "../FeatureSource"
|
||||
import { Tiles } from "../../../Models/TileRange"
|
||||
import { IdbLocalStorage } from "../../Web/IdbLocalStorage"
|
||||
import { UIEventSource } from "../../UIEventSource"
|
||||
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
|
||||
import { BBox } from "../../BBox"
|
||||
import SimpleFeatureSource from "../Sources/SimpleFeatureSource"
|
||||
import FilteredLayer from "../../../Models/FilteredLayer"
|
||||
import Loc from "../../../Models/Loc"
|
||||
import { Feature } from "geojson"
|
||||
import TileLocalStorage from "./TileLocalStorage"
|
||||
import { GeoOperations } from "../../GeoOperations"
|
||||
import { Utils } from "../../../Utils"
|
||||
|
||||
/***
|
||||
* Saves all the features that are passed in to localstorage, so they can be retrieved on the next run
|
||||
*
|
||||
* The data is saved in a tiled way on a fixed zoomlevel and is retrievable per layer.
|
||||
*
|
||||
* Also see the sibling class
|
||||
*/
|
||||
export default class SaveFeatureSourceToLocalStorage {
|
||||
constructor(layername: string, zoomlevel: number, features: FeatureSource) {
|
||||
const storage = TileLocalStorage.construct<Feature[]>(layername)
|
||||
features.features.addCallbackAndRunD((features) => {
|
||||
const sliced = GeoOperations.slice(zoomlevel, features)
|
||||
sliced.forEach((features, tileIndex) => {
|
||||
const src = storage.getTileSource(tileIndex)
|
||||
if (Utils.sameList(src.data, features)) {
|
||||
return
|
||||
}
|
||||
src.setData(features)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue