-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ independent recipes, + geolocation, + range/area/volumetric searches
- Loading branch information
Showing
33 changed files
with
197 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
h1. Geolocation Categories | ||
|
||
* basic.rb | ||
* multi_radius.rb (multiple radii) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require File.expand_path '../../../server/lib/picky', __FILE__ | ||
|
||
GeoCoords = Struct.new :id, :lat, :lng | ||
|
||
data = Picky::Index.new :people do | ||
# 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 | ||
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 | ||
|
||
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.expand_path '../../../server/lib/picky', __FILE__ | ||
|
||
GeoCoords = Struct.new :id, :lat, :lng | ||
|
||
data = Picky::Index.new :people do | ||
# 1.0 is the radius in k around which to search. | ||
# precision 1 is low precision (20% error margin), but fast | ||
# | ||
geo_categories :lat1, :lng1, 1.0, :lat_from => :lat, :lng_from => :lng | ||
geo_categories :lat10, :lng10, 10.0, :lat_from => :lat, :lng_from => :lng | ||
geo_categories :lat100, :lng100, 100.0, :lat_from => :lat, :lng_from => :lng | ||
geo_categories :lat1000, :lng1000, 1000.0, :lat_from => :lat, :lng_from => :lng | ||
end | ||
|
||
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('lat1:-33.85 lng1:150.2').ids == [] | ||
fail __FILE__ unless cities.search('lat10:-33.85 lng10:150.2').ids == [] | ||
fail __FILE__ unless cities.search('lat100:-33.85 lng100:150.2').ids == [2] | ||
fail __FILE__ unless cities.search('lat1000:-33.85 lng1000:150.2').ids == [2, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
h1. Range Categories | ||
|
||
* one_dimensional.rb (Value range search) | ||
* two_dimensional.rb (Area search) | ||
* three_dimensional.rb (Volumetric search) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require File.expand_path '../../../server/lib/picky', __FILE__ | ||
|
||
OneD = Struct.new :id, :value | ||
|
||
data = Picky::Index.new :people do | ||
# 1.0 is the range around which to search | ||
# precision 1 is low precision (20% error margin), but fast | ||
# | ||
ranged_category :value, 1.0, precision: 1 | ||
end | ||
|
||
data.replace OneD.new(1, 3.2) | ||
data.replace OneD.new(2, 1.8) | ||
data.replace OneD.new(3, 9.7) | ||
data.replace OneD.new(4, 4.1) | ||
|
||
one_d = Picky::Search.new data | ||
|
||
results = one_d.search '3.1' | ||
|
||
# p results.allocations | ||
|
||
# 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 results.ids == [4, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require File.expand_path '../../../server/lib/picky', __FILE__ | ||
|
||
ThreeD = Struct.new :id, :x, :y, :z | ||
|
||
data = Picky::Index.new :people do | ||
# 1.0 is the range around which to search | ||
# precision 1 is low precision (20% error margin), but fast | ||
# | ||
ranged_category :x, 1.0, precision: 1 | ||
ranged_category :y, 1.0, precision: 1 | ||
ranged_category :z, 1.0, precision: 1 | ||
end | ||
|
||
data.replace ThreeD.new(1, 3.2, 2.8, -8.5) | ||
data.replace ThreeD.new(2, 1.8, 0.4, 13.7) | ||
data.replace ThreeD.new(3, 9.7, 11.2, -7.0) | ||
data.replace ThreeD.new(4, 4.1, 2.2, -7.5) | ||
|
||
three_d = Picky::Search.new data | ||
|
||
# Since the x, y and z coordinates are not | ||
# disjunct, we have to specify which is which. | ||
# | ||
results = three_d.search 'x:3.1 y:2.4 z:-8.0' | ||
|
||
# p results.allocations | ||
|
||
# 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 results.ids == [4, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require File.expand_path '../../../server/lib/picky', __FILE__ | ||
|
||
TwoD = Struct.new :id, :x, :y | ||
|
||
data = Picky::Index.new :people do | ||
# 1.0 is the range around which to search | ||
# precision 1 is low precision (20% error margin), but fast | ||
# | ||
ranged_category :x, 1.0, precision: 1 | ||
ranged_category :y, 1.0, precision: 1 | ||
end | ||
|
||
data.replace TwoD.new(1, 3.2, 2.8) | ||
data.replace TwoD.new(2, 1.8, 0.4) | ||
data.replace TwoD.new(3, 9.7, 11.2) | ||
data.replace TwoD.new(4, 4.1, 2.2) | ||
|
||
two_d = Picky::Search.new data | ||
|
||
# Since the x and y coordinates are not | ||
# disjunct, we have to specify which is which. | ||
# | ||
results = two_d.search 'x:3.1 y:2.4' | ||
|
||
# p results.allocations | ||
|
||
# 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 results.ids == [4, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
Person = Struct.new :id, :first, :last | ||
|
||
Dir['**/*.rb'].each { |file| require File.expand_path "../#{file}", __FILE__ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters