如何以形式(度、分、秒)转换 GPS 坐标 C #

本文关键字:转换 GPS 坐标 | 更新日期: 2023-09-27 18:35:55

PropertyItem GpsAltitudeProperty = photo.GetPropertyItem(0x0004);
string GpsAltitude = BitConverter.ToString(GpsAltitudeProperty.Value);
textBox7.Text = GpsAltitude.ToString();

显示:

21-00-00-00-01-00-00-00-00-24-00-00-00-01-00-00-00-50-34-00-00-E8-03-00-00

您需要获取表单的坐标:(33度36分13.39秒)21是33在十进制系统中是36到24在十进制系统中以及第二个记录在16位十六进制系统中不理解。以及如何以正常方式进入:33度36分13.39秒)21是33在十进制系统中是36到24在十进制系统中以及第二个记录在16位十六进制系统中不理解。

如何以形式(度、分、秒)转换 GPS 坐标 C #

你需要阅读BitConverter.ToInt32。

你可以写这样的东西:

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);

输出:

33 degrees 36 minutes 13.39 seconds