geomodel 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/geomodel.rb +10 -10
- data/lib/geomodel/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 568cca72a146050ca2778a4bb8e0f5717bdb14ba
|
4
|
+
data.tar.gz: 5442b3cd80c73256afebec260de8081f53871194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 846bb9fa6bc8d79950c48f01b5a73441de130e231a7737ebd7dc28d50257dc9ad7535669deea89f9a0a0f70cb697408d075f1c8dba9937143f598f0351ad40a1
|
7
|
+
data.tar.gz: 0f1dcaadb4eb6b74927fef71b2b079b5c2b705981bb6073436909778aee2102db777b675b7918429f1fa2f6e578693d62fdf423195f6686aa21bdefd8f320dd7
|
data/CHANGELOG.md
CHANGED
@@ -2,4 +2,7 @@
|
|
2
2
|
* Initial release - Straight port from Python, Java and JS implementations
|
3
3
|
|
4
4
|
### 0.0.2 (January 5, 2014)
|
5
|
-
* Upped the test coverage (which revealed some pretty blatant bugs)
|
5
|
+
* Upped the test coverage (which revealed some pretty blatant bugs)
|
6
|
+
|
7
|
+
### 0.0.3 (January 6, 2014)
|
8
|
+
* Cleaned up more bugs in proximity search after testing with Cassandra demo app
|
data/lib/geomodel.rb
CHANGED
@@ -74,7 +74,7 @@ module Geomodel
|
|
74
74
|
(!x.empty? && !y.empty?) ? x[1] <=> y[1] : 0
|
75
75
|
end
|
76
76
|
|
77
|
-
dup_fn = lambda do |x|
|
77
|
+
dup_fn = lambda do |x|
|
78
78
|
(x.nil? || x.empty?) ? nil : x[0].id
|
79
79
|
end # assuming the the element responds to #id
|
80
80
|
|
@@ -84,24 +84,24 @@ module Geomodel
|
|
84
84
|
while !cur_geocells.empty?
|
85
85
|
closest_possible_next_result_dist = sorted_edge_distances[0]
|
86
86
|
|
87
|
-
|
87
|
+
break if max_distance && closest_possible_next_result_dist > max_distance
|
88
88
|
|
89
89
|
cur_geocells_unique = cur_geocells - searched_cells.to_a
|
90
|
-
|
90
|
+
|
91
91
|
# Run query on the next set of geocells.
|
92
92
|
cur_resolution = cur_geocells[0].size
|
93
|
-
|
93
|
+
|
94
94
|
# Update results and sort.
|
95
95
|
new_results = query_runner.call(cur_geocells_unique)
|
96
|
-
|
96
|
+
|
97
97
|
searched_cells.merge(cur_geocells)
|
98
|
-
|
98
|
+
|
99
99
|
# Begin storing distance from the search result entity to the
|
100
100
|
# search center along with the search result itself, in a tuple.
|
101
101
|
new_results = new_results.map { |entity| [entity, Geomodel::Math.distance(center, entity.location)] }
|
102
102
|
new_results.sort! { |x, y| (!x.empty? && !y.empty?) ? x[1] <=> y[1] : 0 }
|
103
103
|
new_results = new_results[0...max_results]
|
104
|
-
|
104
|
+
|
105
105
|
# Merge new_results into results or the other way around, depending on
|
106
106
|
# which is larger.
|
107
107
|
if results.size > new_results.size
|
@@ -112,7 +112,7 @@ module Geomodel
|
|
112
112
|
end
|
113
113
|
|
114
114
|
results = results[0...max_results]
|
115
|
-
|
115
|
+
|
116
116
|
sorted_edges, sorted_edge_distances = Geomodel::Util.distance_sorted_edges(cur_geocells, center)
|
117
117
|
|
118
118
|
if results.empty? || cur_geocells.size == 4
|
@@ -121,7 +121,7 @@ module Geomodel
|
|
121
121
|
# geocells.
|
122
122
|
cur_containing_geocell = cur_containing_geocell[0...-1]
|
123
123
|
cur_geocells = cur_geocells.map { |cell| cell[0...-1] }
|
124
|
-
break if
|
124
|
+
break if cur_geocells.empty? || !cur_geocells[0] # Done with search, we've searched everywhere.
|
125
125
|
elsif cur_geocells.size == 1
|
126
126
|
# Get adjacent in one direction.
|
127
127
|
# TODO(romannurik): Watch for +/- 90 degree latitude edge case geocells.
|
@@ -155,4 +155,4 @@ module Geomodel
|
|
155
155
|
results[0...max_results].keep_if { |result| max_distance == 0 || result.last < max_distance }
|
156
156
|
end
|
157
157
|
|
158
|
-
end
|
158
|
+
end
|
data/lib/geomodel/version.rb
CHANGED