如何将二进制(十六进制)数据转换为纬度和经度?

发布于 2024-10-19 01:40:38 字数 1619 浏览 1 评论 0原文

我有一些传递地理位置坐标的二进制数据流 - 纬度和经度。我需要找到它们的编码方法。

4adac812 = 74°26.2851' = 74.438085
2b6059f9 = 43°0.2763'  = 43.004605

4adaee12 = 74°26.3003' = 74.438338
2a3c8df9 = 42°56.3177' = 42.938628

4ae86d11 = 74°40.1463' = 74.669105
2afd0efb = 42°59.6263' = 42.993772

第一个值是十六进制值。第二和第二第三个是我在输出中获得的值(不确定在转换中使用哪一个)。

我发现第一个字节代表值的整数部分(0x4a = 74)。但我找不到小数部分是如何编码的。

我真的很感激任何帮助!

谢谢。

--

更新:该流来自一些“中国”GPS服务器软件通过tcp协议。我没有客户端软件的来源或文档。我想它是用 VC++6 编写的并使用了一些标准实现。

--

Upd:这是我得到的数据包:

Hex data:
41 00 00 00  13 bd b2 2c
4a e8 6d 11  2a 3c 8d f9
f6 0c ee 13

Log data in client soft:
[Lng] 74°40.1463', direction:1
[Lat] 42°56.3177', direction:1
[Head] direction:1006, speed:3318, AVA:1
[Time] 2011-02-25 19:52:19

Result data in client (UI):
74.669105
42.938628
Head 100 // floor(1006/10)
Speed 61.1 // floor(3318/54.3)


41 00 00 00  b1 bc b2 2c
4a da ee 12  2b 60 59 f9
00 00 bc 11
[Lng] 74°26.3003', direction:1
[Lat] 43°0.2763', direction:1
[Head] direction:444, speed:0, AVA:1
[Time] 2011-02-25 19:50:49
74.438338
43.004605


00 00 00 00  21 bd b2 2c
4a da c8 12  aa fd 0e fb
0d 0b e1 1d
[Lng] 74°26.2851', direction:1
[Lat] 42°59.6263', direction:1
[Head] direction:3553, speed:2829, AVA:1
[Time] 2011-02-25 19:52:33
74.438085
42.993772

我不知道前 4 个字节是什么意思。

我发现第5个字节的低7位代表秒数。 (也许 5-8 位是时间?) 字节9表示Lat的整数。

字节13是Lng的整数。

字节 17-18 反转(字字节)是速度。

字节 19-20 反转为 ava(?) &方向(4 + 12 位)。 (顺便说一句,有人知道 ava 是什么吗?)

还有一个注释。在第三个数据包的第 13 个字节中,您可以看到仅使用了低 7 位。我想第一个位并不意味着什么(我一开始就把它删除了,如果我错了,抱歉)。

I have some binary data stream which passes geo location coordinates - latitude and longitude. I need to find the method they are encoded.

4adac812 = 74°26.2851' = 74.438085
2b6059f9 = 43°0.2763'  = 43.004605

4adaee12 = 74°26.3003' = 74.438338
2a3c8df9 = 42°56.3177' = 42.938628

4ae86d11 = 74°40.1463' = 74.669105
2afd0efb = 42°59.6263' = 42.993772

1st value is hex value. 2nd & 3rd are values that I get in output (not sure which one is used in conversion).

I've found that first byte represents integer part of value (0x4a = 74). But I cannot find how decimal part is encoded.

I would really appreciate any help!

Thanks.

--

Upd: This stream comes from some "chinese" gps server software through tcp protocol. I have no sources or documentation for clent software. I suppose it was written in VC++6 and uses some standard implementations.

--

Upd: Here is packets I get:

Hex data:
41 00 00 00  13 bd b2 2c
4a e8 6d 11  2a 3c 8d f9
f6 0c ee 13

Log data in client soft:
[Lng] 74°40.1463', direction:1
[Lat] 42°56.3177', direction:1
[Head] direction:1006, speed:3318, AVA:1
[Time] 2011-02-25 19:52:19

Result data in client (UI):
74.669105
42.938628
Head 100 // floor(1006/10)
Speed 61.1 // floor(3318/54.3)


41 00 00 00  b1 bc b2 2c
4a da ee 12  2b 60 59 f9
00 00 bc 11
[Lng] 74°26.3003', direction:1
[Lat] 43°0.2763', direction:1
[Head] direction:444, speed:0, AVA:1
[Time] 2011-02-25 19:50:49
74.438338
43.004605


00 00 00 00  21 bd b2 2c
4a da c8 12  aa fd 0e fb
0d 0b e1 1d
[Lng] 74°26.2851', direction:1
[Lat] 42°59.6263', direction:1
[Head] direction:3553, speed:2829, AVA:1
[Time] 2011-02-25 19:52:33
74.438085
42.993772

I don't know what first 4 bytes mean.

I found the lower 7 bits of 5th byte represent the number of sec. (maybe 5-8 bits are time?)
Byte 9 represent integer of Lat.

