将十六进制转换为经纬度所需的 PHP 函数长的
我有一个关于纬度和经度编码的问题,但我的大脑拒绝给出答案。
我需要编写一个php函数,它采用值“1446041F”和“447D1100”(纬度和经度)进行一些处理(我无法理解的位)并输出“52.062297”和“0.191030”。
有人告诉我经纬度和纬度Lng 由带符号的度、分和小数分编码为 4 个字节,格式如下;
Latitude: SDDMM.MMMMM where 0≤DD≤90, S = [+|-], 0≤M≤9
Longitude: SDDDMM.MMMMM where 0≤DDD≤180, S = [+|-], 0≤M≤9
看到最后一点,我搜索了很多网站,但我仍然不知道这意味着什么。
我知道这是在黑暗中拍摄的一个巨大镜头,而且可能很简单,我被正确地告知要戴着笨蛋帽子坐在角落里,但我的头发已经不多了!
非常感谢任何建议。
谢谢, 马修
I have a question regarding lattitude and longitude encoding, the answer to which my brain refuses to produce.
I need to write a php function that takes the value '1446041F' and '447D1100' (Lat & Lng) does some processing (the bit I cannot fathom) and outputs '52.062297' and '0.191030'.
I am told the Lat & Lng are encoded to 4 bytes from a signed degrees, minutes and decimal minutes with a format as follows;
Latitude: SDDMM.MMMMM where 0≤DD≤90, S = [+|-], 0≤M≤9
Longitude: SDDDMM.MMMMM where 0≤DDD≤180, S = [+|-], 0≤M≤9
See that last bit, I've searched many sites but I still have no idea what that all means.
I'm aware this is a massive shot in the dark and it may be so simple that I am rightfully told to sit in the corner wearing the dunce hat but I am running low on hair to pull out!
Any advice is much appreciated.
Thanks,
Matthew
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您给出的示例
1446041F
和447D1100
可能是小端字节顺序的 32 位有符号整数。它们的解读如下:
它们可以以度和分来解释,如下所示:
以下函数将把您指定的十六进制值转换为度。我假设这些值是整数,如 0x447D1100 等。如果我假设错误并且输入值实际上是字符串,请告诉我。我把这个功能放到了公共领域。
The examples you gave,
1446041F
and447D1100
are probably 32-bit signed integers in little-endian byte order.They are to be read as follows:
They can be interpreted in degrees and minutes like this:
The following function will convert the hex values you specified to degrees. I assume the values are integers like 0x447D1100 and the like. If I assume wrong and the input values are actually strings, let me know. I put this function into the public domain.
这是 PHP(为了清晰起见,冗长):
Here's the PHP (the verbosity is for clarity):