Fix maxzoom cutoff for summary layer

This commit is contained in:
Pieter Vander Vennet 2024-02-20 02:56:23 +01:00
parent 049e712981
commit 67b379c16f
4 changed files with 35 additions and 18 deletions

View file

@ -31,10 +31,8 @@ export class SummaryTileSource extends DynamicTileSource {
(tileIndex) => {
const [z, x, y] = Tiles.tile_from_index(tileIndex)
let coordinates = Tiles.centerPointOf(z, x, y)
const count = UIEventSource.FromPromiseWithErr(
Utils.downloadJson(`${cacheserver}/${layersSummed}/${z}/${x}/${y}.json`)
)
const url = `${cacheserver}/${layersSummed}/${z}/${x}/${y}.json`
const count = UIEventSource.FromPromiseWithErr(Utils.downloadJson(url))
const features: Store<Feature<Point>[]> = count.mapD((count) => {
if (count["error"] !== undefined) {
console.error(
@ -61,7 +59,8 @@ export class SummaryTileSource extends DynamicTileSource {
lon,
lat,
tileBbox,
counts
counts,
url
)
} else {
coordinates = [lon, lat]
@ -86,7 +85,6 @@ export class SummaryTileSource extends DynamicTileSource {
return new StaticFeatureSource(
features.map(
(f) => {
console.log("z, zdiff, rounded:", z, zDiff, zoomRounded.data)
if (z - zDiff !== zoomRounded.data) {
return SummaryTileSource.empty
}

View file

@ -391,6 +391,13 @@ class MiscThemeChecks extends DesugaringStep<LayoutConfigJson> {
}
}
if (json["overideAll"]) {
context
.enter("overideAll")
.err(
"'overrideAll' is spelled with _two_ `r`s. You only wrote a single one of them."
)
}
return json
}
}

View file

@ -657,7 +657,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
)
}
private setupSummaryLayer() {
private setupSummaryLayer(maxzoom: number) {
const layers = this.layout.layers.filter(
(l) =>
Constants.priviliged_layers.indexOf(<any>l.id) < 0 &&
@ -668,7 +668,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
url.protocol + "//" + url.host + "/summary",
layers.map((l) => l.id),
this.mapProperties.zoom.map((z) => Math.max(Math.ceil(z), 0)),
this.mapProperties
this.mapProperties,
{
isActive: this.mapProperties.zoom.map((z) => z <= maxzoom),
}
)
}
/**
@ -677,6 +680,22 @@ export default class ThemeViewState implements SpecialVisualizationState {
private drawSpecialLayers() {
type AddedByDefaultTypes = (typeof Constants.added_by_default)[number]
const empty = []
/**
* MaxZoom for the summary layer
*/
const normalLayers = this.layout.layers.filter(
(l) =>
Constants.priviliged_layers.indexOf(<any>l.id) < 0 &&
!l.id.startsWith("note_import")
)
const maxzoom = Math.min(...normalLayers.map((l) => l.minzoom))
console.log(
"Maxzoom for summary layer is",
maxzoom,
normalLayers.map((nl) => nl.id + " - " + nl.minzoom).join(", ")
)
/**
* A listing which maps the layerId onto the featureSource
*/
@ -698,7 +717,7 @@ export default class ThemeViewState implements SpecialVisualizationState {
),
current_view: this.currentView,
favourite: this.favourites,
summary: this.setupSummaryLayer(),
summary: this.setupSummaryLayer(maxzoom),
}
this.closestFeatures.registerSource(specialLayers.favourite, "favourite")
@ -744,7 +763,6 @@ export default class ThemeViewState implements SpecialVisualizationState {
return
}
if (id === "summary") {
console.log("Skipping summary!")
return
}
@ -759,16 +777,10 @@ export default class ThemeViewState implements SpecialVisualizationState {
})
})
const maxzoom = Math.min(
...this.layout.layers
.filter((l) => Constants.priviliged_layers.indexOf(<any>l.id) < 0)
.map((l) => l.minzoom)
)
console.log("Maxzoom is", maxzoom)
new ShowDataLayer(this.map, {
features: specialLayers.summary,
layer: new LayerConfig(<LayerConfigJson>summaryLayer, "summaryLayer"),
doShowLayer: this.mapProperties.zoom.map((z) => z < maxzoom),
// doShowLayer: this.mapProperties.zoom.map((z) => z < maxzoom),
selectedLayer: this.selectedLayer,
selectedElement: this.selectedElement,
})

View file

@ -754,7 +754,7 @@
{"properties":{"name":"Rio Mosaico 2019","id":"rio2019","url":"https://pgeo3.rio.rj.gov.br/arcgis/services/Imagens/Mosaico_2019/ImageServer/WMSServer?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.3.0&SERVICE=WMS&REQUEST=GetMap&LAYERS=0&STYLES=&CRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}","attribution":{"text":"Instituto Pereira Passos - Prefeitura da Cidade do Rio de Janeiro","url":"https://www.rio.rj.gov.br/web/ipp"},"type":"wms","category":"photo","min_zoom":4,"best":true},"type":"Feature","geometry":{"coordinates":[[[-43.59375,-23.09163],[-43.49213,-23.09163],[-43.49043,-23.05158],[-43.42965,-23.04994],[-43.42958,-23.03186],[-43.42655,-23.02912],[-43.35517,-23.02925],[-43.35275,-23.0322],[-43.35273,-23.04931],[-43.32336,-23.05052],[-43.32046,-23.07079],[-43.27378,-23.07079],[-43.27156,-23.05116],[-43.24219,-23.04994],[-43.24219,-23.02902],[-43.23053,-23.02917],[-43.22783,-23.03186],[-43.22776,-23.09163],[-43.11654,-23.09163],[-43.11722,-23.03416],[-43.14502,-23.03414],[-43.1481,-23.03106],[-43.14754,-22.98957],[-43.11653,-22.98732],[-43.11722,-22.90906],[-43.14502,-22.90904],[-43.14805,-22.90629],[-43.14923,-22.86457],[-43.14741,-22.82414],[-43.14433,-22.82106],[-43.08564,-22.82104],[-43.08564,-22.72164],[-43.16528,-22.72227],[-43.1653,-22.73907],[-43.16696,-22.7417],[-43.19618,-22.74253],[-43.1962,-22.76033],[-43.19771,-22.76284],[-43.25866,-22.76343],[-43.25873,-22.78092],[-43.26176,-22.78367],[-43.41453,-22.78622],[-43.41511,-22.80369],[-43.42776,-22.80537],[-43.45873,-22.80481],[-43.46052,-22.80212],[-43.46123,-22.78622],[-43.55392,-22.78749],[-43.5541,-22.79474],[-43.55793,-22.8019],[-43.5704,-22.80269],[-43.57864,-22.81028],[-43.58017,-22.81603],[-43.59306,-22.81851],[-43.59375,-22.84646],[-43.72215,-22.84891],[-43.73108,-22.85144],[-43.73374,-22.85711],[-43.75373,-22.85651],[-43.75466,-22.86261],[-43.75861,-22.86767],[-43.78738,-22.87297],[-43.78944,-22.87424],[-43.78951,-22.8854],[-43.79156,-22.8879],[-43.8121,-22.88817],[-43.8121,-22.93182],[-43.80039,-22.93188],[-43.78897,-22.93578],[-43.78326,-22.94066],[-43.77767,-22.94095],[-43.76014,-22.95055],[-43.75786,-22.98804],[-43.72977,-22.98767],[-43.72766,-22.99051],[-43.72696,-23.00888],[-43.69775,-23.00989],[-43.69606,-23.04994],[-43.68379,-23.0512],[-43.68033,-23.06129],[-43.68026,-23.07079],[-43.60544,-23.07086],[-43.60269,-23.07389],[-43.60267,-23.091],[-43.59375,-23.09163]]],"type":"Polygon"}},
{"properties":{"name":"Rio Mosaico 2022","id":"rio2022","url":"https://pgeo3.rio.rj.gov.br/arcgis/services/Imagens/Mosaico_2022/ImageServer/WMSServer?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.3.0&SERVICE=WMS&REQUEST=GetMap&LAYERS=0&STYLES=&CRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}","attribution":{"text":"Instituto Pereira Passos - Prefeitura da Cidade do Rio de Janeiro","url":"https://www.rio.rj.gov.br/web/ipp"},"type":"wms","category":"photo","min_zoom":4},"type":"Feature","geometry":{"coordinates":[[[-43.59375,-23.09163],[-43.49213,-23.09163],[-43.49043,-23.05158],[-43.42965,-23.04994],[-43.42958,-23.03186],[-43.42655,-23.02912],[-43.35517,-23.02925],[-43.35275,-23.0322],[-43.35273,-23.04931],[-43.32336,-23.05052],[-43.32046,-23.07079],[-43.27378,-23.07079],[-43.27156,-23.05116],[-43.24219,-23.04994],[-43.24219,-23.02902],[-43.23053,-23.02917],[-43.22783,-23.03186],[-43.22776,-23.09163],[-43.11654,-23.09163],[-43.11722,-23.03416],[-43.14502,-23.03414],[-43.1481,-23.03106],[-43.14754,-22.98957],[-43.11653,-22.98732],[-43.11722,-22.90906],[-43.14502,-22.90904],[-43.14805,-22.90629],[-43.14923,-22.86457],[-43.14741,-22.82414],[-43.14433,-22.82106],[-43.08564,-22.82104],[-43.08564,-22.72164],[-43.16528,-22.72227],[-43.1653,-22.73907],[-43.16696,-22.7417],[-43.19618,-22.74253],[-43.1962,-22.76033],[-43.19771,-22.76284],[-43.25866,-22.76343],[-43.25873,-22.78092],[-43.26176,-22.78367],[-43.41453,-22.78622],[-43.41511,-22.80369],[-43.42776,-22.80537],[-43.45873,-22.80481],[-43.46052,-22.80212],[-43.46123,-22.78622],[-43.55392,-22.78749],[-43.5541,-22.79474],[-43.55793,-22.8019],[-43.5704,-22.80269],[-43.57864,-22.81028],[-43.58017,-22.81603],[-43.59306,-22.81851],[-43.59375,-22.84646],[-43.72215,-22.84891],[-43.73108,-22.85144],[-43.73374,-22.85711],[-43.75373,-22.85651],[-43.75466,-22.86261],[-43.75861,-22.86767],[-43.78738,-22.87297],[-43.78944,-22.87424],[-43.78951,-22.8854],[-43.79156,-22.8879],[-43.8121,-22.88817],[-43.8121,-22.93182],[-43.80039,-22.93188],[-43.78897,-22.93578],[-43.78326,-22.94066],[-43.77767,-22.94095],[-43.76014,-22.95055],[-43.75786,-22.98804],[-43.72977,-22.98767],[-43.72766,-22.99051],[-43.72696,-23.00888],[-43.69775,-23.00989],[-43.69606,-23.04994],[-43.68379,-23.0512],[-43.68033,-23.06129],[-43.68026,-23.07079],[-43.60544,-23.07086],[-43.60269,-23.07389],[-43.60267,-23.091],[-43.59375,-23.09163]]],"type":"Polygon"}},
{"properties":{"name":"Jaraguá do Sul Ortomosaico 2020","id":"jaragua-do-sul-2020","url":"https://www.jaraguadosul.sc.gov.br/geo/ortomosaico2020/{zoom}/{x}/{y}.png","attribution":{"text":"Prefeitura de Jaraguá do Sul, SC","url":"https://sistemas.jaraguadosul.sc.gov.br/index.php?class=GeoWelcomeView"},"type":"tms","category":"photo","max_zoom":19},"type":"Feature","geometry":{"coordinates":[[[-49.25368,-26.26563],[-49.17549,-26.31065],[-49.16931,-26.35804],[-49.19403,-26.38449],[-49.19266,-26.42016],[-49.21051,-26.43676],[-49.21806,-26.47733],[-49.22562,-26.48471],[-49.24621,-26.48901],[-49.29634,-26.54185],[-49.30595,-26.58054],[-49.28106,-26.61953],[-49.23798,-26.61922],[-49.20433,-26.62966],[-49.17824,-26.61615],[-49.1645,-26.65237],[-49.13292,-26.64316],[-49.10408,-26.61063],[-49.10133,-26.58177],[-49.0876,-26.57993],[-49.08554,-26.55168],[-49.0567,-26.54615],[-49.05121,-26.51912],[-49.03404,-26.52219],[-49.01756,-26.51298],[-49.01138,-26.48287],[-49.02511,-26.45643],[-49.09515,-26.39863],[-49.10545,-26.39371],[-49.10477,-26.36972],[-49.13635,-26.33219],[-49.13841,-26.30265],[-49.16725,-26.26571],[-49.16725,-26.21336],[-49.19128,-26.21274],[-49.23454,-26.23061],[-49.23386,-26.25524],[-49.25368,-26.26563]]],"type":"Polygon"}},
{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t2.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14296&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null},
{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t1.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14296&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null},
{"properties":{"name":"CyclOSM","id":"cyclosm","url":"https://{switch:a,b,c}.tile-cyclosm.openstreetmap.fr/cyclosm/{zoom}/{x}/{y}.png","attribution":{"text":"Rendering: CyclOSM (hosted by OpenStreetMap France) © Map data OpenStreetMap contributors","url":"https://www.cyclosm.org/"},"type":"tms","category":"osmbasedmap","max_zoom":20},"type":"Feature","geometry":null},
{"properties":{"name":"Esri World Imagery","id":"EsriWorldImagery","url":"https://{switch:services,server}.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{zoom}/{y}/{x}","attribution":{"required":true,"text":"Terms & Feedback","url":"https://wiki.openstreetmap.org/wiki/Esri"},"type":"tms","category":"photo","max_zoom":22,"default":true},"type":"Feature","geometry":null},
{"properties":{"name":"Esri World Imagery (Clarity) Beta","id":"EsriWorldImageryClarity","url":"https://clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{zoom}/{y}/{x}","attribution":{"required":true,"text":"Terms & Feedback","url":"https://wiki.openstreetmap.org/wiki/Esri"},"type":"tms","category":"photo","max_zoom":22,"default":true},"type":"Feature","geometry":null},