function serveGPSData(req, res){
    // Get data from the database

    var timeFrom = parseInt(req.params.timeFrom) || 0;
    var timeUntil = parseInt(req.params.timeUntil) || new Date().getTime();

    var query = {
        selector: {
            "$and": [
                {time: {"$gt": timeFrom}},
                {time: {"$lt": timeUntil}}]
        }
    };

    logger.info(JSON.stringify(query));
    cloudant.use(req.params.dronename + '_positionlog').find(query, function(err, result){
        if(err){
            logger.error("[position.request."+ req.params.dronename +"] " + err);
            logger.error(JSON.stringify(query));
            res.status(500).send("Request error. Malformed?");
            return;
        }
        if(result === undefined){
            res.status(204).send("Empty return");
            return;
        }
        result.docs.forEach(function (doc) {
            delete doc._id;
            delete doc._rev;

        });

        var data = JSON.stringify(result.docs);
        res.status(200).send(data);
    });

}
/**
 * Serve GPS data from Cloudant database
 * @param req {Object} The request from the client
 * @param req.params.timeFrom {String} Timestamp in milliseconds since epoch
 * @param req.params.timeTill {String} Timestamp in milliseconds since epoch
 * @param res {Object} The response for the client
 */
Serve GPS data from Cloudant database
@param req {Object} The request from the client
@param req.params.timeFrom {String} Timestamp in milliseconds since epoch
@param req.params.timeTill {String} Timestamp in milliseconds since epoch
@param res {Object} The response for the client
Serve GPS data from Cloudant database @param req { Object } The request from the client @param req . params . timeFrom { String } Timestamp in milliseconds since epoch @param req . params . timeTill { String } Timestamp in milliseconds since epoch @param res { Object } The response for the client
function serveGPSData(req, res){
    var timeFrom = parseInt(req.params.timeFrom) || 0;
    var timeUntil = parseInt(req.params.timeUntil) || new Date().getTime();
    var query = {
        selector: {
            "$and": [
                {time: {"$gt": timeFrom}},
                {time: {"$lt": timeUntil}}]
        }
    };
    logger.info(JSON.stringify(query));
    cloudant.use(req.params.dronename + '_positionlog').find(query, function(err, result){
        if(err){
            logger.error("[position.request."+ req.params.dronename +"] " + err);
            logger.error(JSON.stringify(query));
            res.status(500).send("Request error. Malformed?");
            return;
        }
        if(result === undefined){
            res.status(204).send("Empty return");
            return;
        }
        result.docs.forEach(function (doc) {
            delete doc._id;
            delete doc._rev;
        });
        var data = JSON.stringify(result.docs);
        res.status(200).send(data);
    });
}
function serveGPSData ( req , res ) { var timeFrom = parseInt ( req . params . timeFrom ) || 0 ; var timeUntil = parseInt ( req . params . timeUntil ) || new Date ( ) . getTime ( ) ; var query = { selector : { "$and" : [ { time : { "$gt" : timeFrom } } , { time : { "$lt" : timeUntil } } ] } } ; logger . info ( JSON . stringify ( query ) ) ; cloudant . use ( req . params . dronename + '_positionlog' ) . find ( query , function ( err , result ) { if ( err ) { logger . error ( "[position.request." + req . params . dronename + "] " + err ) ; logger . error ( JSON . stringify ( query ) ) ; res . status ( 500 ) . send ( "Request error. Malformed?" ) ; return ; } if ( result === undefined ) { res . status ( 204 ) . send ( "Empty return" ) ; return ; } result . docs . forEach ( function ( doc ) { delete doc . _id ; delete doc . _rev ; } ) ; var data = JSON . stringify ( result . docs ) ; res . status ( 200 ) . send ( data ) ; } ) ; }
Serve GPS data from Cloudant database
 @param req {Object} The request from the client
 @param req.params.timeFrom {String} Timestamp in milliseconds since epoch
 @param req.params.timeTill {String} Timestamp in milliseconds since epoch
 @param res {Object} The response for the client
Serve GPS data from Cloudant database @param req { Object } The request from the client @param req . params . timeFrom { String } Timestamp in milliseconds since epoch @param req . params . timeTill { String } Timestamp in milliseconds since epoch @param res { Object } The response for the client
// Get data from the database