From 3d2cb29dd31df45c5c892f637a31a53fc15e7d03 Mon Sep 17 00:00:00 2001 From: DTux Date: Sat, 25 Apr 2020 11:42:50 +0000 Subject: [PATCH] first commit --- jpg2gpx.kdev4 | 3 + jpg2gpx.php | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 jpg2gpx.kdev4 create mode 100644 jpg2gpx.php diff --git a/jpg2gpx.kdev4 b/jpg2gpx.kdev4 new file mode 100644 index 0000000..fec9593 --- /dev/null +++ b/jpg2gpx.kdev4 @@ -0,0 +1,3 @@ +[Project] +Name=jpg2gpx +Manager=KDevGenericManager diff --git a/jpg2gpx.php b/jpg2gpx.php new file mode 100644 index 0000000..91fa11d --- /dev/null +++ b/jpg2gpx.php @@ -0,0 +1,203 @@ +getTimestamp()); + //echo $date . EOL; + if ( ! empty($datas["DateTime"]) ) + { + $datetime_local = date_create_from_format("Y:m:d H:i:s", $datas["DateTime"]); + }elseif ( ! empty($datas["DateTimeOriginal"]) ) + { + $datetime_local = date_create_from_format("Y:m:d H:i:s", $datas["DateTimeOriginal"]); + }else + { + $flag = true; + } + if ( $flag = false ) + { + $list[$x]["datetimelocal"] = date( "c", $datetime_local->getTimestamp()); + $dh = $datetime->diff( $datetime_local ); + $decalagehoraire = $dh->h; + + if ( $dh->i >55) + { + $decalagehoraire += 1; + } + if ( $decalagehoraire >=0 ) + { + $decalagehoraire = "+" . str_pad(abs($decalagehoraire), 4, "0", STR_PAD_BOTH ); + }else + { + $decalagehoraire = "-" . str_pad(abs($decalagehoraire), 4, "0", STR_PAD_BOTH ); + } + $list[$x]["fuseauhoraire"] = $decalagehoraire; + }else + { + $decalagehoraire = ""; + } + + + $datetime->setTimeZone(new DateTimeZone('Europe/Paris')); + echo $path . EOL; + echo strftime( "le %A %c heure de Paris", $datetime->getTimestamp() ) . EOL; + echo strftime( "le %A %c heure locale", $datetime_local->getTimestamp() ) . EOL; + echo "Fuseau horaire : " . $decalagehoraire .EOL; + echo "Latitude : $latitude $dlatitude\nLongitude : $longitude $dlongitude\nAltitude : $altitude\n"; + //print_r($datas); + + } + } +} + +function convert2decimal( $d, $m, $s) +{ + return transform( $d ) + transform($m)/60 + transform($s)/3600; +} + +function transform($a) +{ + $b = explode( "/", $a); + $r = floatval($b[0]) / floatval($b[1]); + return $r; +} + +function gpstime( $a ) +{ + $h = explode("/", $a[0]); + $m = explode("/", $a[1]); + $s = explode("/", $a[2]); + return str_pad( $h[0], 2 ,"0", STR_PAD_LEFT ) . ":" . str_pad( $m[0], 2 ,"0", STR_PAD_LEFT ) . ":" . str_pad( $s[0], 2 ,"0", STR_PAD_LEFT ); +} + +function exportKML( $list ) +{ + $enteteKML = '' . EOL; + print_r($list); + if ( ! $fh = fopen("export_jpg2gpx_" . date("YmdHis") . ".kml", "w") ) + { + $erreur = error_get_last(); + echo "Erreur fopen ligne " . __LINE__ . " : " . $erreur["message"] . EOL; + exit (1); + } + fwrite( $fh, $enteteKML ); + + foreach ( $list as $ligne ) + { + $text = "" . EOL . "" . basename($ligne["name"]) . "" . EOL . "" . $ligne["name"] . EOL . "Altitude : " . $ligne["altitude"] . EOL . "Heure UTC : " . $ligne["datetimeUTC"] . EOL . "Heure locale :" . $ligne["datetimelocal"] . EOL . "Fuseau horaire : " . $ligne["fuseauhoraire"] . EOL . "Généré automatiquement" .EOL; + $text .= " " . EOL . " " . $ligne["longitude"] . "," . $ligne["latitude"] . "" . EOL . " " . EOL . " " . EOL; + fwrite( $fh, $text ); + } + fwrite( $fh, "" ); +} + +function exportGPX( $list ) +{ + $enteteXML = 'export_jpg2gpx_' . date("YmdHis") . '' . EOL; + + if ( ! $fh = fopen("export_jpg2gpx_" . date("YmdHis") . ".gpx", "w") ) + { + $erreur = error_get_last(); + echo "Erreur fopen ligne " . __LINE__ . " : " . $erreur["message"] . EOL; + exit (1); + } + fwrite( $fh, $enteteXML ); + + foreach ( $list as $ligne ) + { + $text = ''; + $text .= "" . $ligne["altitude"] . ""; + $text .= "" . EOL; + $text .= "" . basename($ligne["name"]) . "" . EOL; + $text .= "Généré automatiquement" . EOL; + $text .= "" . $ligne["name"] . EOL; + if ( ! empty($ligne["datetimelocal"]) ) + { + $text .= " Heure locale :" . $ligne["datetimelocal"]; + } + $text .= "" . EOL; + $text .= "" .EOL; + fwrite( $fh, $text ); + } + fwrite( $fh, "" ); +} + +function remplacevirgule ( $f ) +{ + +}