[Solved] how to translate the GPS coordinates in the form (degrees, minutes, seconds) C #? [closed]


You need read about BitConverter.ToInt32.

You can write something like this:

byte[] Value = new byte[] { 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x34, 0x00, 0x00, 0xE8, 0x03, 0x00, 0x00 };
int deg = BitConverter.ToInt32(Value, 0);    // convert first 4 bytes to int
int min = BitConverter.ToInt32(Value, 8);    // convert bytes  8 - 11 to int
int ss = BitConverter.ToInt32(Value, 16);    // convert bytes 16 - 19 to int

double sec = ss / 1000 + Math.Round((ss % 1000) / 1000.0, 2);

string output = string.Format(@"{0} degrees {1} minutes {2} seconds", deg, min, sec);
Console.WriteLine(output);

Output:

33 degrees 36 minutes 13.39 seconds

solved how to translate the GPS coordinates in the form (degrees, minutes, seconds) C #? [closed]