通过 Imageing.PropertyItems 读取照片GPS信息时,GPS经纬度的度分秒中,秒只能得到小数点后三位精度。
但通过windows 属性查看照片GPS信息时,秒是精确到小数点后15位的
这个是怎么回事,VB.NET能实现精确到小数点后15位么
Private Sub GetGPSTest()
Dim theImage As Image = New Bitmap("c:\test.jpg")
Dim propItems As PropertyItem() = theImage.PropertyItems '获取照片的PropertyItems
Dim propItem As PropertyItem
Dim value As Byte()
Dim d, m, s As Double
Dim Latitude As String
For Each propItem In propItems
If propItem.Id = &H2 Then '找到维度信息
value = propItem.Value '
d = BitConverter.ToUInt32(value, 0) / BitConverter.ToUInt32(value, 4) '读取度
m = BitConverter.ToUInt32(value, 8) / BitConverter.ToUInt32(value, 12) '读取分
s = BitConverter.ToUInt32(value, 16) / BitConverter.ToUInt32(value, 20) '读取秒
'结果为 31; 20; 20.706 其中秒只显示到小数点后三位
'但在windows中查看照片exif属性,能看到维度为31; 20; 20.706000000005673
'秒显示到小数点后15位,这个是怎么实现的
Latitude = String.Format("{0:#}; {1:#}; {2}", d, m, s)
End If
Next
End Sub
------解决思路----------------------
类型换成decimal试试
double精度本身也才15位吧,加上小数点前2位,后面的不见了也可能是正常现象
------解决思路----------------------
也有可能是windows图片查看器本身使用的类型在二进制处理的时候就损失了精度,导致转10进制字符串的时候出现误差
就如8楼所说,精确到纳米级别根本毫无意义
能精确到小数点后3位已经足够了
GPS设备本身的误差可能就已经大于1米了
------解决思路----------------------
15位正好是一个Double类型的精度,猜测Windows图片查看器是把秒的整数和小数部分拆开存放的,Double有点误差不稀奇。