forked from MapComplete/MapComplete
Docs: create overview of online services (for F-Droid acceptance); inline ELI again
This commit is contained in:
parent
1a75823f17
commit
e9209f6b7c
26 changed files with 1099 additions and 298 deletions
|
@ -9,25 +9,14 @@ import { Store, Stores, UIEventSource } from "../Logic/UIEventSource"
|
|||
import { GeoOperations } from "../Logic/GeoOperations"
|
||||
import { EliCategory, RasterLayerProperties } from "./RasterLayerProperties"
|
||||
import { Utils } from "../Utils"
|
||||
|
||||
import {default as ELI} from "../../public/assets/data/editor-layer-index.json"
|
||||
export type EditorLayerIndex = (Feature<Polygon, EditorLayerIndexProperties> & RasterLayerPolygon)[]
|
||||
|
||||
export class AvailableRasterLayers {
|
||||
private static _editorLayerIndex: EditorLayerIndex = undefined
|
||||
private static _editorLayerIndexStore: UIEventSource<EditorLayerIndex> =
|
||||
new UIEventSource<EditorLayerIndex>(undefined)
|
||||
private static _editorLayerIndex: EditorLayerIndex = <EditorLayerIndex> ELI.features
|
||||
|
||||
public static async editorLayerIndex(): Promise<EditorLayerIndex> {
|
||||
if (AvailableRasterLayers._editorLayerIndex !== undefined) {
|
||||
return AvailableRasterLayers._editorLayerIndex
|
||||
}
|
||||
console.debug("Downloading ELI")
|
||||
const eli = await Utils.downloadJson<{ features: EditorLayerIndex }>(
|
||||
"./assets/data/editor-layer-index.json"
|
||||
)
|
||||
this._editorLayerIndex = eli.features?.filter((l) => l.properties.id !== "Bing") ?? []
|
||||
this._editorLayerIndexStore.set(this._editorLayerIndex)
|
||||
return this._editorLayerIndex
|
||||
public static editorLayerIndex(): EditorLayerIndex {
|
||||
return AvailableRasterLayers._editorLayerIndex
|
||||
}
|
||||
|
||||
public static readonly globalLayers: ReadonlyArray<RasterLayerPolygon> =
|
||||
|
@ -101,18 +90,13 @@ export class AvailableRasterLayers {
|
|||
location: Store<{ lon: number; lat: number }>,
|
||||
enableBing?: Store<boolean>
|
||||
): Store<RasterLayerPolygon[]> {
|
||||
this.editorLayerIndex() // start the download
|
||||
const availableLayersBboxes = Stores.ListStabilized(
|
||||
location.mapD(
|
||||
(loc) => {
|
||||
const eli = AvailableRasterLayers._editorLayerIndexStore.data
|
||||
if (!eli) {
|
||||
return []
|
||||
}
|
||||
const eli = AvailableRasterLayers._editorLayerIndex
|
||||
const lonlat: [number, number] = [loc.lon, loc.lat]
|
||||
return eli.filter((eliPolygon) => BBox.get(eliPolygon).contains(lonlat))
|
||||
},
|
||||
[AvailableRasterLayers._editorLayerIndexStore]
|
||||
}
|
||||
)
|
||||
)
|
||||
return Stores.ListStabilized(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue