Skip to content

Commit e49e5ff

Browse files
authored
Merge pull request #65 from LiamKarlMitchell/patch-3
Premultiply the radius buffer for distance filter?
2 parents 43fb2f5 + 93303f2 commit e49e5ff

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
@@ -130,6 +130,7 @@ export class GeoFireCollectionRef<T> {
130130
opts = defaultOpts
131131
): Observable<(GeoQueryDocument & T)[]> {
132132
const precision = setPrecsion(radius);
133+
const radiusBuffer = radius * 1.02; // buffer for edge distances
133134
const centerHash = center.hash.substr(0, precision);
134135
const area = GeoFirePoint.neighbors(centerHash).concat(centerHash);
135136

@@ -145,7 +146,7 @@ export class GeoFireCollectionRef<T> {
145146
.filter(val => {
146147
const lat = val[field].geopoint.latitude;
147148
const lng = val[field].geopoint.longitude;
148-
return center.distance(lat, lng) <= radius * 1.02; // buffer for edge distances;
149+
return center.distance(lat, lng) <= radiusBuffer;
149150
})
150151

151152
.map(val => {

0 commit comments

Comments
 (0)