Bug 143594

Summary: bad Interpolation in correlate gpssync
Product: [Applications] digikam Reporter: Stéphane Pontier <shadow.walker>
Component: Geolocation-CorrelatorAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles, gerhard
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Mandriva RPMs   
OS: Linux   
Latest Commit: Version Fixed In: 0.1.0
Attachments: interpolation fix in gpssync

Description Stéphane Pontier 2007-03-29 17:26:38 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Mandriva RPMs
OS:                Linux

when trying to see the result of a gpssync on a map, I found that points that had been correlated were wrong. I found out that the code taking care of the correlation was:
point1 + (point2-point1) * (time2-time1)/(timeCor-time1)
(where point can be lat,long or alt)

but it should be:
point1 + (point2-point1) * (timeCor-time1)/(time2-time1)

for example, if you have 2 gps points
 - at time1 0 :   altitude 0
 - at time2 3mn : altitude 30meters
 - a picture taken at timeCor 2mn.

if you take the first formula, you correlate the altitude of the picture at:
  0 + (30-0) * (3-0)/(2-0)
  that give = 45meters which is obviously wrong

but if you calculate this using the second formula you obtain:
  0 + (30-0) * (2-0)/(3-0)
  that give = 20meters which is correct


you can test the following patch that correct formula and rename the t3 variable to tCor to avoid confusion (which occur each time I reread the formula where t3 is after t1 but before t2)
Comment 1 Stéphane Pontier 2007-03-29 17:28:03 UTC
Created attachment 20121 [details]
interpolation fix in gpssync

patch for fix the interrpolation formula and rename variable t3 to tCor for
more readability
Comment 2 caulier.gilles 2007-03-29 17:40:13 UTC
Gerhard,

Like you have a GPS device, can you confirm this bug ? If yes, can you test the patch and apply it on svn ?

Thanks in advance

Gilles
Comment 3 Gerhard Kulzer 2007-03-30 10:12:46 UTC
SVN commit 648020 by gkulzer:

correcting interpolation
CCMAIL:caulier.gilles@gmail.com, shadow.walker@free.fr
BUG:143594

 M  +5 -5      gpsdataparser.cpp  


--- trunk/extragear/libs/kipi-plugins/gpssync/gpsdataparser.cpp #648019:648020
@@ -113,13 +113,13 @@
             double lon2 = nextGPSPoint.longitude();
             double lat2 = nextGPSPoint.latitude();
             uint   t2   = nextDateTime.toTime_t();
-            uint   t3   = cameraGMTDateTime.toTime_t();
+            uint   tCor   = cameraGMTDateTime.toTime_t();
 
-            if (t3-t1 != 0)  
+            if (tCor-t1 != 0)  
             {
-                gpsData.setAltitude(alt1  + (alt2-alt1) * (t2-t1)/(t3-t1));
-                gpsData.setLatitude(lat1  + (lat2-lat1) * (t2-t1)/(t3-t1));
-                gpsData.setLongitude(lon1 + (lon2-lon1) * (t2-t1)/(t3-t1));
+                gpsData.setAltitude(alt1  + (alt2-alt1) * (tCor-t1)/(t2-t1));
+                gpsData.setLatitude(lat1  + (lat2-lat1) * (tCor-t1)/(t2-t1));
+                gpsData.setLongitude(lon1 + (lon2-lon1) * (tCor-t1)/(t2-t1));
                 gpsData.setInterpolated(true);
                 return true;
             }