Feature: add bing maps (test), see #648

This commit is contained in:
Pieter Vander Vennet 2024-01-28 05:10:13 +01:00
parent 94f39e89fe
commit ed050d5be3
6 changed files with 170 additions and 35 deletions

View file

@ -8,9 +8,14 @@ import { RasterLayerProperties } from "./RasterLayerProperties"
export class AvailableRasterLayers {
public static EditorLayerIndex: (Feature<Polygon, EditorLayerIndexProperties> &
RasterLayerPolygon)[] = <any>editorlayerindex.features
RasterLayerPolygon)[] = (<any>editorlayerindex.features).filter(
(l) => l.properties.id !== "Bing"
)
public static globalLayers: RasterLayerPolygon[] = globallayers.layers
.filter((properties) => properties.id !== "osm.carto" /*Added separately*/)
.filter(
(properties) =>
properties.id !== "osm.carto" && properties.id !== "Bing" /*Added separately*/
)
.map(
(properties) =>
<RasterLayerPolygon>{
@ -19,6 +24,9 @@ export class AvailableRasterLayers {
geometry: BBox.global.asGeometry(),
}
)
public static bing: RasterLayerPolygon = (<any>editorlayerindex.features).find(
(l) => l.properties.id === "Bing"
)
public static readonly osmCartoProperties: RasterLayerProperties = {
id: "osm",
name: "OpenStreetMap",
@ -56,7 +64,8 @@ export class AvailableRasterLayers {
}
public static layersAvailableAt(
location: Store<{ lon: number; lat: number }>
location: Store<{ lon: number; lat: number }>,
enableBing?: Store<boolean>
): Store<RasterLayerPolygon[]> {
const availableLayersBboxes = Stores.ListStabilized(
location.mapD((loc) => {
@ -67,20 +76,26 @@ export class AvailableRasterLayers {
})
)
return Stores.ListStabilized(
availableLayersBboxes.map((eliPolygons) => {
const loc = location.data
const lonlat: [number, number] = [loc.lon, loc.lat]
const matching: RasterLayerPolygon[] = eliPolygons.filter((eliPolygon) => {
if (eliPolygon.geometry === null) {
return true // global ELI-layer
availableLayersBboxes.map(
(eliPolygons) => {
const loc = location.data
const lonlat: [number, number] = [loc.lon, loc.lat]
const matching: RasterLayerPolygon[] = eliPolygons.filter((eliPolygon) => {
if (eliPolygon.geometry === null) {
return true // global ELI-layer
}
return GeoOperations.inside(lonlat, eliPolygon)
})
matching.unshift(AvailableRasterLayers.osmCarto)
matching.push(AvailableRasterLayers.maptilerDefaultLayer)
if (enableBing?.data) {
matching.push(AvailableRasterLayers.bing)
}
return GeoOperations.inside(lonlat, eliPolygon)
})
matching.unshift(AvailableRasterLayers.osmCarto)
matching.push(AvailableRasterLayers.maptilerDefaultLayer)
matching.push(...AvailableRasterLayers.globalLayers)
return matching
})
matching.push(...AvailableRasterLayers.globalLayers)
return matching
},
[enableBing]
)
)
}