forked from MapComplete/MapComplete
Preparatory steps to query OSM-api directly, add precise input to bench and waste basket, add waste types
This commit is contained in:
parent
3c51c28157
commit
b39a2b2f6e
7 changed files with 108 additions and 14 deletions
|
@ -38,6 +38,7 @@ import {LayoutConfigJson} from "./Models/ThemeConfig/Json/LayoutConfigJson";
|
||||||
import LayoutConfig from "./Models/ThemeConfig/LayoutConfig";
|
import LayoutConfig from "./Models/ThemeConfig/LayoutConfig";
|
||||||
import LayerConfig from "./Models/ThemeConfig/LayerConfig";
|
import LayerConfig from "./Models/ThemeConfig/LayerConfig";
|
||||||
import Minimap from "./UI/Base/Minimap";
|
import Minimap from "./UI/Base/Minimap";
|
||||||
|
import Constants from "./Models/Constants";
|
||||||
|
|
||||||
export class InitUiElements {
|
export class InitUiElements {
|
||||||
static InitAll(
|
static InitAll(
|
||||||
|
@ -400,7 +401,8 @@ export class InitUiElements {
|
||||||
state.layoutToUse,
|
state.layoutToUse,
|
||||||
state.leafletMap,
|
state.leafletMap,
|
||||||
state.overpassUrl,
|
state.overpassUrl,
|
||||||
state.overpassTimeout
|
state.overpassTimeout,
|
||||||
|
Constants.useOsmApiAt
|
||||||
);
|
);
|
||||||
State.state.layerUpdater = updater;
|
State.state.layerUpdater = updater;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ export default class OverpassFeatureSource implements FeatureSource {
|
||||||
public readonly sufficientlyZoomed: UIEventSource<boolean>;
|
public readonly sufficientlyZoomed: UIEventSource<boolean>;
|
||||||
public readonly runningQuery: UIEventSource<boolean> = new UIEventSource<boolean>(false);
|
public readonly runningQuery: UIEventSource<boolean> = new UIEventSource<boolean>(false);
|
||||||
public readonly timeout: UIEventSource<number> = new UIEventSource<number>(0);
|
public readonly timeout: UIEventSource<number> = new UIEventSource<number>(0);
|
||||||
|
|
||||||
private readonly retries: UIEventSource<number> = new UIEventSource<number>(0);
|
private readonly retries: UIEventSource<number> = new UIEventSource<number>(0);
|
||||||
/**
|
/**
|
||||||
* The previous bounds for which the query has been run at the given zoom level
|
* The previous bounds for which the query has been run at the given zoom level
|
||||||
|
@ -46,7 +47,8 @@ export default class OverpassFeatureSource implements FeatureSource {
|
||||||
layoutToUse: UIEventSource<LayoutConfig>,
|
layoutToUse: UIEventSource<LayoutConfig>,
|
||||||
leafletMap: UIEventSource<L.Map>,
|
leafletMap: UIEventSource<L.Map>,
|
||||||
interpreterUrl: UIEventSource<string>,
|
interpreterUrl: UIEventSource<string>,
|
||||||
timeout: UIEventSource<number>,) {
|
timeout: UIEventSource<number>,
|
||||||
|
maxZoom = undefined) {
|
||||||
this._location = location;
|
this._location = location;
|
||||||
this._layoutToUse = layoutToUse;
|
this._layoutToUse = layoutToUse;
|
||||||
this._leafletMap = leafletMap;
|
this._leafletMap = leafletMap;
|
||||||
|
@ -59,7 +61,14 @@ export default class OverpassFeatureSource implements FeatureSource {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let minzoom = Math.min(...layoutToUse.data.layers.map(layer => layer.minzoom ?? 18));
|
let minzoom = Math.min(...layoutToUse.data.layers.map(layer => layer.minzoom ?? 18));
|
||||||
return location.zoom >= minzoom;
|
if(location.zoom < minzoom){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(maxZoom !== undefined && location.zoom > maxZoom){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}, [layoutToUse]
|
}, [layoutToUse]
|
||||||
);
|
);
|
||||||
for (let i = 0; i < 25; i++) {
|
for (let i = 0; i < 25; i++) {
|
||||||
|
|
|
@ -1,16 +1,34 @@
|
||||||
import FeatureSource from "./FeatureSource";
|
import FeatureSource from "./FeatureSource";
|
||||||
import {UIEventSource} from "../UIEventSource";
|
import {UIEventSource} from "../UIEventSource";
|
||||||
import {OsmObject} from "../Osm/OsmObject";
|
import {OsmObject} from "../Osm/OsmObject";
|
||||||
import State from "../../State";
|
|
||||||
import {Utils} from "../../Utils";
|
import {Utils} from "../../Utils";
|
||||||
|
import Loc from "../../Models/Loc";
|
||||||
|
import FilteredLayer from "../../Models/FilteredLayer";
|
||||||
|
import Constants from "../../Models/Constants";
|
||||||
|
|
||||||
|
|
||||||
export default class OsmApiFeatureSource implements FeatureSource {
|
export default class OsmApiFeatureSource implements FeatureSource {
|
||||||
public readonly features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{ feature: any; freshness: Date }[]>([]);
|
public readonly features: UIEventSource<{ feature: any; freshness: Date }[]> = new UIEventSource<{ feature: any; freshness: Date }[]>([]);
|
||||||
public readonly name: string = "OsmApiFeatureSource";
|
public readonly name: string = "OsmApiFeatureSource";
|
||||||
private readonly loadedTiles: Set<string> = new Set<string>();
|
private readonly loadedTiles: Set<string> = new Set<string>();
|
||||||
|
private readonly _state: {
|
||||||
|
leafletMap: UIEventSource<any>;
|
||||||
|
locationControl: UIEventSource<Loc>, filteredLayers: UIEventSource<FilteredLayer[]>};
|
||||||
|
|
||||||
constructor() {
|
constructor(minZoom = undefined, state: {locationControl: UIEventSource<Loc>, filteredLayers: UIEventSource<FilteredLayer[]>, leafletMap: UIEventSource<any>}) {
|
||||||
|
this._state = state;
|
||||||
|
if(minZoom !== undefined){
|
||||||
|
if(minZoom < 14){
|
||||||
|
throw "MinZoom should be at least 14 or higher, OSM-api won't work otherwise"
|
||||||
|
}
|
||||||
|
const self = this;
|
||||||
|
state.locationControl.addCallbackAndRunD(location => {
|
||||||
|
if(location.zoom > minZoom){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.loadArea()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,21 +52,21 @@ export default class OsmApiFeatureSource implements FeatureSource {
|
||||||
/**
|
/**
|
||||||
* Loads the current inview-area
|
* Loads the current inview-area
|
||||||
*/
|
*/
|
||||||
public loadArea(z: number = 16): boolean {
|
public loadArea(z: number = 14): boolean {
|
||||||
const layers = State.state.filteredLayers.data;
|
const layers = this._state.filteredLayers.data;
|
||||||
|
|
||||||
const disabledLayers = layers.filter(layer => layer.layerDef.source.overpassScript !== undefined || layer.layerDef.source.geojsonSource !== undefined)
|
const disabledLayers = layers.filter(layer => layer.layerDef.source.overpassScript !== undefined || layer.layerDef.source.geojsonSource !== undefined)
|
||||||
if (disabledLayers.length > 0) {
|
if (disabledLayers.length > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const loc = State.state.locationControl.data;
|
const loc = this._state.locationControl.data;
|
||||||
if (loc.zoom < 16) {
|
if (loc.zoom < Constants.useOsmApiAt) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (State.state.leafletMap.data === undefined) {
|
if (this._state.leafletMap.data === undefined) {
|
||||||
return false; // Not yet inited
|
return false; // Not yet inited
|
||||||
}
|
}
|
||||||
const bounds = State.state.leafletMap.data.getBounds()
|
const bounds = this._state.leafletMap.data.getBounds()
|
||||||
const tileRange = Utils.TileRangeBetween(z, bounds.getNorth(), bounds.getEast(), bounds.getSouth(), bounds.getWest())
|
const tileRange = Utils.TileRangeBetween(z, bounds.getNorth(), bounds.getEast(), bounds.getSouth(), bounds.getWest())
|
||||||
const self = this;
|
const self = this;
|
||||||
Utils.MapRange(tileRange, (x, y) => {
|
Utils.MapRange(tileRange, (x, y) => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {Utils} from "../Utils";
|
||||||
|
|
||||||
export default class Constants {
|
export default class Constants {
|
||||||
|
|
||||||
public static vNumber = "0.9.8";
|
public static vNumber = "0.9.9";
|
||||||
|
|
||||||
// The user journey states thresholds when a new feature gets unlocked
|
// The user journey states thresholds when a new feature gets unlocked
|
||||||
public static userJourney = {
|
public static userJourney = {
|
||||||
|
@ -26,6 +26,12 @@ export default class Constants {
|
||||||
*/
|
*/
|
||||||
static updateTimeoutSec: number = 30;
|
static updateTimeoutSec: number = 30;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If zoom >= useOsmApiAt, then the OSM api will be used directly.
|
||||||
|
* If undefined, use overpass exclusively
|
||||||
|
*/
|
||||||
|
static useOsmApiAt = undefined;
|
||||||
|
|
||||||
private static isRetina(): boolean {
|
private static isRetina(): boolean {
|
||||||
if (Utils.runningFromConsole) {
|
if (Utils.runningFromConsole) {
|
||||||
return;
|
return;
|
||||||
|
|
2
State.ts
2
State.ts
|
@ -398,7 +398,7 @@ export default class State {
|
||||||
|
|
||||||
new ChangeToElementsActor(this.changes, this.allElements)
|
new ChangeToElementsActor(this.changes, this.allElements)
|
||||||
|
|
||||||
this.osmApiFeatureSource = new OsmApiFeatureSource()
|
this.osmApiFeatureSource = new OsmApiFeatureSource(Constants.useOsmApiAt, this)
|
||||||
|
|
||||||
new PendingChangesUploader(this.changes, this.selectedElement);
|
new PendingChangesUploader(this.changes, this.selectedElement);
|
||||||
|
|
||||||
|
|
|
@ -605,6 +605,9 @@
|
||||||
"pt_BR": "Adicionar um novo banco",
|
"pt_BR": "Adicionar um novo banco",
|
||||||
"fi": "Lisää uusi penkki",
|
"fi": "Lisää uusi penkki",
|
||||||
"pl": "Dodaj nową ławkę"
|
"pl": "Dodaj nową ławkę"
|
||||||
|
},
|
||||||
|
"presiceInput": {
|
||||||
|
"preferredBackground": "photo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -22,7 +22,60 @@
|
||||||
"en": "This is a public waste basket, thrash can, where you can throw away your thrash.",
|
"en": "This is a public waste basket, thrash can, where you can throw away your thrash.",
|
||||||
"nl": "Dit is een publieke vuilnisbak waar je je afval kan weggooien."
|
"nl": "Dit is een publieke vuilnisbak waar je je afval kan weggooien."
|
||||||
},
|
},
|
||||||
"tagRenderings": [],
|
"tagRenderings": [
|
||||||
|
{
|
||||||
|
"question": {
|
||||||
|
"en": "What kind of waste basket is this?",
|
||||||
|
"nl": "Wat voor soort vuilnisbak is dit?"
|
||||||
|
},
|
||||||
|
"multiAnswer": true,
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"if": "waste=",
|
||||||
|
"then": {
|
||||||
|
"en": "A waste basket for general waste",
|
||||||
|
"nl": "Een vuilnisbak voor zwerfvuil"
|
||||||
|
},
|
||||||
|
"hideInAnswer": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "waste=trash",
|
||||||
|
"then": {
|
||||||
|
"en": "A waste basket for general waste",
|
||||||
|
"nl": "Een vuilnisbak voor zwerfvuil"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "waste=dog_excrement",
|
||||||
|
"then": {
|
||||||
|
"en": "A waste basket for dog excrements",
|
||||||
|
"nl": "Een vuilnisbak specifiek voor hondenuitwerpselen"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "waste=cigarettes",
|
||||||
|
"then": {
|
||||||
|
"en": "A waste basket for cigarettes",
|
||||||
|
"nl": "Een vuilnisbak voor sigarettenpeuken"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "waste=drugs",
|
||||||
|
"then": {
|
||||||
|
"en": "A waste basket for drugs",
|
||||||
|
"nl": "Een vuilnisbak voor (vervallen) medicatie en drugs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "waste=sharps",
|
||||||
|
"then": {
|
||||||
|
"en": "A waste basket for needles and other sharp objects",
|
||||||
|
"nl": "Een vuilnisbak voor injectienaalden en andere scherpe voorwerpen"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"icon": {
|
"icon": {
|
||||||
"render": "./assets/themes/waste_basket/waste_basket.svg"
|
"render": "./assets/themes/waste_basket/waste_basket.svg"
|
||||||
},
|
},
|
||||||
|
@ -56,6 +109,9 @@
|
||||||
"title": {
|
"title": {
|
||||||
"en": "Waste Basket",
|
"en": "Waste Basket",
|
||||||
"nl": "Vuilnisbak"
|
"nl": "Vuilnisbak"
|
||||||
|
},
|
||||||
|
"presiceInput": {
|
||||||
|
"preferredBackground": "photo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue