From 8426b17cca2e56ad48fdf457a3596e9f884805d6 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sun, 13 Aug 2023 23:12:01 +0200 Subject: [PATCH] kartaview converter to gpx trace --- kartaview_exif_mapper/README.md | 55 ++++++++++++++ kartaview_exif_mapper/essai-josm.gpx | 64 +++++++++++++++++ kartaview_exif_mapper/main.ts | 104 +++++++++++++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 kartaview_exif_mapper/README.md create mode 100644 kartaview_exif_mapper/essai-josm.gpx create mode 100644 kartaview_exif_mapper/main.ts diff --git a/kartaview_exif_mapper/README.md b/kartaview_exif_mapper/README.md new file mode 100644 index 00000000..b2d1ff5a --- /dev/null +++ b/kartaview_exif_mapper/README.md @@ -0,0 +1,55 @@ +# Kartaview exif mapper + +Mapper les données exif des photos exportées de kartaview. + +# mode d'action + +configurer le dossier en argument + +```bash +ts-node main.ts --folder=/folder/path +``` + +# trace gpx example +prendre dans la section body, l'info géographique g, colonne 3 et 4 pour latitude, longitude. + +> METADATA:2.0 + HEADER + ALIAS:d;DEVICE;1;1 + ALIAS:g;GPS;1;1 + ALIAS:o;OBD;1;1 + ALIAS:cam;CAMERA;2;2 + ALIAS:exif;EXIF;2;2 + ALIAS:p;PRESSURE;1;1 + ALIAS:c;COMPASS;1;1 + ALIAS:f;PHOTO;1;1 + ALIAS:a;ACCELERATION;1;1 + ALIAS:y;ATTITUDE;1;1 + ALIAS:x;GRAVITY;1;1 + BODY + 1599225187.923:d:Android;P;9;OnePlus ONEPLUS A5000;3.1.6;3.1.6;photo + 1599225187.958:exif:4.103;3840;2160 + 1599225187.958:cam:64.8699962380788;51.01659133079809;1.7 + 1599225189.000:g:48.61844552;2.12523291;155.55169677734375;3.216;3.216;0.0 +> +> ... +> +> END +# liens entre les fichiers +Les photos exportées de kartaview n'ont pas d'informations GPS. + +kartaview n'a pas documenté ses liens entre fichiers, on devine donc que les dossiers ont un numéro qui relient les infos de séquence dans un fichier texte au format privé .txt avec les photos concernées. + +## Example de nom de dossier +3596249 +## Example de timestamp dans le fichier de métadonnées txt +1599225189.000 +correspond à : +Date Fri Sep 04 2020 15:13:09 GMT+0200 (heure d’été d’Europe centrale) + +``` +let d = new Date(1599225189*1000); +``` +## Example de nom de fichier photo +3596249_f3ccd_60a0f9cda58b5.jpg + diff --git a/kartaview_exif_mapper/essai-josm.gpx b/kartaview_exif_mapper/essai-josm.gpx new file mode 100644 index 00000000..9afcc77b --- /dev/null +++ b/kartaview_exif_mapper/essai-josm.gpx @@ -0,0 +1,64 @@ + + + + tour_paté_de_maison + + georges + + + 2022 + https://creativecommons.org/licenses/by-sa/2.5 + + nada + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kartaview_exif_mapper/main.ts b/kartaview_exif_mapper/main.ts new file mode 100644 index 00000000..1d529dc9 --- /dev/null +++ b/kartaview_exif_mapper/main.ts @@ -0,0 +1,104 @@ +/** + conversion de données gpx + conversion de données exif + **/ +import * as fs from 'node:fs'; + +const dossier_photo: string = "/home/poule/encrypted/stockage-syncable/photos/imagerie kartaview carto tel/kartaview_export_storage/share2tykayn/photo/2785606" +const file_gpx: string = "/home/poule/encrypted/stockage-syncable/photos/imagerie kartaview carto tel/kartaview_export_storage/share2tykayn/metadata_file/3596249/3596249_d875a_60a0f9bf38f99.txt" + +let gpxData: any = {} +let tableKartaviewTrace = [] + +function makeGpxFromKartaview() { + + let track_points; + // TODO build track points + tableKartaviewTrace.forEach((elem: any) => { + track_points = track_points + '\n' + }) + + let content = '\n' + + '\n' + + ' \n' + + ' trace_gpx_de_demo\n' + + ' \n' + + ' somebody\n' + + ' \n' + + ' \n' + + // ' 2022\n' + + ' https://creativecommons.org/licenses/by-sa/2.5\n' + + ' \n' + + ' nada\n' + + // ' \n' + + // ' \n' + + ' \n' + + // ' \n' + + // ' \n' + + ' \n' + + ' \n' + + track_points + + // ' \n' + + ' \n' + + ' \n' + + ' \n' + + '' + + return content; +} + + +function openGPX(filepath: any) { + + fs.readFile(filepath, 'utf8', (err, data) => { + if (err) { + throw err; + } + const gpx_content = data; + let lines = gpx_content.split('\n') + console.log('lines.length', lines.length) + lines.forEach((elem: any) => { + if (elem.indexOf(":g:") > -1) { + let boom = elem.split(':') + let gpsmodel = boom[2] + let gps = gpsmodel.split(';') + tableKartaviewTrace.push(gps) + // console.log('boom', boom) + // console.log('gps', gps) + let date = new Date(boom[0] * 1000) + console.log('*', date, gps[0], gps[1]) + + } + }) + let content_gpx = makeGpxFromKartaview() + + // writeFile('./output.gpx', content_gpx) + // console.log('gpx_content', gpx_content) + }) + // loop on all lines, only take the lines that contain :g: + // do stuff on gpxData to enrich it +} + +function writeFile(name, content) { + console.log('name,content', name, content) + fs.writeFileSync(name,content) +} + +function getAllFilesInFolder(folderPath: any) { + let listOfFiles: any = [] + return listOfFiles +} + +function mapExifDataOnListOfFilesFromGpxData(listOfFiles: any, gpxData: any) { + listOfFiles.forEach((elem: any) => { + // find corresponding timestamp + // add exif info + // save file + }) +} + +openGPX(file_gpx) +let listOfFiles: any = getAllFilesInFolder(dossier_photo) +console.log('listOfFiles', listOfFiles)