server/adapters/HttpAjax-adapter.js
function(dbresult) {
        // start with response header
        var jsonresponse= // validate syntaxe at http://geojsonlint.com/
          {"type":"GeometryCollection"
          ,"device":
            {"type":"Device"
            ,"class":device.class
            ,"model": device.model
            ,"call": device.call
          },"properties":
            {"type":"Properties"
            ,'id'  : query.devid
            ,"name": device.name
            ,'url': devurl
            ,'img': device.img
          }
          ,"geometries":[]             
          };       
     
        for (var idx in dbresult) {
            var pos = dbresult [idx];
            var ptsinfo=util.format ("%s<br>Position:[%s,%s] Speed:%s",pos.date,pos.lon.toFixed(4),pos.lat.toFixed(4),pos.sog.toFixed(1));
            jsonresponse.geometries.push (
                   {'type':'Point'
                    ,'coordinates' :[pos.lon, pos.lat]
                    ,'sog' : pos.sog
                    ,'cog' : pos.cog
                    ,'date' : pos.date.getTime()
                    ,'properties'  :
                        {'type':'Properties'
                        ,"title": ptsinfo 
                    }});
           };
    if (query.jsoncallback === undefined) {
        response.writeHead(200,{"Content-Type": "application/json"});  
        response.write(JSON.stringify(jsonresponse));
    } else {
        response.writeHead(200,{"Content-Type": "text/javascript",'Cache-Control':'no-cache'});  
        var fakescript=query.jsoncallback +'(' + JSON.stringify(jsonresponse) +');';
        response.write (fakescript);
    }      
    response.end(); 
    }
function(dbresult) {
        // start with response header
        var jsonresponse= // validate syntaxe at http://geojsonlint.com/
          {"type":"GeometryCollection"
          ,"device":
            {"type":"Device"
            ,"class":device.class
            ,"model": device.model
            ,"call": device.call
          },"properties":
            {"type":"Properties"
            ,'id'  : query.devid
            ,"name": device.name
            ,'url': devurl
            ,'img': device.img
          }
          ,"geometries":[]             
          };       
     
        for (var idx in dbresult) {
            var pos = dbresult [idx];
            var ptsinfo=util.format ("%s<br>Position:[%s,%s] Speed:%s",pos.date,pos.lon.toFixed(4),pos.lat.toFixed(4),pos.sog.toFixed(1));
            jsonresponse.geometries.push (
                   {'type':'Point'
                    ,'coordinates' :[pos.lon, pos.lat]
                    ,'sog' : pos.sog
                    ,'cog' : pos.cog
                    ,'date' : pos.date.getTime()
                    ,'properties'  :
                        {'type':'Properties'
                        ,"title": ptsinfo 
                    }});
           };
    if (query.jsoncallback === undefined) {
        response.writeHead(200,{"Content-Type": "application/json"});  
        response.write(JSON.stringify(jsonresponse));
    } else {
        response.writeHead(200,{"Content-Type": "text/javascript",'Cache-Control':'no-cache'});  
        var fakescript=query.jsoncallback +'(' + JSON.stringify(jsonresponse) +');';
        response.write (fakescript);
    }      
    response.end(); 
    }
function ( dbresult ) { // start with response header var jsonresponse = // validate syntaxe at http://geojsonlint.com/ { "type" : "GeometryCollection" , "device" : { "type" : "Device" , "class" : device . class , "model" : device . model , "call" : device . call } , "properties" : { "type" : "Properties" , 'id' : query . devid , "name" : device . name , 'url' : devurl , 'img' : device . img } , "geometries" : [ ] } ; for ( var idx in dbresult ) { var pos = dbresult [ idx ] ; var ptsinfo = util . format ( "%s<br>Position:[%s,%s] Speed:%s" , pos . date , pos . lon . toFixed ( 4 ) , pos . lat . toFixed ( 4 ) , pos . sog . toFixed ( 1 ) ) ; jsonresponse . geometries . push ( { 'type' : 'Point' , 'coordinates' : [ pos . lon , pos . lat ] , 'sog' : pos . sog , 'cog' : pos . cog , 'date' : pos . date . getTime ( ) , 'properties' : { 'type' : 'Properties' , "title" : ptsinfo } } ) ; } ; if ( query . jsoncallback === undefined ) { response . writeHead ( 200 , { "Content-Type" : "application/json" } ) ; response . write ( JSON . stringify ( jsonresponse ) ) ; } else { response . writeHead ( 200 , { "Content-Type" : "text/javascript" , 'Cache-Control' : 'no-cache' } ) ; var fakescript = query . jsoncallback + '(' + JSON . stringify ( jsonresponse ) + ');' ; response . write ( fakescript ) ; } response . end ( ) ; }
DB callback return a json object with device name and possition
DB callback return a json object with device name and possition