kartaview converter to gpx trace
This commit is contained in:
parent
06f5f1bb1b
commit
8426b17cca
55
kartaview_exif_mapper/README.md
Normal file
55
kartaview_exif_mapper/README.md
Normal file
@ -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
|
||||
|
64
kartaview_exif_mapper/essai-josm.gpx
Normal file
64
kartaview_exif_mapper/essai-josm.gpx
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<gpx version="1.1" creator="JOSM GPX export" xmlns="http://www.topografix.com/GPX/1/1"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
|
||||
<metadata>
|
||||
<desc>tour_paté_de_maison</desc>
|
||||
<author>
|
||||
<name>georges</name>
|
||||
</author>
|
||||
<copyright author="georges">
|
||||
<year>2022</year>
|
||||
<license>https://creativecommons.org/licenses/by-sa/2.5</license>
|
||||
</copyright>
|
||||
<keywords>nada</keywords>
|
||||
<time>2022-01-20T21:35:02.039062Z</time>
|
||||
<bounds minlat="48.6835305" minlon="2.1368623" maxlat="48.68647" maxlon="2.1427953"/>
|
||||
</metadata>
|
||||
<wpt lat="48.686470006111435" lon="2.139083136320114">
|
||||
</wpt>
|
||||
<trk>
|
||||
<trkseg>
|
||||
<trkpt lat="48.683587161789646" lon="2.1410250556468964">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68353049489128" lon="2.1399414432048802">
|
||||
</trkpt>
|
||||
<trkpt lat="48.683856328686176" lon="2.139726866483689">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68487631650288" lon="2.1380424392223363">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68545713366763" lon="2.1373772513866425">
|
||||
</trkpt>
|
||||
<trkpt lat="48.685938781845564" lon="2.136862267255783">
|
||||
</trkpt>
|
||||
<trkpt lat="48.686045027147024" lon="2.137495268583298">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68602377810467" lon="2.1382677447795873">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68610877422032" lon="2.13868616938591">
|
||||
</trkpt>
|
||||
<trkpt lat="48.686073359189564" lon="2.1391367805004124">
|
||||
</trkpt>
|
||||
<trkpt lat="48.685896283662224" lon="2.1396732223033905">
|
||||
</trkpt>
|
||||
<trkpt lat="48.685903366695264" lon="2.1403491389751435">
|
||||
</trkpt>
|
||||
<trkpt lat="48.686094608211" lon="2.1413469207286835">
|
||||
</trkpt>
|
||||
<trkpt lat="48.686186687200305" lon="2.1417760741710663">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68610877422032" lon="2.1422696006298065">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68596003092379" lon="2.142795313596726">
|
||||
</trkpt>
|
||||
<trkpt lat="48.684925898717474" lon="2.1413254630565643">
|
||||
</trkpt>
|
||||
<trkpt lat="48.684005078196044" lon="2.142623652219773">
|
||||
</trkpt>
|
||||
<trkpt lat="48.683636745273404" lon="2.1418833625316624">
|
||||
</trkpt>
|
||||
<trkpt lat="48.68359424514746" lon="2.141218174695969">
|
||||
</trkpt>
|
||||
</trkseg>
|
||||
</trk>
|
||||
</gpx>
|
104
kartaview_exif_mapper/main.ts
Normal file
104
kartaview_exif_mapper/main.ts
Normal file
@ -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 + '<trkpt lat="' + elem[1] + '" lon="' + elem[1] + ">\n'
|
||||
})
|
||||
|
||||
let content = '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n' +
|
||||
'<gpx version="1.1" creator="JOSM GPX export" xmlns="http://www.topografix.com/GPX/1/1"\n' +
|
||||
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n' +
|
||||
' xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">\n' +
|
||||
' <metadata>\n' +
|
||||
' <desc>trace_gpx_de_demo</desc>\n' +
|
||||
' <author>\n' +
|
||||
' <name>somebody</name>\n' +
|
||||
' </author>\n' +
|
||||
' <copyright author="somebody">\n' +
|
||||
// ' <year>2022</year>\n' +
|
||||
' <license>https://creativecommons.org/licenses/by-sa/2.5</license>\n' +
|
||||
' </copyright>\n' +
|
||||
' <keywords>nada</keywords>\n' +
|
||||
// ' <time>2022-01-20T21:35:02.039062Z</time>\n' +
|
||||
// ' <bounds minlat="48.6835305" minlon="2.1368623" maxlat="48.68647" maxlon="2.1427953"/>\n' +
|
||||
' </metadata>\n' +
|
||||
// ' <wpt lat="48.686470006111435" lon="2.139083136320114">\n' +
|
||||
// ' </wpt>\n' +
|
||||
' <trk>\n' +
|
||||
' <trkseg>\n' +
|
||||
track_points +
|
||||
// ' <trkpt lat="48.68359424514746" lon="2.141218174695969">\n' +
|
||||
' </trkpt>\n' +
|
||||
' </trkseg>\n' +
|
||||
' </trk>\n' +
|
||||
'</gpx>'
|
||||
|
||||
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)
|
Loading…
Reference in New Issue
Block a user