3

我正在编写一些图像处理代码,并且正在提取 GPS 坐标,但是它们是某种整数数组,我无法弄清楚如何转换为度/分/秒或十进制形式。

Lat: (38,0,0,0,1,0,0,0,54,0,0,0,1,0,0,0,168,73,5,0,16,39,0,0)
Lng: (77,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,60,122,0,0,16,39,0,0)

根据 windows,这个的 D/M/S 版本是:

在此处输入图像描述

VB.NET 代码最有帮助,但我可能可以将它从任何语言转换。

4

2 回答 2

3

这是使用 .NET 调用在 C# 中工作的代码(在 VB 中应该很简单)

Double deg = (Double)BitConverter.ToInt32(data,0)/ BitConverter.ToInt32(data,4);
Double min = (Double)BitConverter.ToInt32(data,8)/ BitConverter.ToInt32(data,12);
Double sec = (Double)BitConverter.ToInt32(data,16)/ BitConverter.ToInt32(data,20);

格式记录在这里 http://en.wikipedia.org/wiki/Geotagging

于 2013-10-03T04:55:35.400 回答
0

数组按以下形式排列:

bytes(0 -> 3) / bytes(4 -> 7) = degree
(bytes(8 -> 11) / bytes(12 -> 15)) / 60= minute
(bytes(16 -> 19) / bytes(20 -> 23)) / 3600 = second

*注 - 每个byte(x -> y)数量是范围的总和。

下面会将给定的 lat 数组解码为十进制形式。

    Dim coord(5) As Decimal
    Dim j As Integer = 0
    Dim coordinate As Decimal

    For i As Integer = 0 To lat.Length - 1
        coord(j) = coord(j) + lat(i)

        'If i is a multiple of 4, goto the next index
        If ((i + 1) Mod 4 = 0) And i <> 0 Then
            j += 1
        End If

    Next

    coordinate = (coord(0) / coord(1)) + ((coord(2) / coord(3))) / 60 + ((coord(4) / coord(5)) / 3600)

只需将引用的数组更改为解码 lng。

于 2013-10-03T04:56:27.043 回答