Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
private string DDToGPRMCpost(double Lat, double Lng)
       {
           double Res, Decdeg;
           string Latstr, Lngstr;

           //lat
           Res = Math.Abs(Math.Truncate(Lat)); //45
           Decdeg = Math.Round((Math.Abs(Lat) - Math.Abs(Math.Truncate(Lat))) / 60, 6);
           Latstr = Res.ToString() + Decdeg.ToString();
           Latstr = (Lat > 0) ? Latstr + ",N" : Latstr + ",S";
           //lng
           Res = Math.Abs(Math.Truncate(Lng));
           Decdeg = Math.Round((Math.Abs(Lng) - Math.Abs(Math.Truncate(Lng))) / 60, 6);
           Lngstr = Res.ToString() + Decdeg.ToString();
           Lngstr = (Lng > 0) ? Lngstr + ",E" : Lngstr + ",W";

           return  Latstr + "," + Lngstr;
       }


This is what I have so far... doesn't seem to be working correctly...
Posted
Comments
Sergey Alexandrovich Kryukov 19-Jan-15 16:44pm    
How about using the debugger?
And don't use Math.Round! Why?
And don't use string return type. Why? Work with data, not strings representing data.
—SA

1 solution

Have you read the NMEA protocol? For GPRMC you need 12 fields including checksum:
http://aprs.gids.nl/nmea/#rmc[^]

This may help:
NMEA 0183 sentence parser/builder[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900