From 53f4378325f30728cceeae8d149d69a74ca5556e Mon Sep 17 00:00:00 2001 From: Code WvS Date: Sun, 8 Mar 2015 10:09:15 +0100 Subject: make overpass query more usable by returning the list of elements --- objects.js | 8 ++++---- overpass.xml | 2 +- threads.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/objects.js b/objects.js index b351cdd..868dc43 100644 --- a/objects.js +++ b/objects.js @@ -224,10 +224,10 @@ SpriteMorph.prototype.initBlocks = function () { category: 'motion', spec: 'address at longitude: %n latitude: %n' }, - overpassQuerySucceeds: { - type: 'predicate', + overpassQuery: { + type: 'reporter', category: 'sensing', - spec: 'overpass query %s returns elements' + spec: 'overpass query %s' }, focusMap: { type: 'command', @@ -2033,7 +2033,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('overpassQuerySucceeds')); + blocks.push(block('overpassQuery')); // for debugging: /////////////// diff --git a/overpass.xml b/overpass.xml index 753c613..3960a51 100644 --- a/overpass.xml +++ b/overpass.xml @@ -1 +1 @@ -
+
\ No newline at end of file diff --git a/threads.js b/threads.js index 06644f9..f8218c3 100644 --- a/threads.js +++ b/threads.js @@ -2692,8 +2692,8 @@ Process.prototype.focusMap = function (lon, lat, zoom) { // 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) { +// returns elements returned by the overpass query +Process.prototype.overpassQuery = function (query) { var url = 'overpass-api.de/api/interpreter?data=[out:json];' + query; @@ -2706,7 +2706,7 @@ Process.prototype.overpassQuerySucceeds = function (query) { response = this.httpRequest.responseText; this.httpRequest = null; console.log(response); // DEBUG - return JSON.parse(response).elements.length > 0; + return new List(JSON.parse(response).elements); } this.pushContext('doYield'); this.pushContext(); -- cgit v1.3.1