-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdbQuery.js
40 lines (26 loc) · 1.07 KB
/
dbQuery.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
var fs = require('fs');
var db_file = 'RAINAPP.db'; //pass in databse files
var exist = fs.existsSync(db_file); //check if files exists
var sqlite3 = require('sqlite3').verbose(); //connect to database
var db = new sqlite3.Database('RAINAPP.db');
console.log('Connecting to Database');
var well_cordinates = [];
//function getData( Query , callback){
function getWellLocations(well_cordinates){
db.each("SELECT * FROM Well_Locations WHERE ID LIKE 'V%' ", function(err, row) {
//console.log(row);
if(err) console.log(err);
well_cordintes.push(parseLatLong(row));
});
return well_cordintes;
}
function parseLatLong(row){
//console.log(myData);
var latitude = Number(row.LAT_DEGREE) + Number(row.LAT_MINUTE)/60 + Number(row.LAT_SECOND)/3600;
//console.log("Latitude: " + latitude);
var longitude = Number(row.LNG_DEGREE) + Number(row.LNG_MINUTE)/60 + Number(row.LNG_SECOND)/3600;
//console.log("longitude: " + longitude);
var latLng = {'WellId':row.ID, 'Latitude': latitude, 'Longitude': longitude }
console.log(latLng);
return {latLng};
}