【问题标题】:HERE Map tile API : decode geometryHERE Map tile API:解码几何
【发布时间】:2020-06-30 08:18:06
【问题描述】:

我的目的是分析道路几何形状。为此,我使用 Map Tile API(例如https://vector.hereapi.com/v2/vectortiles/base/mc/11/1100/673/omv?apiKey={YOUR_API_KEY})来获取二进制文件。然后我使用 HERE 文档中给出的 protobuf 模式对文件进行解码,以获取一些 JSON 数据。在这个数据中我发现了这个:

"type":2,
"geometry":[
  9,
  1376,
  7552,
  26,
  192,
  207,
  16,
  287,
  111,
  207,
  9,
  0,
  0,
  10,
  239,
  47,
  9,
  0,
  0,
  18,
  239,
  80,
  143,
  336,
  9,
  0,
  0,
  26,
  208,
  288,
  144,
  48,
  176,
  0
]

现在我正在寻找一种方法来解码几何部分,但我不知道该怎么做。在 protobuf 模式中,附加到几何属性的注释说:

// Contains a stream of commands and parameters (vertices).
// A detailed description on geometry encoding is located in
// section 4.3 of the specification.

但我找不到将 uint32 数组转换为可读流的方法,我想我无法访问上述规范,但我知道如何继续。

我能否详细了解几何图形的编码方式?

感谢您的帮助

【问题讨论】:

    标签: rest here-api


    【解决方案1】:

    您能否尝试使用以下代码来解码数据。

    GsonBuilder gsonBuilder = new GsonBuilder();
                    Gson gson = gsonBuilder.registerTypeAdapter(<here-schema>.class, new AdapterTemplate<here-schema>() {
                    }).create();
    
    
                    try {
                        String jsonStr = gson.toJson(<here-schema>.parseFrom(res3));
    }
                    catch (Exception e){
                        e.printStackTrace();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-12
      • 2023-03-16
      • 1970-01-01
      相关资源
      最近更新 更多