guess interval for gps trace for photos in sequence folder

This commit is contained in:
Tykayn 2023-08-14 16:25:24 +02:00 committed by tykayn
parent afa7a9de53
commit 46206f4401
2 changed files with 66 additions and 20 deletions

View File

@ -15,6 +15,15 @@ ts-node main.ts --folder=/folder/path
Cela va convertir en trace GPX les fichiers de métadonnées kartaview Cela va convertir en trace GPX les fichiers de métadonnées kartaview
retrouver le dossier et les photos correspondantes, et appliquer les informations exif de positionnement gps aux photos afin de les envoyer sur panoramax avec l'outil geovisio_cli. retrouver le dossier et les photos correspondantes, et appliquer les informations exif de positionnement gps aux photos afin de les envoyer sur panoramax avec l'outil geovisio_cli.
## options de CLI
sequence : numéro de séquence, correspond à un dossier photo de l'export
folder : chemin du dossier contenant l'export kartaview
gpx-output : nom de fichier de gpx en sortie de conversion
gpx-input : un chemin de fichier txt de kartaview donnant les informations de positionnements de trace pour une séquence
# trace gpx example # trace gpx example
prendre dans la section body, l'info géographique g, colonne 3 et 4 pour latitude, longitude. prendre dans la section body, l'info géographique g, colonne 3 et 4 pour latitude, longitude.

View File

@ -22,7 +22,7 @@ let folders_list_txt: any = [
// "6102537", "6102569", "6127433", "6133465", "6242729", "6329129", "6329177", "6329241", "6329305", "6329321", "6738633", "6738809", "6738953", "6752761", // "6102537", "6102569", "6127433", "6133465", "6242729", "6329129", "6329177", "6329241", "6329305", "6329321", "6738633", "6738809", "6738953", "6752761",
// "6752889", // "6752889",
// "6752905", // "6752905",
// "6752921", "6752921",
"6752937", "6752937",
// "6752953", "6760985", "6761049", "6761289", "6794633", "7325929", "7326457", "7328265", "7330009", "7330025", // "6752953", "6760985", "6761049", "6761289", "6794633", "7325929", "7326457", "7328265", "7330009", "7330025",
// "7330041", // "7330041",
@ -70,11 +70,11 @@ function makeGpxFromKartaview(tableKartaviewTrace: any) {
let track_points: string = ''; let track_points: string = '';
tableKartaviewTrace.forEach((elem: any) => { tableKartaviewTrace.forEach((elem: any) => {
console.log('elem', elem) // console.log('elem', elem)
console.log('elem', elem[6] *1000) // console.log('elem', elem[6] *1000)
let utc_time = new Date(elem[6] *1000) let utc_time = new Date(elem[6] * 1000)
console.log('utc_time', utc_time.toISOString()) // 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> <ele>${elem[2]}</ele>
<time>${utc_time.toISOString()}</time> <time>${utc_time.toISOString()}</time>
@ -107,9 +107,27 @@ function makeGpxFromKartaview(tableKartaviewTrace: any) {
return content; return content;
} }
function reduceGpxPointsToInterval(sequence_name: any) {
function openKartaviewTxtGPX(filepath let photos_count_in_sequence = photo_folders_counter[sequence_name].length
: any) { let interval = Math.round(gpxData[sequence_name].length / photos_count_in_sequence)
let ii = 1;
console.log('--------- sequence_name', sequence_name)
console.log('--------- interval', interval)
// tableKartaviewTrace.forEach((elem: any) => {
// // only work on an interval of files to assign gps coordinates
// ii--
// if(ii<=0){
// // set the gps coordinates to the picture in sequence
// let timestamp = elem[6] * 1000
// let date = new Date(timestamp)
// ii =interval*1
// }
//
// })
}
function openKartaviewTxtGPX(filepath: any, sequence_name: string) {
console.log('filepath', filepath) console.log('filepath', filepath)
let boom = filepath.split('/') let boom = filepath.split('/')
let fileName = boom[boom.length - 1] let fileName = boom[boom.length - 1]
@ -135,12 +153,14 @@ function openKartaviewTxtGPX(filepath
let gps = gpsmodel.split(';') let gps = gpsmodel.split(';')
gps.push(timestamp) 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[sequence_name] = [...tableKartaviewTrace]
console.log('gpxData', gpxData)
// console.log('gpxData', gpxData)
let content_gpx = makeGpxFromKartaview(tableKartaviewTrace) let content_gpx = makeGpxFromKartaview(tableKartaviewTrace)
@ -148,6 +168,9 @@ function openKartaviewTxtGPX(filepath
writeFile('' + fileName + '_trace.gpx', content_gpx) writeFile('' + fileName + '_trace.gpx', content_gpx)
} }
if(Object.keys(gpxData).length === folders_list_txt.length){
gather()
}
// console.log('gpx_content', gpx_content) // console.log('gpx_content', gpx_content)
}) })
} }
@ -206,22 +229,20 @@ function writeFile(fileName: string, fileContent: any) {
) )
} }
let photo_folders_counter: any = {}
function listPhotos(sequence_number: string) { function listPhotos(sequence_number: string) {
let photo_folder = dossier_photo + '/' + sequence_number; let photo_folder = dossier_photo + '/' + sequence_number;
let gps_points = gpxData[sequence_number] let gps_points = gpxData[sequence_number]
console.log('gps_points', gps_points) // 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. // 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) getAllFilesInFolder(photo_folder)
.then(listOfFiles => { .then(listOfFiles => {
console.log('listOfFiles', listOfFiles) // console.log('listOfFiles', listOfFiles)
photo_folders_counter[sequence_number] = listOfFiles
// open exif data and get the creation date.
// look for photos with corresponding timestamps in gpxData
// add gps exif data to matching photos
}) })
} }
@ -234,7 +255,7 @@ async function getGPXAndEnrichExifOfPhotosInFolder(sequence_number: string) {
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, sequence_number)
}) })
}, err => { }, err => {
@ -243,11 +264,27 @@ async function getGPXAndEnrichExifOfPhotosInFolder(sequence_number: string) {
listPhotos(sequence_number) listPhotos(sequence_number)
} }
console.log('dossiers à traiter: ', folders_list_txt.length) console.log('dossiers à traiter: ', folders_list_txt.length)
folders_list_txt.forEach((elem: string) => { folders_list_txt.forEach((elem: string) => {
getGPXAndEnrichExifOfPhotosInFolder(elem) getGPXAndEnrichExifOfPhotosInFolder(elem).then(r => {
console.log('r', r)
}
)
}) })
function gather() {
// console.log('gpxData', gpxData)
console.log('sequences', folders_list_txt)
folders_list_txt.forEach((sequence: string) => {
reduceGpxPointsToInterval(sequence)
})
}