NEO-7M定位信息转换

素颜马尾好姑娘i 2022-12-27 12:50 67阅读 0赞

标准

一、 目前国内正在使用的有两种坐标系

  1. 火星坐标系 (GCJ-02)
  2. 百度坐标系 (BD-09)

二、 国内的地图软件获取的位置一般是自己的标准,例如百度的BD-09,各自之间不太通用。
三、 传感器获取的经纬度(例如GPS与北斗)是原始数据,也不能直接拿来在各大地图api上使用

转化为WGS84(全球通用GPS标准)

NEO-7M获取的经纬度信息是abcde.figh格式,这个理论精确度是0.1m,但是直接获取的地理位置信息不能直接用,需要先转化为标准的位置信息。计算方法是小数点前高位不足补零,小数点后位数不足补零按位计算abc+de/60+figh/600000或者是abc+de.figh/60
不考虑性能的java示例代码

  1. public static double NEO7MToWgs84(Stringneo7m) {
  2. String tempValue = neo7m;
  3. //将数据长度格式化为abcde.figh格式
  4. String[] valueTable = tempValue.split("\\.");
  5. while (valueTable[0].length() < 5 || valueTable[1].length() < 4) {
  6. if (valueTable[0].length() < 5) {
  7. valueTable[0] = "0" + valueTable[0];
  8. }
  9. if (valueTable[1].length() < 4) {
  10. valueTable[1] += "0";
  11. }
  12. }
  13. double abc = Double.parseDouble(valueTable[0].substring(0, 3));
  14. double de = Double.parseDouble(valueTable[0].substring(3, 5));
  15. double figh = Double.parseDouble(valueTable[1].substring(0, 4));
  16. return abc + de / 60 + figh / 600000;
  17. }

C++11版本

  1. //实际使用需要添加正则表达式库,不要用以下include
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. class Utils
  5. {
  6. public:
  7. /** * @brief Neo7m To Wgs84 * * @param neo7m Neo7m raw data * @return double Wgs84 */
  8. static double Neo7mToWgs84(std::string neo7m)
  9. {
  10. if (neo7m.length() <= 2)
  11. {
  12. return 0.0;
  13. }
  14. //匹配数据为abcde.figh格式
  15. std::regex neo7reg("\\d+\\.\\d+");
  16. std::smatch neo7results;
  17. std::regex_search(neo7m, neo7results, neo7reg);
  18. std::string tempNeo7 = neo7results.str();
  19. std::string abcde = tempNeo7.substr(0, tempNeo7.find("."));
  20. while (abcde.length() < 5)
  21. {
  22. abcde.insert(abcde.begin(), '0');
  23. }
  24. std::string figh = tempNeo7.substr(tempNeo7.find(".") + 1);
  25. while (figh.length() < 4)
  26. {
  27. figh.insert(figh.begin(), '0');
  28. }
  29. return stod(abcde.substr(0, 3)) + stod(abcde.substr(3, 2)) / 60 + stod(figh.substr(0, 4)) / 600000;
  30. }
  31. };
  32. int main()
  33. {
  34. std::cout << Utils::Neo7mToWgs84("11337.47512 E") << std::endl;
  35. }

WGS84转其他参考https://blog.csdn.net/weixin_34356310/article/details/93012277

发表评论

表情:
评论列表 (有 0 条评论,67人围观)

还没有评论,来说两句吧...

相关阅读

    相关 py2neo操作Neo4j

    一、概述 Neo4j是一款开源图数据库,Py2neo提供了使用Python语言访问Neo4j的接口。本文介绍了使用Py2neo的NodeMatcher和Relations

    相关 neo4j 3.4.7安装和使用

    neo4j是目前最流行的图形数据库,支持完整的事务。在树形图中,图是有顶点、边和属性组成的,顶点和边都可以设置属性,顶点又称节点,边也叫做关系。每个节点和关系都可以由一个或多个