gps-simulator
v1.1.1
Published
A js lib to simulate GPS location of a movable object (bus, car, etc).
Downloads
21
Readme
GPS Simulator
Install
npm install gps-simulator
Usage
var gps = require('gps-simulator/gps-simulator.js');
var gpsData = require('gps-simulator/gps-simulator-data.js');
// There are 4 routes in gpsData, named routes01 -> routes04
// Each route, there are 2 directions: AB and BA
// So to get one route data, just use: gpsData.routes01.AB, for example.
var busId = 'Bus 01';
var gpsSimulator = new gps.GpsSimulator(gpsData.routes01.AB, busId);
gpsSimulator.start(function(position, beStopped, movableObject, currentRouteIndex) {
var str = "Route " + currentRouteIndex + ", speed " + movableObject.velocity * 3.6 + " km/h";
console.log('[ ' + new Date() + ' ] ' + str);
var gps_sensor = {
"device_id" : busId,
"timestamp" : new Date(),
"latitude" : position.latitude,
"longitude" : position.longitude
};
// Do something you want with gps_sensor
if (beStopped == true) {
console.log(busId + ' has been stopped');
console.log('======================================');
}
});