Skip to content

Commit

Permalink
Merge commit 'e8ada9b71b916e7f891f2b3b0d82d51fe61ad1f3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Simple Geebus committed Jun 16, 2011
2 parents 9209396 + e8ada9b commit 20d0509
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion demos/cli.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'geocoder/us/database'
require 'pp'

db = Geocoder::US::Database.new("/mnt/geocoder-us/geocoder.db", :debug=>true)
db = Geocoder::US::Database.new("/mnt/tiger2010/geocoder.db", :debug=>true)
result = db.geocode(ARGV[0])
pp(result)
print "#{result[0][:lat]} N, #{-result[0][:lon]} W\n"
5 changes: 4 additions & 1 deletion lib/geocoder/us/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ def interpolate (points, fraction, side, offset=0.000075)
(1...points.length).each {|n| total += distance(points[n-1], points[n])}
target = total * fraction
for n in 1...points.length
next if points[n-1] == points[n] # because otherwise step==0 and dx/dy==NaN
step = distance(points[n-1], points[n])
if step < target
target -= step
Expand All @@ -582,7 +583,9 @@ def interpolate (points, fraction, side, offset=0.000075)
return street_side_offset(offset*side, points[n-1], found)
end
end
# raise "Can't happen!"
# in a pathological case, points[n-1] == points[n] for n==-1
# so *sigh* just forget interpolating and return points[-1]
return points[-1]
end

# Find and replace the city, state, and county information
Expand Down

0 comments on commit 20d0509

Please sign in to comment.