[Linpha-cvs] SF.net SVN: linpha: [4849] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <bz...@us...> - 2008-02-02 15:05:31
|
Revision: 4849 http://linpha.svn.sourceforge.net/linpha/?rev=4849&view=rev Author: bzrudi Date: 2008-02-02 07:05:22 -0800 (Sat, 02 Feb 2008) Log Message: ----------- minor improvements Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/plugins/maps/xml_parser.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-02-02 13:11:40 UTC (rev 4848) +++ trunk/linpha2/ChangeLog 2008-02-02 15:05:22 UTC (rev 4849) @@ -3,6 +3,7 @@ assign images to closest/nearest trackpoint in GPX file using some offset logic. - add some new methods for this + * Add support for images starting earlier as track 2008-02-01 bzrudi * More improvements to XML parser class. XML/GPX parsing works now, same @@ -10,7 +11,7 @@ well as the image EXIF datetimeoriginal tag from all images in folder. * Add some required new methods to LinMetaData() class * Add new file modules.geodata.php for testing all geodata stuff - * some basic tests work alright now + * Some basic tests work alright now 2008-01-31 bzrudi * Maps plugin Modified: trunk/linpha2/lib/plugins/maps/xml_parser.class.php =================================================================== --- trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-02 13:11:40 UTC (rev 4848) +++ trunk/linpha2/lib/plugins/maps/xml_parser.class.php 2008-02-02 15:05:22 UTC (rev 4849) @@ -294,7 +294,58 @@ if($images['starttime'] < $track['starttime']) { echo "Offset detected, images start earlier...<br>"; - print_r($images['geodata']); + + $number = count($images['geodata']); + + while(list($image_time, $filename) = each($images['geodata'])) + { + if($image_time < $track['starttime']) + { + $no_offsync++; + $files_offsync[] = $filename; + } + } + echo "$no_offsync "."out of ".$number ." images are out of sync...<br>"; + echo "We have an offset of ".($track['starttime']-$images['starttime'])." " . + "seconds, which is about ".(($track['starttime']-$images['starttime'])/3600)." hours"; + echo "<br>Calibrating...<br>"; + + if($no_offsync > '0') + { + $full_hour = round(($track['starttime']-$images['starttime'])/3600, '0'); + + if($full_hour != '0') + { + echo "Usually offset is because of wrong UTC/GMT settings, so " . + "trying full hours first<br>"; + echo "Setting full hour offset to ".$full_hour." h<br>"; + echo "Faking image times... new setting +$full_hour h<br>"; + + $offset = ($full_hour*3600); + + } + else + { + echo "Danm, looks like we have an time skew < 1h - not so good<br>"; + echo "Setting offset to 5 min...<br>"; + echo "Faking image times... new setting -5 min<br>"; + + $offset = '300'; + } + + foreach($images['geodata'] AS $image_time => $filename) + { + $geo_tmp[($image_time + $offset)] = $filename; + } + + $image_tmp = array("starttime" => ($images['starttime'] + $offset), + "endtime" => ($images['endtime'] + $offset), + "geodata" => $geo_tmp ); + + echo "Rerunning offset test...<br>"; + $this->fixImagesOffset($track, $image_tmp); + } + } elseif($images['endtime'] > $track['endtime']) { @@ -398,7 +449,7 @@ while($loop === true) { - $loop = $this->trkptRadar($trkdata, $image_time, $offset); + $loop = $this->trkptRadar($trkdata, $image_time, $offset, $image_filename); $offset++; } } @@ -415,7 +466,7 @@ * @author bzrudi * @return bool */ - private function trkptRadar($trkdata, $image_time, $offset) + private function trkptRadar($trkdata, $image_time, $offset, $image_filename) { if(array_key_exists($image_time, $trkdata)) { @@ -423,6 +474,11 @@ echo "<br>Connecting image ".$image_time." " . "<br>to LAT: ".$trkdata[$image_time]['lat']."<br>and LON: " . "".$trkdata[$image_time]['lon']."<br><br>"; + + $this->writeGpsData2File($image_filename, + $trkdata[$image_time]['lat'], + $trkdata[$image_time]['lon']); + return false; } elseif(array_key_exists(($image_time + $offset), $trkdata)) @@ -431,6 +487,11 @@ echo "<br>Connecting image ".$image_time." " . "<br>to LAT: ".$trkdata[$image_time + $offset]['lat']."<br>and LON: " . "".$trkdata[$image_time + $offset]['lon']."<br><br>"; + + $this->writeGpsData2File($image_filename, + $trkdata[$image_time + $offset]['lat'], + $trkdata[$image_time + $offset]['lon']); + return false; } elseif(array_key_exists(($image_time - $offset), $trkdata)) @@ -439,6 +500,10 @@ echo "<br>Connecting image ".$image_time." " . "<br>to LAT: ".$trkdata[$image_time - $offset]['lat']."<br>and LON: " . "".$trkdata[$image_time - $offset]['lon']."<br><br>"; + $this->writeGpsData2File($image_filename, + $trkdata[$image_time - $offset]['lat'], + $trkdata[$image_time - $offset]['lon']); + return false; } else @@ -448,6 +513,32 @@ } } + + /** + * Write GPS data to file + */ + private function writeGpsData2File($filename, $lat, $lon) + { + echo "Trying to write GPS data to files - ***SIMULATION***<br>"; + echo "Trying file: ".$filename."<br>"; + + ($lon > 0) ? $lonref = "E" : $latref = "W"; + ($lat > 0) ? $latref = "N" : $latref = "S"; + + echo "Latref ".$latref." Longref ".$lonref."<br><br>"; + + + $filename = substr($filename, 2); + $filename = LINPHA_DIR."/$filename"; + $return = ""; + $meta = ""; + $parameters = "-GPSLongitudeRef = ".$lonref." " . + "-GPSLongitude = ".$lon." " . + "-GPSLatitudeRef = ".$latref." " . + "-GPSLatitude = ".$lat." "; + + //LinFilesys::linExec($this->exiftool.' '.$parameters.' "'.$filename.'"', $meta, $return); + } }// end class /* vi: set ts=4 sw=4 sts=4 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |