Bug report #6687

Wrong GPS position

Added by Tomas Vrana about 12 years ago. Updated almost 12 years ago.

Status:Closed
Priority:Normal
Assignee:Marco Hugentobler
Category:Digitising
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:15855

Description

I have a GPS attached to linux machine via gpsd. I have two notebooks with openSuse 12.2 and identical versions of Qgis - 1.8.0. When same project is opened on both machines and gps tracking is on, then one shows correct position, bu the other is about 1500 m mistaken. Both receive same data from the same gpsd server.

Associated revisions

Revision b75c89b8
Added by Jürgen Fischer almost 12 years ago

nmea parsing: call strtod with locale "C" (fixes #6687)

History

#1 Updated by Tomas Vrana about 12 years ago

Actually it seems, that in the live tracking GPS the LAT/LON numbers are just stuck. The don't change at all. Running via gpsd, I check the position with xgps simultaneously, and the position is correct there. QGIS however shows GPS status green.

#2 Updated by Tomas Vrana about 12 years ago

Same in 1.9.0 Alpha (git master)

#3 Updated by Tomas Vrana about 12 years ago

Setting LC_NUMERIC=en_US.utf8 helps.

Parsing of NMEA strings depends strtod() string to double conversion which is locale dependent, however NMEA always uses a decimal dot. So currently if you locale has different decimal separator your GPS tracking will look stuck, becuase you get the nondecimal part only.

Optimally it would be good to fix core/gps/tok.c on line 89

res = strtod( &buff[0], &tmp_ptr );

so it wouldn't depend on locale.

#4 Updated by Marco Hugentobler about 12 years ago

  • Assignee set to Marco Hugentobler
  • Pull Request or Patch supplied changed from No to Yes

#5 Updated by Marco Hugentobler almost 12 years ago

  • Pull Request or Patch supplied changed from Yes to No

What kind of replacement for strtod do you suggest?
It might be possible to use QString::number for that purpose, but on the other hand it might not be good to insert that into a source file from libnmea (which has no dependency to Qt). Any better suggestion?

#6 Updated by Tomas Vrana almost 12 years ago

Perhaps wrap the strtod in a temporary locale switch function would be a portables solution...

     void
     with_other_locale (char *new_locale,
                        void (*subroutine) (int),
                        int argument)
     {
       char *old_locale, *saved_locale;

       /* Get the name of the current locale.  */
       old_locale = setlocale (LC_ALL, NULL);

       /* Copy the name so it won't be clobbered by setlocale. */
       saved_locale = strdup (old_locale);
       if (saved_locale == NULL)
         fatal ("Out of memory");

       /* Now change the locale and do some stuff with it. */
       setlocale (LC_ALL, new_locale);
       (*subroutine) (argument);

       /* Restore the original locale. */
       setlocale (LC_ALL, saved_locale);
       free (saved_locale);
     }

#7 Updated by Jürgen Fischer almost 12 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF