以下脚本对我来说很好,但是在获取一些记录(通常是100条记录)之后,它失败并给我错误: -
Invalid JSON string
有时在获取大约500条记录后,它会停止获取坐标。 我需要对18000个坐标进行任何建议吗?
task :populate_geolocations_reverse => :environment do
AdvocateDetail.order("id DESC").all.each do |advocate|
p advocate.id
if advocate.latitude.nil? or advocate.latitude==0 or advocate.latitude=="0"
p "fetching geolocations...:-( "
a = Geocoder.fetch_coordinates(advocate.address)
unless a.nil?
p "got geolocations... :-) "
advocate.latitude=a[0]
advocate.longitude=a[1]
p "saving geolocations...:-P "
advocate.save(false)
end
else
p " already have geolocations for this Jumped....:-)"
end
end
p "transformation done... "
end
答案 0 :(得分:0)
请记住,谷歌有限制来满足您的要求。每天大约有1000个独特请求,每秒1个。据我所知,Geokit使用的服务多于谷歌本身,但它仍然可能有限。仔细看看。