Google表格中的距离 [英] Distances in google sheets

查看:86
本文介绍了Google表格中的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组20,000个地址,我需要找出这些地址与一个设置的地址之间的距离. 该程序可以正常工作,但是我仍然遇到一天中被调用太多次的服务"错误消息.有谁知道是否可以从Google购买更多查询"?

谢谢!

我正在使用的代码:

function DrivingMeters(origin, destination) {
  var randnumber = Math.random()*10000;
      Utilities.sleep(randnumber);
  var directions = Maps.newDirectionFinder()
  .setOrigin(origin)
  .setDestination(destination)
  .getDirections();
  return directions.routes[0].legs[0].distance.value;
}

function DrivingMiles(origin, destination) {
  return DrivingMeters(origin, destination)/1609.34;  
}

function DrivingSeconds(origin, destination) {
  var directions = Maps.newDirectionFinder()
  .setOrigin(origin)
  .setDestination(destination)
  .getDirections();
  return directions.routes[0].legs[0].duration.value;  
}

function DrivingHours(origin, destination) {
  return DrivingSeconds(origin, destination)/(60*60);
}

解决方案

指查询",意思是"quota".不同的服务有不同的每日配额.可能的异常消息是:

Service invoked too many times: Calendar.这表明脚本在一天内调用了给定的服务太多次.

对于普通消费者(gmail.com),此行值得注意:

URL提取呼叫:每天20,000次

(有关所有文档,请参见此处)

在Google搜索购买更多应用脚本配额"后,没有可喜的结果.建议使用其他框架或从多个用户分配配额的一些变通办法.我的建议是考虑从消费者"级别升级到您的域的Google Apps"级别(或更高级别).

p.s.您的问题中的一些示例代码可能会有所帮助,因此我们可以缩小您尝试使用的服务的范围,以及是否有任何可能的方法可以使您的代码更高效.

I have a set of 20,000 addresses and I need to find the distance between those and a set address. The program works but I keep encountering the "service invoked too many times in one day" error message. Does anyone know if there is a way to buy more "queries" from google?

Thanks!

Code I am using:

function DrivingMeters(origin, destination) {
  var randnumber = Math.random()*10000;
      Utilities.sleep(randnumber);
  var directions = Maps.newDirectionFinder()
  .setOrigin(origin)
  .setDestination(destination)
  .getDirections();
  return directions.routes[0].legs[0].distance.value;
}

function DrivingMiles(origin, destination) {
  return DrivingMeters(origin, destination)/1609.34;  
}

function DrivingSeconds(origin, destination) {
  var directions = Maps.newDirectionFinder()
  .setOrigin(origin)
  .setDestination(destination)
  .getDirections();
  return directions.routes[0].legs[0].duration.value;  
}

function DrivingHours(origin, destination) {
  return DrivingSeconds(origin, destination)/(60*60);
}

解决方案

by referring to "queries", you mean "quota". Different services have different daily quotas. A possible exception message is:

Service invoked too many times: Calendar. This indicates that the script called the given service too many times in one day.

for a normal consumer (gmail.com), this line is notable:

URL Fetch calls: 20,000 / day

(see here for all the documentation)

After doing a google search for "buy more apps script quota", there were no promising results. some workarounds suggested using other frameworks or splitting up quota from multiple users. My suggestion would be to look into upgrading from the "Consumer" level to the "Google Apps for Your Domain" level (or higher).

p.s. some sample code in your question may help, so we can narrow down which service you are trying to use, and if there are any possible ways to make your code more efficient.

这篇关于Google表格中的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