forked from PecanProject/bety
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_paths_to_counties.rb
44 lines (29 loc) · 997 Bytes
/
add_paths_to_counties.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
RAILS_ENV='production'
require '/rails/ebi/config/environment'
require 'rvg/rvg'
include Magick
county = ARGV[0].to_i
0.upto(11) do |zoom|
if zoom == 0
conditions = "county_boundaries.zoom0skip = 0"
elsif zoom == 1
conditions = "county_boundaries.zoom1skip = 0"
else
conditions = "1 = 1"
end
p zoom
#County.first.id.upto(County.last.id) do |c|
#next if !county.blank? and c != county
c = county
path = CountyPath.new
county = County.find(c,:include => :county_boundaries, :conditions => conditions) rescue next
# next if ["Alaska", "Hawaii"].include?(county.state)
#County.find(c,:include => :county_boundaries, :conditions => conditions).each do |county|
path.zoom = zoom
path.path = county.county_boundaries.collect { |cb| cb["zoom#{zoom}x"].round(4).to_s + "," + cb["zoom#{zoom}y"].round(4).to_s }.join(" ")
path.save
county.county_paths << path
p county.id if county.id % 100 == 0
#end
#end
end