首页 > 解决方案 > 号有没有限制。我可以在循环中进行的 HERE API 调用(使用 R)

问题描述

我正在尝试遍历原始目的地经纬度位置列表以获取运输时间。循环时出现以下错误。但是,当我进行一次调用(不循环)时,我得到一个没有错误的输出。我使用免费增值的 HERE-API,每月可以进行 25 万笔交易。

 `for (i in 1:nrow(test))        
   { 
            call <- paste0("https://route.api.here.com/routing/7.2/calculateroute.json",
                           "?app_id=","appid",
                           "&app_code=","appcode",
                           "&waypoint0=geo!",y$dc_lat[i],",",y$dc_long[i],
                           "&waypoint1=geo!",y$store_lat[i],",",y$store_long[i],
                           "&mode=","fastest;truck;traffic:enabled",
                           "&trailerscount=","1",
                           "&routeattributes=","sh",
                           "&maneuverattributes=","di,sh",
                           "&limitedweight=","20")

                  response <-fromJSON(call, simplify = TRUE)
            Traffic_time = (response[["response"]][["route"]][[1]][["summary"]][["trafficTime"]]) / 60
            Base_time = (response[["response"]][["route"]][[1]][["summary"]][["baseTime"]]) / 60
            print(Traffic_time)
}`

Error in file(con, "r"): cannot open the connection to 'https://route.api.here.com/routing/7.2/calculateroute.json?app_id=appid&app_code=appcode&waypoint0=geo!45.1005200,-93.2452000&waypoint1=geo!45.0978500,-95.0413620&mode=fastest;truck;traffic:enabled&trailerscount=1&routeattributes=sh&maneuverattributes=di,sh&limitedweight=20' Traceback:

标签: rhere-apirjsonio

解决方案


根据错误,这表明您最后的文件存在问题。它可能已损坏,最好尝试更改文件的扩展名。也可以尝试重启你的IDE。API 调用的数量取决于您选择免费增值计划或专业计划的计划。您可以了解更多详细信息:https ://developer.here.com/faqs


推荐阅读