forked from MapComplete/MapComplete
Refactoring: split 'Utils' into multiple files; fix some stray uppercase-method names
This commit is contained in:
parent
81be4db044
commit
3ec89826e4
97 changed files with 884 additions and 921 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import { Store, UIEventSource } from "../../UIEventSource"
|
||||
import { FeatureSource, IndexedFeatureSource, UpdatableFeatureSource } from "../FeatureSource"
|
||||
import { Feature } from "geojson"
|
||||
import { Utils } from "../../../Utils"
|
||||
import { OsmFeature } from "../../../Models/OsmFeature"
|
||||
import { Lists } from "../../../Utils/Lists"
|
||||
|
||||
/**
|
||||
* The featureSourceMerger receives complete geometries from various sources.
|
||||
|
|
@ -23,7 +23,7 @@ export default class FeatureSourceMerger<Src extends FeatureSource = FeatureSour
|
|||
constructor(...sources: Src[]) {
|
||||
this._featuresById = new UIEventSource<Map<string, Feature>>(new Map<string, Feature>())
|
||||
this.featuresById = this._featuresById
|
||||
sources = Utils.NoNull(sources)
|
||||
sources = Lists.noNull(sources)
|
||||
for (const source of sources) {
|
||||
source.features.addCallback(() => {
|
||||
this.addDataFromSources(sources)
|
||||
|
|
@ -69,7 +69,7 @@ export default class FeatureSourceMerger<Src extends FeatureSource = FeatureSour
|
|||
}
|
||||
|
||||
protected addData(sources: Feature[][]) {
|
||||
sources = Utils.NoNull(sources)
|
||||
sources = Lists.noNull(sources)
|
||||
let somethingChanged = false
|
||||
const all: Map<string, Feature> = new Map()
|
||||
const unseen = new Set<string>()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import BaseUIElement from "../../../UI/BaseUIElement"
|
|||
import { Utils } from "../../../Utils"
|
||||
import { OsmTags } from "../../../Models/OsmFeature"
|
||||
import { FeatureSource } from "../FeatureSource"
|
||||
import { Lists } from "../../../Utils/Lists"
|
||||
|
||||
/**
|
||||
* Highly specialized feature source.
|
||||
|
|
@ -48,11 +49,9 @@ export class LastClickFeatureSource implements FeatureSource {
|
|||
allPresets.push(html)
|
||||
}
|
||||
|
||||
this.renderings = Utils.Dedup(
|
||||
allPresets.map((uiElem) =>
|
||||
Utils.runningFromConsole ? "" : uiElem.ConstructElement().innerHTML
|
||||
)
|
||||
)
|
||||
this.renderings = Lists.dedup(allPresets.map((uiElem) =>
|
||||
Utils.runningFromConsole ? "" : uiElem.ConstructElement().innerHTML
|
||||
))
|
||||
|
||||
this._features = new UIEventSource<Feature[]>([])
|
||||
this.features = this._features
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { Feature } from "geojson"
|
|||
import FeatureSourceMerger from "../Sources/FeatureSourceMerger"
|
||||
import OsmObjectDownloader from "../../Osm/OsmObjectDownloader"
|
||||
import FullNodeDatabaseSource from "../TiledFeatureSource/FullNodeDatabaseSource"
|
||||
import { Lists } from "../../../Utils/Lists"
|
||||
|
||||
/**
|
||||
* If a tile is needed (requested via the UIEventSource in the constructor), will download the appropriate tile and pass it via 'handleTile'
|
||||
|
|
@ -173,7 +174,7 @@ export default class OsmFeatureSource extends FeatureSourceMerger {
|
|||
for (let i = 0; i < features.length; i++) {
|
||||
features[i] = await this.patchIncompleteRelations(features[i], <any>osmJson)
|
||||
}
|
||||
features = Utils.NoNull(features)
|
||||
features = Lists.noNull(features)
|
||||
features.forEach((f) => {
|
||||
f.properties["_backend"] = this._backend
|
||||
})
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { Utils } from "../../../Utils"
|
|||
import { TagsFilter } from "../../Tags/TagsFilter"
|
||||
import { BBox } from "../../BBox"
|
||||
import { OsmTags } from "../../../Models/OsmFeature"
|
||||
import { Lists } from "../../../Utils/Lists"
|
||||
|
||||
("use strict")
|
||||
|
||||
|
|
@ -199,7 +200,7 @@ export default class OverpassFeatureSource implements UpdatableFeatureSource {
|
|||
*/
|
||||
private GetFilter(interpreterUrl: string, layersToDownload: LayerConfig[]): Overpass {
|
||||
let filters: TagsFilter[] = layersToDownload.map((layer) => layer.source.osmTags)
|
||||
filters = Utils.NoNull(filters)
|
||||
filters = Lists.noNull(filters)
|
||||
if (filters.length === 0) {
|
||||
return undefined
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { Utils } from "../../../Utils"
|
|||
import { Feature, MultiLineString, Position } from "geojson"
|
||||
import { GeoOperations } from "../../GeoOperations"
|
||||
import { UpdatableDynamicTileSource } from "./DynamicTileSource"
|
||||
import { Lists } from "../../../Utils/Lists"
|
||||
|
||||
/**
|
||||
* The PolygonSourceMerger receives various small pieces of bigger polygons and stitches them together.
|
||||
|
|
@ -32,7 +33,7 @@ export class LineSourceMerger extends UpdatableDynamicTileSource<
|
|||
}
|
||||
|
||||
protected addDataFromSources(sources: FeatureSourceForTile[]) {
|
||||
sources = Utils.NoNull(sources)
|
||||
sources = Lists.noNull(sources)
|
||||
const all: Map<string, Feature<MultiLineString>> = new Map()
|
||||
const currentZoom = this._zoomlevel?.data ?? 0
|
||||
for (const source of sources) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { FeatureSourceForTile, UpdatableFeatureSource } from "../FeatureSource"
|
||||
import { Store } from "../../UIEventSource"
|
||||
import { BBox } from "../../BBox"
|
||||
import { Utils } from "../../../Utils"
|
||||
import { Feature } from "geojson"
|
||||
import { GeoOperations } from "../../GeoOperations"
|
||||
import { UpdatableDynamicTileSource } from "./DynamicTileSource"
|
||||
import { Lists } from "../../../Utils/Lists"
|
||||
|
||||
/**
|
||||
* The PolygonSourceMerger receives various small pieces of bigger polygons and stitches them together.
|
||||
|
|
@ -29,7 +29,7 @@ export class PolygonSourceMerger extends UpdatableDynamicTileSource<
|
|||
}
|
||||
|
||||
protected addDataFromSources(sources: FeatureSourceForTile[]) {
|
||||
sources = Utils.NoNull(sources)
|
||||
sources = Lists.noNull(sources)
|
||||
const all: Map<string, Feature> = new Map()
|
||||
const zooms: Map<string, number> = new Map()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue