Skip to content

Commit 93303f2

Browse files
Premultiply the radius buffer for distance filter?
Doing it in the function in the loop evaluates it for each iteration. https://jsperf.com/set-comparison-value-outside-of-filter/1 At least that is my understanding.
1 parent 25a06a9 commit 93303f2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/collection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export class GeoFireCollectionRef {
122122
opts = defaultOpts
123123
): Observable<GeoQueryDocument[]> {
124124
const precision = setPrecsion(radius);
125+
const radiusBuffer = radius * 1.02; // buffer for edge distances
125126
const centerHash = center.hash.substr(0, precision);
126127
const area = GeoFirePoint.neighbors(centerHash).concat(centerHash);
127128

@@ -137,7 +138,7 @@ export class GeoFireCollectionRef {
137138
.filter(val => {
138139
const lat = val[field].geopoint.latitude;
139140
const lng = val[field].geopoint.longitude;
140-
return center.distance(lat, lng) <= radius * 1.02; // buffer for edge distances;
141+
return center.distance(lat, lng) <= radiusBuffer;
141142
})
142143

143144
.map(val => {

0 commit comments

Comments
 (0)