The Ordnance Survey maps for Great Britain use grid references based on the Airy Spheroid (OSGB36) reference ellipsoid.
The following article discusses a C# class to convert GPS derived NMEA data to the British Ordnance Survey Grid.
This article assumes that the NMEA data is being derived using Jon Person's excellent NMEA interpreter class as discussed in Writing Your Own GPS Applications: Part 2.
In order to perform the transformation, some additional data is required in the form of ellipsoid height, which can be derived from the NMEA $GPGGA sentence.
The $GPGGA sentence is not parsed in the original from of the NMEAinterpreter so this must be added.
First off, we need to make a couple of small alterations to the NMEAinterpreter class, for an explanation of these changes read the "Re: Love this product!...just 1 minor Logical ERROR" comments.
In public bool ParseGPGSV(string sentence)
where it says
SignalToNoiseRatio = Convert.ToInt32(Words[Count * 4 + 2]);
it should say
SignalToNoiseRatio = Convert.ToInt32(Words[Count * 4 + 3]);
Also
public string[] GetWords(string sentence)
should be modified as follows
public string[] GetWords(string sentence)
{
//remove the * and checksum from the end of the sentence
sentence = sentence.Substring(0, sentence.IndexOf("*"));
//now split it up
return sentence.Split(',');
}
Now we need to add parsing of the $GPGGA sentence.
First we will need to add a new delegate for the ellipsoid height event:
Below the line
public delegate void PDOPReceivedEventHandler(double value);
add the line
public delegate void EllipsoidHeightReceivedEventHandler(double value);
We also need to add a new event:
Below the line
public event PDOPReceivedEventHandler PDOPReceived;
add the line
public event EllipsoidHeightReceivedEventHandler EllipsoidHeightReceived;The
public bool Parse(string sentence)
routine needs a new case added for the $GPGGA sentence.
Replace
case "$GPGSA":
return ParseGPGSA(sentence);
default:
// Indicate that the sentence was not recognised
return false;
with
case "$GPGSA":
return ParseGPGSA(sentence);
case "$GPGGA":
return ParseGPGGA(sentence);
default:
// Indicate that the sentence was not recognised
return false;
Now we need to add parsing of the $GPGGA sentence.
There are numerous web pages which detail the structure of the various NMEA sentences, I got my information from http://www.commlinx.com.au/NMEA_sentences.htm. If the first word of the GPGGA sentence is word 0 then word 9 contains the ellipsoid height.
public bool ParseGPGGA(string sentence)
could be added below
public bool ParseGPGSA(string sentence)
public bool ParseGPGGA(string sentence)
{
// Divide the sentence into words
string[] Words = GetWords(sentence);
if (Words[9] != "")
{
if (EllipsoidHeightReceived != null)
EllipsoidHeightReceived(double.Parse(Words[9]));
}
return true;
}
So now we have modified Jon Person's NMEAinterpreter class to give us the ellipsoid height. (In practice you may want to pull out various other bits of data too).
On the next page we will make a start on the coordinate transformation class.
Comments