add utc time in gpx
This commit is contained in:
parent
b3730fb4ec
commit
afa7a9de53
|
@ -28,6 +28,8 @@ let folders_list_txt: any = [
|
||||||
// "7330041",
|
// "7330041",
|
||||||
// "7330057"
|
// "7330057"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
let enable_write_gpx_file = true;
|
||||||
let folder = "/home/poule/encrypted/stockage-syncable/photos/imagerie kartaview carto tel/kartaview_export_storage/share2tykayn/"
|
let folder = "/home/poule/encrypted/stockage-syncable/photos/imagerie kartaview carto tel/kartaview_export_storage/share2tykayn/"
|
||||||
let dossier_gpx: string = "./output_gpx"
|
let dossier_gpx: string = "./output_gpx"
|
||||||
let file_gpx: string = "3596249_d875a_60a0f9bf38f99.txt"
|
let file_gpx: string = "3596249_d875a_60a0f9bf38f99.txt"
|
||||||
|
@ -66,9 +68,16 @@ function makeGpxFromKartaview(tableKartaviewTrace: any) {
|
||||||
|
|
||||||
console.log('make gpx')
|
console.log('make gpx')
|
||||||
let track_points: string = '';
|
let track_points: string = '';
|
||||||
// TODO build track points
|
|
||||||
tableKartaviewTrace.forEach((elem: any) => {
|
tableKartaviewTrace.forEach((elem: any) => {
|
||||||
|
console.log('elem', elem)
|
||||||
|
console.log('elem', elem[6] *1000)
|
||||||
|
let utc_time = new Date(elem[6] *1000)
|
||||||
|
|
||||||
|
console.log('utc_time', utc_time.toISOString())
|
||||||
track_points = `${track_points}<trkpt lat="${elem[0]}" lon="${elem[1]}">
|
track_points = `${track_points}<trkpt lat="${elem[0]}" lon="${elem[1]}">
|
||||||
|
<ele>${elem[2]}</ele>
|
||||||
|
<time>${utc_time.toISOString()}</time>
|
||||||
</trkpt>
|
</trkpt>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
@ -120,17 +129,25 @@ function openKartaviewTxtGPX(filepath
|
||||||
if (elem.indexOf(":g:") > -1) {
|
if (elem.indexOf(":g:") > -1) {
|
||||||
// do stuff on gpxData to enrich it
|
// do stuff on gpxData to enrich it
|
||||||
let boom = elem.split(':')
|
let boom = elem.split(':')
|
||||||
|
let timestamp = boom[0]
|
||||||
|
|
||||||
let gpsmodel = boom[2]
|
let gpsmodel = boom[2]
|
||||||
let gps = gpsmodel.split(';')
|
let gps = gpsmodel.split(';')
|
||||||
|
gps.push(timestamp)
|
||||||
tableKartaviewTrace.push(gps)
|
tableKartaviewTrace.push(gps)
|
||||||
let date = new Date(boom[0] * 1000)
|
let date = new Date(boom[0] * 1000)
|
||||||
// console.log('*', date, gps[0], gps[1])
|
// console.log('*', date, gps[0], gps[1])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
gpxData[fileName] = [...tableKartaviewTrace]
|
gpxData[fileName] = [...tableKartaviewTrace]
|
||||||
|
console.log('gpxData', gpxData)
|
||||||
let content_gpx = makeGpxFromKartaview(tableKartaviewTrace)
|
let content_gpx = makeGpxFromKartaview(tableKartaviewTrace)
|
||||||
|
|
||||||
writeFile('' + fileName + '_trace.gpx', content_gpx)
|
|
||||||
|
if (enable_write_gpx_file) {
|
||||||
|
|
||||||
|
writeFile('' + fileName + '_trace.gpx', content_gpx)
|
||||||
|
}
|
||||||
// console.log('gpx_content', gpx_content)
|
// console.log('gpx_content', gpx_content)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -189,16 +206,23 @@ function writeFile(fileName: string, fileContent: any) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function listPhotos(sequence_number: string){
|
function listPhotos(sequence_number: string) {
|
||||||
getAllFilesInFolder(dossier_photo + '/' + sequence_number)
|
let photo_folder = dossier_photo + '/' + sequence_number;
|
||||||
|
|
||||||
|
let gps_points = gpxData[sequence_number]
|
||||||
|
console.log('gps_points', gps_points)
|
||||||
|
// pour réconcilier les données, on divise la trace en part égales du nombre de photos présentes dans la séquence.
|
||||||
|
|
||||||
|
getAllFilesInFolder(photo_folder)
|
||||||
.then(listOfFiles => {
|
.then(listOfFiles => {
|
||||||
|
|
||||||
console.log('listOfFiles', listOfFiles)
|
console.log('listOfFiles', listOfFiles)
|
||||||
|
|
||||||
|
// open exif data and get the creation date.
|
||||||
|
|
||||||
// look for photos with corresponding timestamps in gpxData
|
// look for photos with corresponding timestamps in gpxData
|
||||||
// add gps exif data to matching photos
|
// add gps exif data to matching photos
|
||||||
|
|
||||||
|
|
||||||
// let listOfFiles: any = getAllFilesInFolder(dossier_photo + '/' + sequence_number)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,16 +231,18 @@ async function getGPXAndEnrichExifOfPhotosInFolder(sequence_number: string) {
|
||||||
// get metadata txt file in metadata folder
|
// get metadata txt file in metadata folder
|
||||||
getAllFilesInFolder(dossier_gpx_input + '/' + sequence_number)
|
getAllFilesInFolder(dossier_gpx_input + '/' + sequence_number)
|
||||||
.then(listOfFiles => {
|
.then(listOfFiles => {
|
||||||
// let listOfFiles: any = getAllFilesInFolder(dossier_gpx_input+ '/' + sequence_number )
|
|
||||||
console.log('listOfFiles', listOfFiles)
|
console.log('listOfFiles', listOfFiles)
|
||||||
listOfFiles?.forEach((file: string) => {
|
listOfFiles?.forEach((file: string) => {
|
||||||
openKartaviewTxtGPX(dossier_gpx_input + '/' + sequence_number + '/' + file)
|
openKartaviewTxtGPX(dossier_gpx_input + '/' + sequence_number + '/' + file)
|
||||||
|
|
||||||
})
|
})
|
||||||
}, err => {
|
}, err => {
|
||||||
throw new Error(err)
|
throw new Error(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('gpxData', gpxData)
|
listPhotos(sequence_number)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('dossiers à traiter: ', folders_list_txt.length)
|
console.log('dossiers à traiter: ', folders_list_txt.length)
|
||||||
|
|
Loading…
Reference in New Issue