Bug 134747

Summary: GPS Sync: not optimal correlation
Product: [Applications] digikam Reporter: Fabien <fabien.ubuntu>
Component: Geolocation-CorrelatorAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 0.1.0
Attachments: picture with no GPS tags
picture with no GPS tags
Picture with GPS tags
GPX file
Small and dirty patch

Description Fabien 2006-09-27 15:52:27 UTC
Version:           svn (using KDE KDE 3.5.2)
Installed from:    Ubuntu Packages
OS:                Linux

When parsing a gpx file, gpssync stops at the first match when interval < max gap.

Extract from source code gpsdataparser.cpp:

    for (GPSDataMap::Iterator it = m_GPSDataMap.begin();
         it != m_GPSDataMap.end(); ++it )
    {
        // Here we check a possible accuracy in seconds between the
        // Camera GMT time and the GPS device GMT time.

        int nbSecs = abs(cameraGMTDateTime.secsTo( it.key() ));

        if( nbSecs < maxGapTime )
        {
            gpsData = m_GPSDataMap[it.key()];
            return true;
        }
    }

But, the first match is usually not the best one. gpssync should continue to iterate until it find the best value (min interval)...
Comment 1 Fabien 2006-09-27 17:24:01 UTC
Created attachment 17939 [details]
picture with no GPS tags
Comment 2 Fabien 2006-09-27 17:24:01 UTC
Created attachment 17940 [details]
picture with no GPS tags
Comment 3 Fabien 2006-09-27 17:27:06 UTC
Created attachment 17941 [details]
Picture with GPS tags
Comment 4 Fabien 2006-09-27 17:27:54 UTC
Created attachment 17942 [details]
GPX file
Comment 5 Fabien 2006-09-27 17:31:24 UTC
Created attachment 17943 [details]
Small and dirty patch

This is a very dirty hack to get the best gps values...
Comment 6 Fabien 2006-09-27 17:43:25 UTC
BTW, timezone is GMT+2
Comment 7 caulier.gilles 2006-09-30 10:55:47 UTC
Fabien,

3 images are the same with the same date !

Gilles
Comment 8 caulier.gilles 2006-09-30 11:03:53 UTC
SVN commit 590452 by cgilles:

kipi-plugins from trunk : GPSSync : optimize GPX data parsing to search the minimal diff time.

Fabien, your patch is not optimum because it don't check all items in the list. In fact if the date list of GPS point isn't sorted using time stamp, your optimization don't work.

Of course i will very surprise if the gps data list is not sorted in time (:=))). But like I have none experience with GPS data, we must care about this point.

Please test this patch indeep and give me your feedback. Thanks in advance.

CCBUGS: 134747

 M  +9 -3      gpsdataparser.cpp  


--- trunk/extragear/libs/kipi-plugins/gpssync/gpsdataparser.cpp #590451:590452
@@ -68,6 +68,8 @@
     QDateTime cameraGMTDateTime = photoDateTime.addSecs(timeZone*3600*(-1));
 
     // We trying to find the right date in the GPS points list.
+    bool findItem = false;
+    int nbSecItem = maxGapTime;
 
     for (GPSDataMap::Iterator it = m_GPSDataMap.begin();
          it != m_GPSDataMap.end(); ++it )
@@ -77,13 +79,17 @@
         
         int nbSecs = abs(cameraGMTDateTime.secsTo( it.key() ));
         
-        if( nbSecs < maxGapTime )
+        // We tring to find the minimal accuracy.
+        if( nbSecs < maxGapTime && nbSecs < nbSecItem)
         {
-            gpsData = m_GPSDataMap[it.key()];
-            return true;
+            gpsData   = m_GPSDataMap[it.key()];
+            findItem  = true;
+            nbSecItem = nbSecs;
         }
     }
 
+    if (findItem) return true;
+
     // If we can't find it, we will trying to interpolate the GPS point.
 
     if (interpolate)
Comment 9 caulier.gilles 2006-10-01 20:03:32 UTC
Fabien,

Can you give me a fresh feedback about my last fix ? Its work fine for you ?

Gilles
Comment 10 Fabien 2006-10-05 17:07:08 UTC
Hello,

Sorry for this late answer...

Yes, it's working really fine !
I tried with different gpx files containing 1 or more tracks and it's ok !
I even tried to merge in a single gpx file 2 tracks from 2 different GPSr taken at the same time (so with the same dates) and it works perfectly fine : the best position is taken between the 2 tracks.
So, it looks really ok for me !
Thanks a lot Gilles !
Comment 11 caulier.gilles 2006-10-05 18:21:25 UTC
ok. Thanks for the report Fabien. I close this file now.

Gilles Caulier