[gnome-maps] overpass: Use the osm-type to look up data



commit d86b27c828fcb851277468a6148b8745776a3985
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Mon Dec 1 05:28:39 2014 -0500

    overpass: Use the osm-type to look up data
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740937

 src/overpass.js |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/src/overpass.js b/src/overpass.js
index 9864613..1858f29 100644
--- a/src/overpass.js
+++ b/src/overpass.js
@@ -63,7 +63,7 @@ const Overpass = new Lang.Class({
     },
 
     addInfo: function(place, callback) {
-        let url = this._getQueryUrl(place.osm_id);
+        let url = this._getQueryUrl(place);
         let uri = new Soup.URI(url);
         let request = new Soup.Message({ method: 'GET',
                                          uri: uri });
@@ -105,17 +105,17 @@ const Overpass = new Lang.Class({
         return newPlace;
     },
 
-    _getQueryUrl: function(osmId) {
+    _getQueryUrl: function(place) {
         return Format.vprintf('%s?data=%s', [ BASE_URL,
-                                              this._generateOverpassQuery(osmId) ]);
+                                              this._generateOverpassQuery(place) ]);
     },
 
-    _generateOverpassQuery: function(osmId) {
+    _generateOverpassQuery: function(place) {
         return Format.vprintf('%s%s%s;%s;%s;',
                               [ this._getKeyValue('timeout', this.timeout),
                                 this._getKeyValue('out', this.outputFormat),
                                 this._getKeyValue('maxsize', this.maxsize),
-                                this._getData(osmId),
+                                this._getData(place),
                                 this._getOutput() ]);
     },
 
@@ -124,8 +124,18 @@ const Overpass = new Lang.Class({
                                            value ]);
     },
 
-    _getData: function(osmId) {
-        return Format.vprintf('node(%s)', [osmId]);
+    _osmTypeString: function(osmType) {
+        switch(osmType) {
+            case Geocode.PlaceOsmType.NODE: return 'node';
+            case Geocode.PlaceOsmType.RELATION: return 'relation';
+            case Geocode.PlaceOsmType.WAY: return 'way';
+            default: return 'node';
+        }
+    },
+
+    _getData: function(place) {
+        return Format.vprintf('%s(%s)', [this._osmTypeString(place.osm_type),
+                                         place.osm_id]);
     },
 
     _getOutput: function() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]