cities under the ISS

node v6.17.1
version: master
endpointsharetweet
// get current position of the international space station var request = require('request'); async function currentPosition() { var issurl = 'http://api.open-notify.org/iss-now.json'; var obj = JSON.parse(await require('request-promise')(issurl)).iss_position; obj.latitude = parseFloat(obj.latitude); obj.longitude = parseFloat(obj.longitude); return obj; }; // fetch current position var iss = await currentPosition();
// create Cloudant connection var db = require('silverlining')(process.env.CLOUDANTURL + '/cities'); // get cities 'near' the ISS (sometimes there are none - there's a lot of empty out there) var t = 5; // five degrees of tolerance var cities = await db.query( { 'latitude' : { '$gt': iss.latitude - t, '$lt' : iss.latitude + t }, 'longitude' : { '$gt': iss.longitude - t, '$lt' : iss.longitude + t} } );
Loading…

no comments

    sign in to comment