Byte 13 is integer of Lng.

Bytes 17-18 reversed (word byte) is speed.

Bytes 19-20 reversed is ava(?) & direction (4 + 12 bits). (btw, somebody knows what ava is?)

And one note. In 3rd packet 13th byte you can see only lower 7 bits are used. I guess 1st bit doesnt mean smth (I removed it in the beginning, sorry if I'm wrong).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淑女气质 2024-10-26 01:40:38

我重新排序了您的数据,以便我们首先有 3 个经度,然后是 3 个纬度:

74.438085、74.438338、74.669105、43.004605、42.938628、42.993772

这是我能想到的最适合的十六进制数是:

74.437368、74 .439881, 74.668392, 42.993224 、 42.961388、 42.982391

区别是: -0.000717、 0.001543、 -0.000713、 -0.011381、 0.022760、 -0.011381

从完整的十六进制(4 个而不是 3 个字节)生成这些值的程序是:

int main(int argc, char** argv) {
    int a[] = { 0x4adac812, 0x4adaee12, 0x4ae86d11, 0x2b6059f9, 0x2a3c8df9, 0x2afd0efb };
    int i = 0;
    while(i<3) {
        double b = (double)a[i] / (2<<(3*8)) * 8.668993 -250.0197;
        printf("%f\n",b);
        i++;
    }
    while(i<6) {
        double b = (double)a[i] / (2<<(3*8)) *  0.05586007 +41.78172;
        printf("%f\n",b);
    i++;
    }
    printf("press key");
    getch();
}

I have reordered your data so that we first have 3 longitures and then 3 latitudes:

74.438085, 74.438338, 74.669105, 43.004605, 42.938628, 42.993772

This is the best fit of the hexadecimals i can come up with is:

74.437368, 74.439881, 74.668392, 42.993224, 42.961388, 42.982391

The differences are: -0.000717, 0.001543, -0.000713, -0.011381, 0.022760, -0.011381

The program that generates these values from the complete Hex'es (4 not 3 bytes) is:

int main(int argc, char** argv) {
    int a[] = { 0x4adac812, 0x4adaee12, 0x4ae86d11, 0x2b6059f9, 0x2a3c8df9, 0x2afd0efb };
    int i = 0;
    while(i<3) {
        double b = (double)a[i] / (2<<(3*8)) * 8.668993 -250.0197;
        printf("%f\n",b);
        i++;
    }
    while(i<6) {
        double b = (double)a[i] / (2<<(3*8)) *  0.05586007 +41.78172;
        printf("%f\n",b);
    i++;
    }
    printf("press key");
    getch();
}
叫嚣ゝ 2024-10-26 01:40:38

在这里集思广益。

如果我们查看第二个字节的低 6 位 (data[1]&0x3f),我们会得到大多数示例的“分钟”值。

0xda & 0x3f = 0x1a = 26; // ok
0x60 & 0x3f = 0; // ok
0xe8 & 0x3f = 0x28 = 40; // ok
0x3c & 0x3f = 0x3c = 60; // should be 56
0xfd & 0x3f = 0x3d = 61; // should be 59

也许这是正确的方向?

Brainstorming here.

If we look at the lower 6 bits of the second byte (data[1]&0x3f) we get the "minutes" value for most of the examples.

0xda & 0x3f = 0x1a = 26; // ok
0x60 & 0x3f = 0; // ok
0xe8 & 0x3f = 0x28 = 40; // ok
0x3c & 0x3f = 0x3c = 60; // should be 56
0xfd & 0x3f = 0x3d = 61; // should be 59

Perhaps this is the right direction?

月亮邮递员 2024-10-26 01:40:38

我已经尝试过你的新数据包:

74+40.1463/60
74+26.3003/60
74+26.2851/60
42+56.3177/60
43+0.2763/60
42+59.6263/60

74.66910, 74.43834, 74.43809, 42.93863, 43.00460, 42.99377

我的程序给出:

74.668392, 74.439881, 74.437368, 42.961388, 42.993224, 39.407346

区别在于:

-0.000708,  0.001541,  -0.000722,  0.022758, -0.011376, -3.586424

我重新使用了从第一个数据包中导出的 4 个常量,因为这些常量可能存储在您的客户端中的某个位置。细微的差异可能是客户端进行一些随机化的结果,以防止您获得准确的值或对其协议进行逆向工程。

I have tried your new data packets:

74+40.1463/60
74+26.3003/60
74+26.2851/60
42+56.3177/60
43+0.2763/60
42+59.6263/60

74.66910, 74.43834, 74.43809, 42.93863, 43.00460, 42.99377

My program gives:

74.668392, 74.439881, 74.437368, 42.961388, 42.993224, 39.407346

The differences are:

-0.000708,  0.001541,  -0.000722,  0.022758, -0.011376, -3.586424

I re-used the 4 constants i derived from your first packet as those are probably stored in your client somewhere. The slight differences might be the result of some randomization the client does to prevent you from getting the exact value or reverse-engineering their protocol.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文