function computeGeoInfo() { $changed=0; $gotTrack=0; foreach ( $this->photos as $photoNum=>$photoInfo) { if ($photoInfo['tm']==1) { // 1 -> we have alredy tried to get geotag info but failed continue; } if (!$photoInfo['tm']) { // no attemp was made to get GeoInfo $imgPath=$this->getPhotoAbsPath($photoNum); $gpsData = CLimage::getGPS($imgPath); $this->photos[$photoNum]['lat']=$gpsData[0]; $this->photos[$photoNum]['lon']=$gpsData[1]; $this->photos[$photoNum]['tm']=$gpsData[2]; // warning tm in local time ... $changed=1; // we got at least the tm } if (!$this->photos[$photoNum]['tm']) { $this->photos[$photoNum]['tm']=1; $changed=1; continue; } if (!$this->photos[$photoNum]['lat'] && !$this->photos[$photoNum]['lon']) { // try to get lat/lon depending on the position in track if (!$gotTrack) { //echo "getting track!"; $flight=new flight(); $flight->getFlightFromDB($this->flightID,0); //dont update takeoffs list($trackLat,$trackLon,$trackTms,$trackAlt)=$flight->getXYValues(1,1); // get also TM and ALT $gotTrack=1; } //correct the tm of the photo that we got from EXIF by subtracking up the timezone offset $this->photos[$photoNum]['tm']-=$flight->timezone*3600; //we will use this to add to every time entry we gto from getXYValues() $startTm=strtotime($flight->DATE); //echo "Flight start time is ".$flight->DATE." -> ".$startTm; $lastTm=$startTm; $photoTm=$this->photos[$photoNum]['tm']; //echo " starttime:$lastTm photo : $photoTm<BR>".count($trackTms); foreach($trackTms as $i=>$tm) { $thisTm=$startTm+$tm; if ( $photoTm<$thisTm && $photoTm>$lastTm ) { //echo "found position!!! tm=$thisTm<BR>"; $this->photos[$photoNum]['lat']=$trackLat[$i]; $this->photos[$photoNum]['lon']=-$trackLon[$i]; $this->photos[$photoNum]['alt']=$trackAlt[$i]; $changed=1; break; } } } } if ($changed) { $this->putToDB(0); // dont update the flights table } }