diff options
| author | Code WvS <code-wvs@quantentunnel.de> | 2015-03-01 12:39:30 +0100 |
|---|---|---|
| committer | Code WvS <code-wvs@quantentunnel.de> | 2015-03-01 12:39:30 +0100 |
| commit | 6dff0b435a059f0c66b842673677c13bfd95f7c4 (patch) | |
| tree | f0179abf954788160ffeffff134c6307ff0f00c3 /threads.js | |
| parent | 6c76ce64d7fb274eb70f4feef17a9bf6dd2093ca (diff) | |
| download | snap-yow-6dff0b435a059f0c66b842673677c13bfd95f7c4.tar.gz snap-yow-6dff0b435a059f0c66b842673677c13bfd95f7c4.zip | |
add overpass API block
Diffstat (limited to 'threads.js')
| -rw-r--r-- | threads.js | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -2642,6 +2642,30 @@ Process.prototype.addMarker = function (pos) { L.marker(pos.contents).addTo(window.map); }; +// Nesting reporters that 'doYield' sucks; as a workaround, +// there is a library imported that uses this function. +// TODO: Improve this :) +// +// returns true if there are elements returned by the overpass query +Process.prototype.overpassQuerySucceeds = function (query) { + var url = 'overpass-api.de/api/interpreter?data=[out:json];' + + query; + + var response; + if (!this.httpRequest) { + this.httpRequest = new XMLHttpRequest(); + this.httpRequest.open("GET", 'http://' + url, true); + this.httpRequest.send(null); + } else if (this.httpRequest.readyState === 4) { + response = this.httpRequest.responseText; + this.httpRequest = null; + console.log(response); // DEBUG + return JSON.parse(response).elements.length > 0; + } + this.pushContext('doYield'); + this.pushContext(); +}; + Process.prototype.reportGeocode = function (lon, lat) { var myself = this; @@ -2666,7 +2690,7 @@ Process.prototype.reportGeocode = function (lon, lat) { this.pushContext('doYield'); this.pushContext(); -} +}; Process.prototype.findLocation = function (searchString) { var myself = this; @@ -2693,7 +2717,7 @@ Process.prototype.findLocation = function (searchString) { this.pushContext('doYield'); this.pushContext(); -} +}; // Process Dates and times in Snap // Map block options to built-in functions |
