diff --git a/execution.js b/execution.js new file mode 100644 index 0000000..c4d8217 --- /dev/null +++ b/execution.js @@ -0,0 +1,11 @@ +(async () =>{ + console.log( getAllCoordinates('route2')) + + + + +//var polyline = L.polyline(newArray, {color: 'red'}).addTo(map); +//map.fitBounds(polyline.getBounds()); +//connectDB('route2') + +})(); \ No newline at end of file diff --git a/functions.js b/functions.js index 6fbda00..947ff22 100644 --- a/functions.js +++ b/functions.js @@ -23,8 +23,8 @@ initIPFS() 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:12', '49.41166303/8.67652893') + await db.put('2022-07-01T10:49:07', '49.41185089/8.67646861') + await db.put('2022-07-01T10:49:12', '49.41166303/8.67652893') let csv = "./new.csv" const value = db.all //console.log(value) @@ -54,6 +54,37 @@ async function connectDB(dbname){ const route2 = db_route2.all console.log(route2); } +async function getActualCoordinates(){ + + +} +async function getAllCoordinates(dbname){ + + // creater db with name db2 +var db2 = await createDb(dbname) +const all_coordinates = db2.all +// coordinates in this schema 49.123/8.2311 +var coordinates = Object.values(all_coordinates) +// parse to string for split and then split by / +var coordinate_string = coordinates.toString() +var between_string = coordinate_string.split("/") +var final_string = between_string.toString() +//comma string looks now like this : 49.1212,8.1231,49.1231, ... +var comma_string = final_string.split(',') +// create new Array and put string back in to array for using paths/polylines with leafleat +var newArray =[]; +// use for loop for iterating over string and put it in the right order +for (var i = 0; i < comma_string.length; i++) { + + var increment = i+1; + newArray.push([comma_string[i], comma_string[increment]]) + increment = increment+1 + i = i+1 + +} +console.log(newArray); +return newArray; +} diff --git a/index.html b/index.html index 68c744f..baf1e5b 100644 --- a/index.html +++ b/index.html @@ -8,10 +8,46 @@ integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ==" crossorigin=""> +