Add loading of live data

This commit is contained in:
Pieter Vander Vennet 2020-10-12 01:25:27 +02:00
parent feab5a19b3
commit 0d6412f824
14 changed files with 291 additions and 35 deletions

View file

@ -1,6 +1,6 @@
import {Bounds} from "../Bounds";
import {TagsFilter} from "../Tags";
import $ from "jquery"
import * as $ from "jquery"
import * as OsmToGeoJson from "osmtogeojson";
/**
@ -27,14 +27,13 @@ export class Overpass {
}
queryGeoJson(bounds: Bounds, continuation: ((any) => void), onFail: ((reason) => void)): void {
let query = this.buildQuery( "[bbox:" + bounds.south + "," + bounds.west + "," + bounds.north + "," + bounds.east + "]")
if(Overpass.testUrl !== null){
let query = this.buildQuery("[bbox:" + bounds.south + "," + bounds.west + "," + bounds.north + "," + bounds.east + "]")
if (Overpass.testUrl !== null) {
console.log("Using testing URL")
query = Overpass.testUrl;
}
$.getJSON(query,
function (json, status) {
if (status !== "success") {
@ -42,7 +41,7 @@ export class Overpass {
onFail(status);
}
if(json.elements === [] && json.remarks.indexOf("runtime error") > 0){
if (json.elements === [] && json.remarks.indexOf("runtime error") > 0) {
console.log("Timeout or other runtime error");
onFail("Runtime error (timeout)")
return;