From 46206f4401b6c9e30fbc515165261ad23cb18a60 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 14 Aug 2023 16:25:24 +0200 Subject: [PATCH] guess interval for gps trace for photos in sequence folder --- kartaview_exif_mapper/README.md | 9 ++++ kartaview_exif_mapper/main.ts | 77 ++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 20 deletions(-) diff --git a/kartaview_exif_mapper/README.md b/kartaview_exif_mapper/README.md index 9dc64e9e..2be1af98 100644 --- a/kartaview_exif_mapper/README.md +++ b/kartaview_exif_mapper/README.md @@ -15,6 +15,15 @@ ts-node main.ts --folder=/folder/path 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. +## 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 prendre dans la section body, l'info géographique g, colonne 3 et 4 pour latitude, longitude. diff --git a/kartaview_exif_mapper/main.ts b/kartaview_exif_mapper/main.ts index 40ad0496..cef8d2f1 100644 --- a/kartaview_exif_mapper/main.ts +++ b/kartaview_exif_mapper/main.ts @@ -22,7 +22,7 @@ let folders_list_txt: any = [ // "6102537", "6102569", "6127433", "6133465", "6242729", "6329129", "6329177", "6329241", "6329305", "6329321", "6738633", "6738809", "6738953", "6752761", // "6752889", // "6752905", - // "6752921", + "6752921", "6752937", // "6752953", "6760985", "6761049", "6761289", "6794633", "7325929", "7326457", "7328265", "7330009", "7330025", // "7330041", @@ -70,11 +70,11 @@ function makeGpxFromKartaview(tableKartaviewTrace: any) { let track_points: string = ''; tableKartaviewTrace.forEach((elem: any) => { - console.log('elem', elem) - console.log('elem', elem[6] *1000) - let utc_time = new Date(elem[6] *1000) + // 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()) + // console.log('utc_time', utc_time.toISOString()) track_points = `${track_points} ${elem[2]} @@ -107,9 +107,27 @@ function makeGpxFromKartaview(tableKartaviewTrace: any) { return content; } +function reduceGpxPointsToInterval(sequence_name: any) { -function openKartaviewTxtGPX(filepath - : any) { + let photos_count_in_sequence = photo_folders_counter[sequence_name].length + 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) let boom = filepath.split('/') let fileName = boom[boom.length - 1] @@ -135,12 +153,14 @@ function openKartaviewTxtGPX(filepath let gps = gpsmodel.split(';') gps.push(timestamp) tableKartaviewTrace.push(gps) - let date = new Date(boom[0] * 1000) + // let date = new Date(boom[0] * 1000) // console.log('*', date, gps[0], gps[1]) } }) - gpxData[fileName] = [...tableKartaviewTrace] - console.log('gpxData', gpxData) + gpxData[sequence_name] = [...tableKartaviewTrace] + + + // console.log('gpxData', gpxData) let content_gpx = makeGpxFromKartaview(tableKartaviewTrace) @@ -148,6 +168,9 @@ function openKartaviewTxtGPX(filepath writeFile('' + fileName + '_trace.gpx', content_gpx) } + if(Object.keys(gpxData).length === folders_list_txt.length){ + gather() + } // 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) { let photo_folder = dossier_photo + '/' + 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. getAllFilesInFolder(photo_folder) .then(listOfFiles => { - console.log('listOfFiles', listOfFiles) - - // open exif data and get the creation date. - - // look for photos with corresponding timestamps in gpxData - // add gps exif data to matching photos + // console.log('listOfFiles', listOfFiles) + photo_folders_counter[sequence_number] = listOfFiles }) } @@ -234,7 +255,7 @@ async function getGPXAndEnrichExifOfPhotosInFolder(sequence_number: string) { console.log('listOfFiles', listOfFiles) listOfFiles?.forEach((file: string) => { - openKartaviewTxtGPX(dossier_gpx_input + '/' + sequence_number + '/' + file) + openKartaviewTxtGPX(dossier_gpx_input + '/' + sequence_number + '/' + file, sequence_number) }) }, err => { @@ -243,11 +264,27 @@ async function getGPXAndEnrichExifOfPhotosInFolder(sequence_number: string) { listPhotos(sequence_number) + } console.log('dossiers à traiter: ', folders_list_txt.length) 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) + + }) + +}