在千米而非米中获取HERE Maps Response

时间:2019-06-21 10:25:21

标签: here-maps-rest

这里的地图路线导航指令以米为单位,我的要求是以公里为单位收集所有距离,我不想用从M到KM的简单转换来解决此问题,因为路线响应中包含方向指令,所以我必须将所有指令响应从M转换为KM。

样品响应:

    {
  "response": {
    "metaInfo": {
      "timestamp": "2019-06-21T10:50:08Z",
      "mapVersion": "8.30.97.151",
      "moduleVersion": "7.2.201923-3839",
      "interfaceVersion": "2.6.58",
      "availableMapVersion": [
        "8.30.97.151"
      ]
    },
    "route": [
      {
        "waypoint": [
          {
            "linkId": "-826632453",
            "mappedPosition": {
              "latitude": 52.5162041,
              "longitude": 13.378365
            },
            "originalPosition": {
              "latitude": 52.5159999,
              "longitude": 13.3778999
            },
            "type": "stopOver",
            "spot": 0.5384615,
            "sideOfStreet": "right",
            "mappedRoadName": "Pariser Platz",
            "label": "Pariser Platz",
            "shapeIndex": 0,
            "source": "user"
          },
          {
            "linkId": "+722940051",
            "mappedPosition": {
              "latitude": 52.5206638,
              "longitude": 13.3861149
            },
            "originalPosition": {
              "latitude": 52.5205999,
              "longitude": 13.3861999
            },
            "type": "stopOver",
            "spot": 0.4634146,
            "sideOfStreet": "right",
            "mappedRoadName": "Reichstagufer",
            "label": "Reichstagufer",
            "shapeIndex": 15,
            "source": "user"
          }
        ],
        "mode": {
          "type": "fastest",
          "transportModes": [
            "car"
          ],
          "trafficMode": "enabled",
          "feature": []
        },
        "leg": [
          {
            "start": {
              "linkId": "-826632453",
              "mappedPosition": {
                "latitude": 52.5162041,
                "longitude": 13.378365
              },
              "originalPosition": {
                "latitude": 52.5159999,
                "longitude": 13.3778999
              },
              "type": "stopOver",
              "spot": 0.5384615,
              "sideOfStreet": "right",
              "mappedRoadName": "Pariser Platz",
              "label": "Pariser Platz",
              "shapeIndex": 0,
              "source": "user"
            },
            "end": {
              "linkId": "+722940051",
              "mappedPosition": {
                "latitude": 52.5206638,
                "longitude": 13.3861149
              },
              "originalPosition": {
                "latitude": 52.5205999,
                "longitude": 13.3861999
              },
              "type": "stopOver",
              "spot": 0.4634146,
              "sideOfStreet": "right",
              "mappedRoadName": "Reichstagufer",
              "label": "Reichstagufer",
              "shapeIndex": 15,
              "source": "user"
            },
            "length": 953,
            "travelTime": 234,
            "maneuver": [
              {
                "position": {
                  "latitude": 52.5162041,
                  "longitude": 13.378365
                },
                "instruction": "Head <span class=\"heading\">east</span> on <span class=\"street\">Pariser Platz</span>. <span class=\"distance-description\">Go for <span class=\"length\">119 m</span>.</span>",
                "travelTime": 45,
                "length": 119,
                "id": "M1",
                "_type": "PrivateTransportManeuverType"
              },
              {
                "position": {
                  "latitude": 52.5162792,
                  "longitude": 13.3795345
                },
                "instruction": "Continue on <span class=\"next-street\">Unter den Linden</span>. <span class=\"distance-description\">Go for <span class=\"length\">90 m</span>.</span>",
                "travelTime": 55,
                "length": 90,
                "id": "M2",
                "_type": "PrivateTransportManeuverType"
              },
              {
                "position": {
                  "latitude": 52.5163651,
                  "longitude": 13.3808541
                },
                "instruction": "Turn <span class=\"direction\">left</span> onto <span class=\"next-street\">Wilhelmstraße</span> <span class=\"number\">(B2)</span>. <span class=\"distance-description\">Go for <span class=\"length\">193 m</span>.</span>",
                "travelTime": 40,
                "length": 193,
                "id": "M3",
                "_type": "PrivateTransportManeuverType"
              },
              {
                "position": {
                  "latitude": 52.5180817,
                  "longitude": 13.3804572
                },
                "instruction": "Continue on <span class=\"next-street\">Wilhelmstraße</span>. <span class=\"distance-description\">Go for <span class=\"length\">95 m</span>.</span>",
                "travelTime": 20,
                "length": 95,
                "id": "M4",
                "_type": "PrivateTransportManeuverType"
              },
              {
                "position": {
                  "latitude": 52.5189292,
                  "longitude": 13.3802962
                },
                "instruction": "Turn <span class=\"direction\">right</span> onto <span class=\"next-street\">Reichstagufer</span>. <span class=\"distance-description\">Go for <span class=\"length\">447 m</span>.</span>",
                "travelTime": 73,
                "length": 447,
                "id": "M5",
                "_type": "PrivateTransportManeuverType"
              },
              {
                "position": {
                  "latitude": 52.5206638,
                  "longitude": 13.3861149
                },
                "instruction": "Arrive at <span class=\"street\">Reichstagufer</span>. Your destination is on the right.",
                "travelTime": 1,
                "length": 9,
                "id": "M6",
                "_type": "PrivateTransportManeuverType"
              }
            ]
          }
        ],
        "summary": {
          "distance": 953,
          "trafficTime": 234,
          "baseTime": 215,
          "flags": [
            "noThroughRoad",
            "builtUpArea"
          ],
          "text": "The trip takes <span class=\"length\">953 m</span> and <span class=\"time\">4 mins</span>.",
          "travelTime": 234,
          "_type": "RouteSummaryType"
        }
      }
    ],
    "language": "en-us"
  }
}

0 个答案:

没有答案