Skip to content
Browse files

.

  • Loading branch information...
1 parent ce3d034 commit bea58124d8aeddec1660fcf1836c0d4b24d8d19d @floere committed
View
10 recipes/geolocation/basic.rb
@@ -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]
View
2 recipes/geolocation/multi_radius.rb
@@ -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
#
View
2 recipes/range/one_dimensional.rb
@@ -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
#
View
2 recipes/range/three_dimensional.rb
@@ -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
#
View
2 recipes/range/two_dimensional.rb
@@ -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
#

0 comments on commit bea5812

Please sign in to comment.
Something went wrong with that request. Please try again.