main kartaview conversion
This commit is contained in:
parent
6a6753d97c
commit
2afaf45d7e
|
@ -4,15 +4,13 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import piexif from 'piexif';
|
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import minimist from 'minimist';
|
import minimist from 'minimist';
|
||||||
import * as Buffer from "buffer";
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const moment = require( "moment");
|
const moment = require("moment");
|
||||||
|
|
||||||
// configs
|
// configs
|
||||||
let sequence_name: string = '3596977'
|
let sequence_name: string = '3596977'
|
||||||
|
@ -48,7 +46,7 @@ let folders_list_txt: any = [
|
||||||
let enable_write_gpx_file = true;
|
let enable_write_gpx_file = true;
|
||||||
let just_one_photo_in_folder = false;
|
let just_one_photo_in_folder = false;
|
||||||
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 folder_photos = folder+"photo"
|
let folder_photos = folder + "photo"
|
||||||
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"
|
||||||
|
|
||||||
|
@ -69,7 +67,6 @@ if (mini_arguments['gpx-input']) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// let dossier_photo: string = folder + "test_photo_apply"
|
// let dossier_photo: string = folder + "test_photo_apply"
|
||||||
let dossier_photo: string = folder_photos
|
let dossier_photo: string = folder_photos
|
||||||
let dossier_gpx_input: string = folder + "metadata_file"
|
let dossier_gpx_input: string = folder + "metadata_file"
|
||||||
|
@ -81,7 +78,7 @@ if (mini_arguments['gpx-input-path']) {
|
||||||
|
|
||||||
|
|
||||||
let gpxData: any = {}
|
let gpxData: any = {}
|
||||||
let exif_commands:any = ['#!/bin/bash' ,'# apply exif data to photos']
|
let exif_commands: any = ['#!/bin/bash', '# apply exif data to photos']
|
||||||
|
|
||||||
|
|
||||||
function makeGpxFromKartaview(tableKartaviewTrace: any) {
|
function makeGpxFromKartaview(tableKartaviewTrace: any) {
|
||||||
|
@ -92,14 +89,18 @@ function makeGpxFromKartaview(tableKartaviewTrace: any) {
|
||||||
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)
|
if (elem.length && elem[6]) {
|
||||||
|
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>
|
||||||
</trkpt>
|
</trkpt>
|
||||||
`
|
`
|
||||||
|
}else{
|
||||||
|
console.log('!!!!!! makeGpxFromKartaview no good element in gpx', elem)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
let content = `<?xml version='1.0' encoding='UTF-8'?>
|
let content = `<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
@ -149,7 +150,7 @@ function reduceGpxPointsToInterval(sequence_name: any) {
|
||||||
let lon = elem[1]
|
let lon = elem[1]
|
||||||
let date = new Date(timestamp)
|
let date = new Date(timestamp)
|
||||||
let date_simezone_indicator = ''; // +2:00
|
let date_simezone_indicator = ''; // +2:00
|
||||||
let iso = moment(date).format('YYYY:MM:DD HH:mm:ss')+date_simezone_indicator
|
let iso = moment(date).format('YYYY:MM:DD HH:mm:ss') + date_simezone_indicator
|
||||||
|
|
||||||
ii = interval * 1
|
ii = interval * 1
|
||||||
|
|
||||||
|
@ -160,10 +161,10 @@ function reduceGpxPointsToInterval(sequence_name: any) {
|
||||||
// set exif data
|
// set exif data
|
||||||
// console.log('file_photo_name to apply exif data', photo_counter, file_photo_name)
|
// console.log('file_photo_name to apply exif data', photo_counter, file_photo_name)
|
||||||
|
|
||||||
|
|
||||||
// -File:ModificationDateTime=="${iso}" \\
|
// -File:ModificationDateTime=="${iso}" \\
|
||||||
// -File:CreateDate="${iso}" \\
|
// -File:CreateDate="${iso}" \\
|
||||||
let exif_command= `\n
|
let exif_command = `\n
|
||||||
exiftool -overwrite_original \\
|
exiftool -overwrite_original \\
|
||||||
-GPSDateTime="${iso}" \\
|
-GPSDateTime="${iso}" \\
|
||||||
-AllDates="${iso}" \\
|
-AllDates="${iso}" \\
|
||||||
|
@ -173,7 +174,7 @@ function reduceGpxPointsToInterval(sequence_name: any) {
|
||||||
-TrackModifyDate=="${iso}" \\
|
-TrackModifyDate=="${iso}" \\
|
||||||
-GPSLongitude="${lon}" \\
|
-GPSLongitude="${lon}" \\
|
||||||
-GPSLatitude="${lat}" \\
|
-GPSLatitude="${lat}" \\
|
||||||
"${dossier_photo+'/'+sequence_name+'/'+file_photo_name}"
|
"${dossier_photo + '/' + sequence_name + '/' + file_photo_name}"
|
||||||
`
|
`
|
||||||
|
|
||||||
// -GPSLongitudeRef="West" \
|
// -GPSLongitudeRef="West" \
|
||||||
|
@ -186,11 +187,11 @@ function reduceGpxPointsToInterval(sequence_name: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
exif_commands.push( `geovisio upload --api-url https://panoramax.openstreetmap.fr "${dossier_photo}/${sequence_name}"`)
|
exif_commands.push(`geovisio upload --api-url https://panoramax.openstreetmap.fr "${dossier_photo}/${sequence_name}"`)
|
||||||
let exif_bash_file = exif_commands.join('\n')
|
let exif_bash_file = exif_commands.join('\n')
|
||||||
|
|
||||||
writeFile(`_exif_commmand_sequence_${sequence_name}.sh`,exif_bash_file)
|
writeFile(`_exif_commmand_sequence_${sequence_name}.sh`, exif_bash_file)
|
||||||
|
|
||||||
console.log('\n ----- apply exif data:', `\n bash ${dossier_gpx}/${exif_bash_file}`)
|
console.log('\n ----- apply exif data:', `\n bash ${dossier_gpx}/${exif_bash_file}`)
|
||||||
|
|
||||||
console.log('\n\nDONE for sequence_name', sequence_name)
|
console.log('\n\nDONE for sequence_name', sequence_name)
|
||||||
|
@ -200,7 +201,7 @@ function openKartaviewTxtGPX(filepath: any, sequence_name: string) {
|
||||||
console.log('openKartaviewTxtGPX filepath', filepath)
|
console.log('openKartaviewTxtGPX filepath', filepath)
|
||||||
let boom = filepath.split('/')
|
let boom = filepath.split('/')
|
||||||
let fileName = boom[boom.length - 1]
|
let fileName = boom[boom.length - 1]
|
||||||
console.log('openKartaviewTxtGPX fileName', fileName, )
|
console.log('openKartaviewTxtGPX fileName', fileName,)
|
||||||
fs.readFile(filepath, 'utf8', (err, data) => {
|
fs.readFile(filepath, 'utf8', (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -229,7 +230,7 @@ function openKartaviewTxtGPX(filepath: any, sequence_name: string) {
|
||||||
gpxData[sequence_name] = [...tableKartaviewTrace]
|
gpxData[sequence_name] = [...tableKartaviewTrace]
|
||||||
|
|
||||||
|
|
||||||
// console.log('gpxData', gpxData)
|
console.log(' makeGpxFromKartaview for sequence ', sequence_name)
|
||||||
let content_gpx = makeGpxFromKartaview(tableKartaviewTrace)
|
let content_gpx = makeGpxFromKartaview(tableKartaviewTrace)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue