The GPS C# sample in the WM5 SDK is extremely useful. You can get it here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mobilesdk5/html/mogrfgpssample.asp
However it has a small bug in one of the sample classes: if the longitude is a fraction of zero then a DivideByZeroException will be thrown. Of course this is only obvious if you live near Greenwich or somewhere else on the longitude zero line.
Anyway I'm worried about Latitude now - so I'm off to Nyeri in Kenya to try it out ;-)
What you want the fix? The example has a bug in the DegreesMinutesSeconds.cs class, ToDecimalDegrees() method
public double ToDecimalDegrees()
{
int absDegrees = Math.Abs(degrees);
double val = (double)absDegrees + ((double)minutes / 60.0) + ((double)seconds / 3600.0);
return val * (absDegrees / degrees);
}
If degrees are zero a DivideByZeroException will be thrown
Adding the following corrects it:
public double ToDecimalDegrees()
{
int absDegrees = Math.Abs(degrees);
double val = (double)absDegrees + ((double)minutes / 60.0) + ((double)seconds / 3600.0);
if (degrees == 0) { return val; };
return val * (absDegrees / degrees);
}