-
Notifications
You must be signed in to change notification settings - Fork 0
/
geolocator-test.js
executable file
·51 lines (41 loc) · 1.25 KB
/
geolocator-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
/*
* Copyright Intel 2013 Michael Wood <michael.g.wood@intel.com>
*/
/* Requires sqlite3 ( npm install sqlite3 ) */
"use strict";
var geolocator = require (__dirname + '/geolocator.js');
var response = new Object ();
/* stubs for simulating http library */
response.end = function () { console.log ("end"); }
response.write = function (string) {console.log (string); }
function successCallback (queryData, loc) {
console.log ("Success callback Got location "+loc)
}
function getGeolocation (queryData, response)
{
var geolocatorData;
geolocatorData = geolocator.newGeolocationData (queryData, successCallback);
geolocator.getGeolocation (geolocatorData, response);
}
function main ()
{
var lat, lng;
geolocator.load ();
var queryData = new Object ();
if ((lat = process.argv[2]) && (lng = process.argv[3])) {
queryData.lat = lat;
queryData.lng = lng;
} else {
console.log ("Usage: geolocator-test.js lat long\nQuerying for \"City of Westminster\" instead (51.507222 -0.1275)");
/* City of Westminster */
queryData.lat = 51.507222;
queryData.lng = -0.1275;
}
getGeolocation (queryData, response);
process.on ('SIGINT', function () {
console.log ("..OK BYE");
process.exit (0);
});
}
main ();