Windows CE GPSID, its C# wrapper, and device emulator interaction issues

GPSID (the GPS abstraction APIs introduced in Windows Mobile 5) has a few known issues (aka bugs).  This is rather complicated due to versioning issues and also because of a C# wrapper library for the API's that work around the bug, which may or may not exist on certain platforms. 

The base issue is that when GPSID shipped to our OEMs in Windows Mobile 5, it returned longitude and latitude in a very bad format.  (Raw from the NMEA stream and not in reasonable degrees).  It was possible to compute a reasonable representation of lat/long from what GPSID returned, but it was not reasonable to have every ISV in the world do this.  So before our OEMs shipped any devices (it takes a few months for them to get ready) we released a fix to GPSID so it returned reasonable values and it was put on all actual PocketPC + SmartPhone devices.  This should have been the end of the story.  Unfortunately there are other factors here.

Another MS developer created a C# wrapper library for GPSID that just P/Invoked the GPSID API's.  He dealt with the bad values that GPSID was returning pre-fix and converted them to be reasonable for the app.  Unfortunately, the C# APIs were not fixed to remove this workaround when GPSID was fixed.  So currently they are doing a conversion of the correct lat/long values, which means they're returning bogus data now.

Further complicating this is that while the GPSID fix made it to PocketPC + SmartPhone ROMs, it did not make it to the device emulator.  So that means on the emulator the C# piece actually does work correctly because it's still fixing valid data, but using the C APIs will give invalid results.

Summary:
GPSID with C APIs:
  Emulator
    STATUS: Will not work (GPSID bug not fixed)
    WORKAROUND: Call GetDegreesFromAngular() (see below) on lat + long values.
  PocketPC/SmartPhone (real device)
    STATUS: Will work (GPSID bug was fixed)
    WORKAROUND: Not needed

GPSID with C# APIs:
  Emulator
    STATUS: Will work (GPSID bug not fixed, C# work around for issue in place)
    WORKAROUND: Not needed
  PocketPC/SmartPhone (real device)
    STATUS: Will not work (C# API working around a bug that no longer exists)
    WORKAROUND: Remove the C# code (it was shipped as source) that does the unneeded conversion.

We're very likely to get the C# wrapper fixed in a future release.  Fixing GPSID on the emulator is under investigation.  You can tell if underlying GPSID is fixed simply by making sure that the lat/long values it returns are what they're supposed to be for whatever the GPS driver is telling it.

As promised above, the conversion function you need ONLY on emulator and using C API lat/long (note I haven't tested this as I'm describing below but it should work)

DOUBLE GetDegreesFromAngular(DOUBLE dbl) {
        dbl /= 100;

 int    i    = (int) dbl;
 DOUBLE frac = (dbl - (double)i) * (100.0 / 60.0);

 return ((double)i + frac);
}

I apologize for all the problems this caused.  The fault here is totally mine, and not the C# developer.  Thanks to Christopher E Piggott of Rochester Institute of Technology and Trapulo "of Italy" (sorry I don't know your real name) for bringing all the C# + emulator issues to my attention and testing out some theories I had.

[Author: John Spaith]