|
|
@ -10,54 +10,84 @@ |
|
|
|
|
|
|
|
} |
|
|
|
initIPFS() |
|
|
|
async function createDb(){ |
|
|
|
const ipfs = await Ipfs.create({repo: 'ok' + Math.random()}); |
|
|
|
|
|
|
|
|
|
|
|
async function createDb(db_name){ |
|
|
|
// Create database instance
|
|
|
|
const orbitdb = await OrbitDB.createInstance(ipfs) |
|
|
|
//const ipfsOptions = { repo: '/orbitdb/createdb1', }
|
|
|
|
|
|
|
|
const ipfs = await Ipfs.create() |
|
|
|
const orbitdb = await OrbitDB.createInstance(ipfs) |
|
|
|
// Create IPFS instance
|
|
|
|
const db = await orbitdb.keyvalue(db_name) |
|
|
|
const db = await orbitdb.keyvalue('routes') |
|
|
|
const address = db.address |
|
|
|
console.log(address) |
|
|
|
console.log(db.address.toString()) |
|
|
|
await db.put('2022-07-01T10:49:07', '49.41185089/8.67646861') |
|
|
|
await db.put('2022-07-01T10:49:07', '49.41185089/8.67646861',{pin: true}) |
|
|
|
await db.put('2022-07-01T10:49:12', '49.41166303/8.67652893') |
|
|
|
await db.put('2022-07-01T10:49:20','49.41123636/8.67652849') |
|
|
|
await db.put(' 2022-07-01T10:49:25','49.41084041/8.67651128') |
|
|
|
await db.put('2022-07-01T10:49:31','49.41049801/8.67656948') |
|
|
|
await db.put('2022-07-01T10:49:31','49.41049801/8.67656948') |
|
|
|
await db.put('2022-07-01T10:49:38','49.4102198/8.67658131') |
|
|
|
await db.put('2022-07-01T10:49:44','49.40982577/8.67668618') |
|
|
|
await db.put('2022-07-01T10:49:50','49.4095211/8.6767495') |
|
|
|
// await db.put('0000','00/00');
|
|
|
|
await db.put('2022-07-01T10:56:43','49.39117231/8.68814905') |
|
|
|
await db.put('2022-07-01T10:56:50','49.39076199/8.68818273') |
|
|
|
await db.put('2022-07-01T10:56:59','49.39058452/8.68776805') |
|
|
|
await db.put('2022-07-01T10:57:04','49.39048152/8.68746322') |
|
|
|
await db.put('2022-07-01T10:57:10','49.39009475/8.68742468') |
|
|
|
await db.put('2022-07-01T10:57:18','49.38966856/8.68741891') |
|
|
|
await db.put('2022-07-01T10:57:26','49.3896966/8.68683682') |
|
|
|
await db.put('2022-07-01T10:57:34','49.38985798/8.68647962') |
|
|
|
await db.put('2022-07-01T11:00:12','49.38983544/8.68654936') |
|
|
|
await db.put('2022-07-01T11:00:19','49.38982943/8.68686349') |
|
|
|
await db.put('2022-07-01T11:00:24','49.38988557/8.68711804') |
|
|
|
await db.put('2022-07-01T11:00:32','49.38975355/8.68742027') |
|
|
|
await db.put('2022-07-01T11:00:39','49.38968475/8.68789061') |
|
|
|
await db.put('2022-07-01T11:00:47','49.38968741/8.68864464') |
|
|
|
await db.put('2022-07-01T11:00:56','49.38981096/8.68935897') |
|
|
|
await db.put('2022-07-01T11:01:03','49.38991498/8.6898232') |
|
|
|
await db.put('2022-07-01T11:01:13','49.39008687/8.69005123') |
|
|
|
await db.put('2022-07-01T11:01:20','49.39012705/8.69004198') |
|
|
|
await db.put('2022-07-01T11:01:42','49.39012273/8.69044973') |
|
|
|
await db.put('2022-07-01T11:03:13','49.39020013/8.69013153') |
|
|
|
await db.put('2022-07-01T11:03:37','49.3902416/8.69011779') |
|
|
|
await db.put('2022-07-01T11:06:03','49.39010871/8.68987621') |
|
|
|
let csv = "./new.csv" |
|
|
|
const value = db.all |
|
|
|
//console.log(value)
|
|
|
|
console.log('datenbank erstellt danke') |
|
|
|
console.log('database connected!') |
|
|
|
//console.log(value)
|
|
|
|
await db.close() |
|
|
|
return db |
|
|
|
} |
|
|
|
|
|
|
|
async function loadRoute(db_name){ |
|
|
|
const ipfs = await Ipfs.create() |
|
|
|
const orbitdb = await OrbitDB.createInstance(ipfs) |
|
|
|
|
|
|
|
const db = await orbitdb.keyvalue(db_name) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function loadRoute(){ |
|
|
|
const db = await createDb() |
|
|
|
await db.load() |
|
|
|
console.log("loadroute ausgeführt") |
|
|
|
const value = db.all |
|
|
|
console.log(value) |
|
|
|
return value; |
|
|
|
} |
|
|
|
async function connectDB(dbname){ |
|
|
|
const ipfsOptions = { repo: '/orbitdb/los', } |
|
|
|
const ipfs = await Ipfs.create(ipfsOptions) |
|
|
|
async function connectDB(){ |
|
|
|
//const ipfsOptions = { repo: '/orbitdb/los', }
|
|
|
|
//const ipfs = await Ipfs.create(ipfsOptions)
|
|
|
|
const ipfs = await Ipfs.create() |
|
|
|
const orbitdb = await OrbitDB.createInstance(ipfs) |
|
|
|
const db_route2 = await orbitdb.open('/orbitdb/zdpuAoog9p95yvwyGcL3xJsGcdMkxVdEDRwYwba1JrKNEgQod/'+dbname); |
|
|
|
const route2 = db_route2.all |
|
|
|
console.log(route2); |
|
|
|
const db_route2 = await orbitdb.open('/orbitdb/zdpuApZ7pMKupZjmxPQk8xp34QdAEXHFFjmA3EPWuACN88DwB/coordinates'); |
|
|
|
//const route2 = db_route2.all
|
|
|
|
//console.log(OrbitDB.isValidAddress('/orbitdb/zdpuAqETvwNibieag6o5ahX4d6WKXi6QZvbar3XZPJEXz3vSE/coordinates'));
|
|
|
|
console.log(db_route2.all); |
|
|
|
console.log(db_route2.address.toString()) |
|
|
|
return db_route2; |
|
|
|
} |
|
|
|
async function getCurrentCoordinate(){ |
|
|
|
var db_conn = await createDb('coordinates') |
|
|
|
var db_conn = await createDb() |
|
|
|
const currentCoordinate = db_conn.all |
|
|
|
console.log(currentCoordinate) |
|
|
|
var latest_coord_string = (currentCoordinate[Object.keys(currentCoordinate)[Object.keys(currentCoordinate).length - 1]]) |
|
|
@ -69,8 +99,20 @@ async function getCurrentCoordinate(){ |
|
|
|
return latest_coordinate_str; |
|
|
|
} |
|
|
|
|
|
|
|
async function getAllCoordinates(dbname){ |
|
|
|
var db2 = await createDb(dbname) |
|
|
|
async function getCurrentTime(){ |
|
|
|
|
|
|
|
var db_conn = await createDb() |
|
|
|
const currentCoordinate = db_conn.all |
|
|
|
//console.log(currentCoordinate)
|
|
|
|
var all_times = (Object.keys(currentCoordinate)) |
|
|
|
var lasttime = all_times[(all_times.length-1)] |
|
|
|
console.log(lasttime) |
|
|
|
//return lasttime;
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function getAllCoordinates(){ |
|
|
|
var db2 = await createDb() |
|
|
|
const all_coordinates = db2.all |
|
|
|
// coordinates in this schema 49.123/8.2311
|
|
|
|
var coordinates = Object.values(all_coordinates) |
|
|
@ -90,6 +132,7 @@ for (var i = 0; i < comma_string.length; i++) { |
|
|
|
increment = increment+1 |
|
|
|
i = i+1 |
|
|
|
} |
|
|
|
|
|
|
|
(function(elem) { |
|
|
|
var callee = arguments.callee; |
|
|
|
return elem instanceof Array ? elem.map(function(elem2) { return callee(elem2); }) |
|
|
@ -100,9 +143,12 @@ newArray = newArray.map(function(elem) { |
|
|
|
return parseFloat(elem2); |
|
|
|
}); |
|
|
|
}); |
|
|
|
console.log(newArray) |
|
|
|
|
|
|
|
//console.log(newArray)
|
|
|
|
return newArray; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|