[gnome-maps/wip/osm-edit: 5/47] osmApi: Call the shim routine to parse OSM node objects



commit ab3d1c6d0a0d5b34857e64c475e8805b3acce53a
Author: Marcus Lundblad <ml update uu se>
Date:   Sun Jan 25 17:16:17 2015 +0100

    osmApi: Call the shim routine to parse OSM node objects
    
    The callback currently handling this still just prints the data.

 src/osmConnection.js |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/osmConnection.js b/src/osmConnection.js
index 6eadd6d..04d01e3 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -21,6 +21,7 @@
  */
 
 const Lang = imports.lang;
+const Maps = imports.gi.GnomeMaps;
 const Soup = imports.gi.Soup;
 
 const BASE_URL = 'http://api.openstreetmap.org/api';
@@ -31,6 +32,7 @@ const OSMConnection = new Lang.Class({
 
     _init: function(params) {
        this._session = new Soup.Session();
+       Maps.osm_init();
     },
 
     getOSMObject: function(type, id, callback) {
@@ -44,10 +46,24 @@ const OSMConnection = new Lang.Class({
                 callback(false, message.status_code, null);
                 return;
             }
+
+           let json;
+
+           print ('Parsing object of type: ' + type);
+           
+           switch (type) {
+           case 'node':
+               json = Maps.osm_parse_node(message.response_body.data,
+                                          message.response_body.length);
+               break;
+           default:
+               // TODO: implement parse methods for the other types as well...
+               json = message.response_body.data;
+           }
            
             callback(true,
                      message.status_code,
-                    message.response_body.data);
+                    json);
         }));
     },
     


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