forked from MapComplete/MapComplete
Small tweaks
This commit is contained in:
parent
4fcd3523b7
commit
e904043069
6 changed files with 27 additions and 75 deletions
|
@ -298,16 +298,13 @@ export default class FeaturePipeline {
|
|||
readonly overpassMaxZoom: UIEventSource<number>,
|
||||
}, useOsmApi: UIEventSource<boolean>): OverpassFeatureSource {
|
||||
const minzoom = Math.min(...state.layoutToUse.layers.map(layer => layer.minzoom))
|
||||
const allUpToDateAndZoomSufficient = state.currentBounds.map(bbox => {
|
||||
const overpassIsActive = state.currentBounds.map(bbox => {
|
||||
if (bbox === undefined) {
|
||||
return true
|
||||
}
|
||||
if (!this.sufficientlyZoomed?.data) {
|
||||
return true;
|
||||
return false
|
||||
}
|
||||
let zoom = state.locationControl.data.zoom
|
||||
if (zoom < minzoom) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (zoom > 16) {
|
||||
zoom = 16
|
||||
|
@ -315,19 +312,22 @@ export default class FeaturePipeline {
|
|||
if (zoom < 8) {
|
||||
zoom = zoom + 2
|
||||
}
|
||||
|
||||
const range = bbox.containingTileRange(zoom)
|
||||
if(range.total > 100){
|
||||
return false
|
||||
}
|
||||
const self = this;
|
||||
const allFreshnesses = Tiles.MapRange(range, (x, y) => self.freshnessForVisibleLayers(zoom, x, y))
|
||||
return !allFreshnesses.some(freshness => freshness === undefined || freshness < this.oldestAllowedDate)
|
||||
return allFreshnesses.some(freshness => freshness === undefined || freshness < this.oldestAllowedDate)
|
||||
|
||||
}, [state.locationControl])
|
||||
|
||||
allUpToDateAndZoomSufficient.addCallbackAndRunD(allUpToDate => console.log("All up to data is: ", allUpToDate))
|
||||
const self = this;
|
||||
const updater = new OverpassFeatureSource(state,
|
||||
{
|
||||
relationTracker: this.relationTracker,
|
||||
isActive: useOsmApi.map(b => !b && !allUpToDateAndZoomSufficient.data, [allUpToDateAndZoomSufficient]),
|
||||
isActive: useOsmApi.map(b => !b && overpassIsActive.data, [overpassIsActive]),
|
||||
onBboxLoaded: ((bbox, date, downloadedLayers) => {
|
||||
Tiles.MapRange(bbox.containingTileRange(self.osmSourceZoomLevel), (x, y) => {
|
||||
downloadedLayers.forEach(layer => {
|
||||
|
|
|
@ -14,6 +14,10 @@ export class Tiles {
|
|||
|
||||
public static MapRange<T>(tileRange: TileRange, f: (x: number, y: number) => T): T[] {
|
||||
const result: T[] = []
|
||||
const total = tileRange.total
|
||||
if(total > 5000){
|
||||
throw "Tilerange too big"
|
||||
}
|
||||
for (let x = tileRange.xstart; x <= tileRange.xend; x++) {
|
||||
for (let y = tileRange.ystart; y <= tileRange.yend; y++) {
|
||||
const t = f(x, y);
|
||||
|
@ -99,12 +103,6 @@ export class Tiles {
|
|||
const ystart = Math.min(t0.y, t1.y)
|
||||
const yend = Math.max(t0.y, t1.y)
|
||||
const total = (1 + xend - xstart) * (1 + yend - ystart)
|
||||
if(total > 1000){
|
||||
console.trace("Detected a big tilerange which'll be iterated over: zoomlevel", zoomlevel, "bounds:", [[lon0, lat0], [lon1, lat1]])
|
||||
}
|
||||
if(total > 10000){
|
||||
throw "Tilerange too big"
|
||||
}
|
||||
|
||||
return {
|
||||
xstart: xstart,
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class ThemeIntroductionPanel extends Combine {
|
|||
constructor(isShown: UIEventSource<boolean>) {
|
||||
const layout = State.state.layoutToUse
|
||||
|
||||
const languagePicker = LanguagePicker.CreateLanguagePicker(layout.language, Translations.t.general.pickLanguage.Clone())
|
||||
const languagePicker = LanguagePicker.CreateLanguagePicker(layout.language, Translations.t.general.pickLanguage.Clone())
|
||||
|
||||
const toTheMap = new SubtleButton(
|
||||
undefined,
|
||||
|
@ -54,7 +54,7 @@ export default class ThemeIntroductionPanel extends Combine {
|
|||
"<br/><br/>",
|
||||
toTheMap,
|
||||
loginStatus,
|
||||
layout.descriptionTail.Clone(),
|
||||
layout.descriptionTail?.Clone(),
|
||||
"<br/>",
|
||||
languagePicker,
|
||||
...layout.CustomCodeSnippets()
|
||||
|
|
|
@ -22,6 +22,8 @@ export default class ShowDataLayer {
|
|||
/**
|
||||
* If the selected element triggers, this is used to lookup the correct layer and to open the popup
|
||||
* Used to avoid a lot of callbacks on the selected element
|
||||
*
|
||||
* Note: the key of this dictionary is 'feature.properties.id+features.geometry.type' as one feature might have multiple presentations
|
||||
* @private
|
||||
*/
|
||||
private readonly leafletLayersPerId = new Map<string, { feature: any, leafletlayer: any }>()
|
||||
|
@ -68,7 +70,7 @@ export default class ShowDataLayer {
|
|||
if (self._leafletMap.data === undefined) {
|
||||
return;
|
||||
}
|
||||
const v = self.leafletLayersPerId.get(selected.properties.id)
|
||||
const v = self.leafletLayersPerId.get(selected.properties.id+selected.geometry.type)
|
||||
if (v === undefined) {
|
||||
return;
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ export default class ShowDataLayer {
|
|||
|
||||
if (feature.id !== feature.properties.id) {
|
||||
// Probably a feature which has renamed
|
||||
console.trace("Not opening the popup for", feature)
|
||||
console.log("Not opening the popup for", feature, "as probably renamed")
|
||||
return;
|
||||
}
|
||||
if (selected.geometry.type === feature.geometry.type // If a feature is rendered both as way and as point, opening one popup might trigger the other to open, which might trigger the one to open again
|
||||
|
@ -223,10 +225,6 @@ export default class ShowDataLayer {
|
|||
popup.setContent(`<div style='height: 65vh' id='${id}'>Rendering</div>`)
|
||||
|
||||
leafletLayer.on("popupopen", () => {
|
||||
if(State.state.selectedElement.data?.properties?.id !== feature.properties.id){
|
||||
State.state.selectedElement.setData(feature)
|
||||
}
|
||||
|
||||
if (infobox === undefined) {
|
||||
const tags = State.state.allElements.getEventSourceById(feature.properties.id);
|
||||
infobox = new FeatureInfoBox(tags, layer);
|
||||
|
@ -242,11 +240,16 @@ export default class ShowDataLayer {
|
|||
|
||||
infobox.AttachTo(id)
|
||||
infobox.Activate();
|
||||
|
||||
|
||||
if(State.state.selectedElement.data?.properties?.id !== feature.properties.id){
|
||||
// x State.state.selectedElement.setData(feature)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Add the feature to the index to open the popup when needed
|
||||
this.leafletLayersPerId.set(feature.properties.id, {feature: feature, leafletlayer: leafletLayer})
|
||||
this.leafletLayersPerId.set(feature.properties.id+feature.geometry.type, {feature: feature, leafletlayer: leafletLayer})
|
||||
|
||||
}
|
||||
|
||||
|
|
3
Utils.ts
3
Utils.ts
|
@ -1,5 +1,4 @@
|
|||
import * as colors from "./assets/colors.json"
|
||||
import {TileRange} from "./Models/TileRange";
|
||||
|
||||
export class Utils {
|
||||
|
||||
|
@ -238,7 +237,7 @@ export class Utils {
|
|||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
static getOrSetDefault<K, V>(dict: Map<K, V>, k: K, v: () => V) {
|
||||
let found = dict.get(k);
|
||||
if (found !== undefined) {
|
||||
|
|
50
test.ts
50
test.ts
|
@ -1,50 +1,2 @@
|
|||
<<<<<<< HEAD
|
||||
import {Tiles} from "./Models/TileRange";
|
||||
import OsmFeatureSource from "./Logic/FeatureSource/TiledFeatureSource/OsmFeatureSource";
|
||||
import {Utils} from "./Utils";
|
||||
import {AllKnownLayouts} from "./Customizations/AllKnownLayouts";
|
||||
import LayerConfig from "./Models/ThemeConfig/LayerConfig";
|
||||
|
||||
const allLayers: LayerConfig[] = []
|
||||
const seenIds = new Set<string>()
|
||||
for (const layoutConfig of AllKnownLayouts.layoutsList) {
|
||||
if (layoutConfig.hideFromOverview) {
|
||||
continue
|
||||
}
|
||||
for (const layer of layoutConfig.layers) {
|
||||
if (seenIds.has(layer.id)) {
|
||||
continue
|
||||
}
|
||||
seenIds.add(layer.id)
|
||||
allLayers.push(layer)
|
||||
}
|
||||
}
|
||||
|
||||
console.log("All layer ids", allLayers.map(l => l.id))
|
||||
|
||||
const src = new OsmFeatureSource({
|
||||
backend: "https://www.openstreetmap.org",
|
||||
handleTile: tile => console.log("Got tile", tile),
|
||||
allLayers: allLayers
|
||||
})
|
||||
src.LoadTile(16, 33354, 21875).then(geojson => {
|
||||
console.log("Got geojson", geojson);
|
||||
Utils.offerContentsAsDownloadableFile(JSON.stringify(geojson), "test.geojson", {
|
||||
mimetype: "application/vnd.geo+json"
|
||||
})
|
||||
})
|
||||
//*/
|
||||
=======
|
||||
import LocationInput from "./UI/Input/LocationInput";
|
||||
import Loc from "./Models/Loc";
|
||||
import {UIEventSource} from "./Logic/UIEventSource";
|
||||
|
||||
new LocationInput({
|
||||
centerLocation: new UIEventSource<Loc>({
|
||||
lat: 51.1110,
|
||||
lon: 3.3701,
|
||||
zoom : 14
|
||||
})
|
||||
}).SetStyle("height: 500px")
|
||||
.AttachTo("maindiv");
|
||||
>>>>>>> feature/animated-precise-input
|
||||
import {Translation} from "./UI/i18n/Translation";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue