forked from MapComplete/MapComplete
Lots of refactoring, first version of the import helper
This commit is contained in:
parent
612b8136ad
commit
3402ac0954
54 changed files with 1104 additions and 315 deletions
|
@ -145,6 +145,15 @@ export class BBox {
|
|||
this.maxLat + latDiff]])
|
||||
}
|
||||
|
||||
padAbsolute(degrees: number): BBox {
|
||||
|
||||
return new BBox([[
|
||||
this.minLon - degrees,
|
||||
this.minLat - degrees
|
||||
], [this.maxLon + degrees,
|
||||
this.maxLat + degrees]])
|
||||
}
|
||||
|
||||
toLeaflet() {
|
||||
return [[this.minLat, this.minLon], [this.maxLat, this.maxLon]]
|
||||
}
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
/***
|
||||
* Saves all the features that are passed in to localstorage, so they can be retrieved on the next run
|
||||
*
|
||||
* Technically, more an Actor then a featuresource, but it fits more neatly this ay
|
||||
*/
|
||||
import FeatureSource, {Tiled} from "../FeatureSource";
|
||||
import {Tiles} from "../../../Models/TileRange";
|
||||
import {IdbLocalStorage} from "../../Web/IdbLocalStorage";
|
||||
|
@ -13,6 +8,11 @@ import SimpleFeatureSource from "../Sources/SimpleFeatureSource";
|
|||
import FilteredLayer from "../../../Models/FilteredLayer";
|
||||
import Loc from "../../../Models/Loc";
|
||||
|
||||
/***
|
||||
* Saves all the features that are passed in to localstorage, so they can be retrieved on the next run
|
||||
*
|
||||
* Technically, more an Actor then a featuresource, but it fits more neatly this ay
|
||||
*/
|
||||
export default class SaveTileToLocalStorageActor {
|
||||
private readonly visitedTiles: UIEventSource<Map<number, Date>>
|
||||
private readonly _layer: LayerConfig;
|
||||
|
|
|
@ -44,7 +44,7 @@ export class Imgur extends ImageProvider {
|
|||
|
||||
}
|
||||
|
||||
static uploadImage(title: string, description: string, blob,
|
||||
static uploadImage(title: string, description: string, blob: File,
|
||||
handleSuccessfullUpload: ((imageURL: string) => void),
|
||||
onFail: (reason: string) => void) {
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import State from "../../../State";
|
||||
import {OsmObject} from "../OsmObject";
|
||||
import OsmChangeAction from "./OsmChangeAction";
|
||||
import {Changes} from "../Changes";
|
||||
|
@ -52,7 +51,7 @@ export default class DeleteAction extends OsmChangeAction {
|
|||
return await new ChangeTagAction(
|
||||
this._id, this._softDeletionTags, osmObject.tags,
|
||||
{
|
||||
theme: State.state?.layoutToUse?.id ?? "unkown",
|
||||
... this.meta,
|
||||
changeType: "soft-delete"
|
||||
}
|
||||
).CreateChangeDescriptions(changes)
|
||||
|
|
|
@ -9,7 +9,6 @@ import * as osmtogeojson from "osmtogeojson";
|
|||
* Interfaces overpass to get all the latest data
|
||||
*/
|
||||
export class Overpass {
|
||||
public static testUrl: string = null
|
||||
private _filter: TagsFilter
|
||||
private readonly _interpreterUrl: string;
|
||||
private readonly _timeout: UIEventSource<number>;
|
||||
|
@ -36,10 +35,6 @@ export class Overpass {
|
|||
|
||||
let query = this.buildQuery("[bbox:" + bounds.getSouth() + "," + bounds.getWest() + "," + bounds.getNorth() + "," + bounds.getEast() + "]")
|
||||
|
||||
if (Overpass.testUrl !== null) {
|
||||
console.log("Using testing URL")
|
||||
query = Overpass.testUrl;
|
||||
}
|
||||
const self = this;
|
||||
const json = await Utils.downloadJson(query)
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import MapState from "./MapState";
|
|||
import SelectedFeatureHandler from "../Actors/SelectedFeatureHandler";
|
||||
import Hash from "../Web/Hash";
|
||||
import {BBox} from "../BBox";
|
||||
import FeatureInfoBox from "../../UI/Popup/FeatureInfoBox";
|
||||
|
||||
export default class FeaturePipelineState extends MapState {
|
||||
|
||||
|
@ -93,8 +94,9 @@ export default class FeaturePipelineState extends MapState {
|
|||
leafletMap: self.leafletMap,
|
||||
layerToShow: source.layer.layerDef,
|
||||
doShowLayer: doShowFeatures,
|
||||
allElements: self.allElements,
|
||||
selectedElement: self.selectedElement
|
||||
selectedElement: self.selectedElement,
|
||||
state: self,
|
||||
popup: (tags, layer) => new FeatureInfoBox(tags, layer, self)
|
||||
}
|
||||
);
|
||||
}, this
|
||||
|
@ -112,11 +114,13 @@ export default class FeaturePipelineState extends MapState {
|
|||
*/
|
||||
public AddClusteringToMap(leafletMap: UIEventSource<any>) {
|
||||
const clustering = this.layoutToUse.clustering
|
||||
const self = this;
|
||||
new ShowDataLayer({
|
||||
features: this.featureAggregator.getCountsForZoom(clustering, this.locationControl, clustering.minNeededElements),
|
||||
leafletMap: leafletMap,
|
||||
layerToShow: ShowTileInfo.styling,
|
||||
enablePopups: this.featureSwitchIsDebugging.data,
|
||||
popup: this.featureSwitchIsDebugging.data ? (tags, layer) => new FeatureInfoBox(tags, layer, self) : undefined,
|
||||
state: this
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,12 @@ export class UIEventSource<T> {
|
|||
|
||||
source.addCallback((latestData) => {
|
||||
sink.setData(latestData?.data);
|
||||
latestData.addCallback(data => {
|
||||
if(source.data !== latestData){
|
||||
return true;
|
||||
}
|
||||
sink.setData(data)
|
||||
})
|
||||
});
|
||||
|
||||
for (const possibleSource of possibleSources ?? []) {
|
||||
|
|
|
@ -8,12 +8,17 @@ import {Utils} from "../../Utils";
|
|||
export class IdbLocalStorage {
|
||||
|
||||
|
||||
public static Get<T>(key: string, options: { defaultValue?: T }): UIEventSource<T>{
|
||||
const src = new UIEventSource<T>(options.defaultValue, "idb-local-storage:"+key)
|
||||
public static Get<T>(key: string, options?: { defaultValue?: T , whenLoaded?: (t: T) => void}): UIEventSource<T>{
|
||||
const src = new UIEventSource<T>(options?.defaultValue, "idb-local-storage:"+key)
|
||||
if(Utils.runningFromConsole){
|
||||
return src;
|
||||
}
|
||||
idb.get(key).then(v => src.setData(v ?? options.defaultValue))
|
||||
idb.get(key).then(v => {
|
||||
src.setData(v ?? options?.defaultValue);
|
||||
if(options?.whenLoaded !== undefined){
|
||||
options?.whenLoaded(v)
|
||||
}
|
||||
})
|
||||
src.addCallback(v => idb.set(key, v))
|
||||
return src;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue