Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
floere committed Dec 30, 2011
1 parent ce3d034 commit bea5812
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions recipes/geolocation/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@
# 1.0 is the radius in k around which to search.
# precision 1 is low precision (20% error margin), but fast
#
geo_categories :lat, :lng, 1000.0 # 1000kms radius
geo_categories :lat, :lng, 1000.0, precision: 1 # 1000kms radius
end
cities = Picky::Search.new data

data.replace GeoCoords.new(1, -37.813611, 144.963056) # Melbourne
data.replace GeoCoords.new(2, -33.859972, 151.211111) # Sydney
data.replace GeoCoords.new(3, 47.366667, 8.55) # Zurich
data.replace GeoCoords.new(4, 41.9, 12.5) # Rome

cities = Picky::Search.new data

# Picky just returns results in range, not ordered
# by distance. Usually that is fine for showing results
# in a graph or on a map.
#
fail __FILE__ unless cities.search('lat:-33.85 lng:150.2').ids == [2, 1]

# Extra fun action: Suddenly, Sydney teleports next to Japan!
#
data.replace GeoCoords.new(2, 33, 150) # Sydney
fail __FILE__ unless cities.search('lat:-33.85 lng:150.2').ids == [1]
2 changes: 1 addition & 1 deletion recipes/geolocation/multi_radius.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GeoCoords = Struct.new :id, :lat, :lng

data = Picky::Index.new :people do
data = Picky::Index.new :cities do
# 1.0 is the radius in k around which to search.
# precision 1 is low precision (20% error margin), but fast
#
Expand Down
2 changes: 1 addition & 1 deletion recipes/range/one_dimensional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

OneD = Struct.new :id, :value

data = Picky::Index.new :people do
data = Picky::Index.new :values do
# 1.0 is the range around which to search
# precision 1 is low precision (20% error margin), but fast
#
Expand Down
2 changes: 1 addition & 1 deletion recipes/range/three_dimensional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ThreeD = Struct.new :id, :x, :y, :z

data = Picky::Index.new :people do
data = Picky::Index.new :locations do
# 1.0 is the range around which to search
# precision 1 is low precision (20% error margin), but fast
#
Expand Down
2 changes: 1 addition & 1 deletion recipes/range/two_dimensional.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TwoD = Struct.new :id, :x, :y

data = Picky::Index.new :people do
data = Picky::Index.new :coords do
# 1.0 is the range around which to search
# precision 1 is low precision (20% error margin), but fast
#
Expand Down

0 comments on commit bea5812

Please sign in to comment.