firebase / geofire-objc

GeoFire for Objective-C - Realtime location queries with Firebase
MIT License
435 stars 176 forks source link

GFUtils.queryBounds radius unit inconsistent #158

Closed chFlorian closed 3 years ago

chFlorian commented 3 years ago

The official Firebase documentation states

let queryBounds = GFUtils.queryBounds(forLocation: center, withRadius: radiusInKilometers)

Meaning that the radius is measured in Kilometers. I have ran some tests:

  1. I created a document in Firebase Firestore with a locationHash of my current location
  2. I ran a query against my current location:
    let queryBounds = GFUtils.queryBounds(forLocation: currentLocation.coordinate, withRadius: radius)
    let queries = queryBounds.compactMap { bound -> Query? in
    store
        .collection("dummy-documents")
        .order(by: "locationHash")
        .start(at: [bound.startValue])
        .end(at: [bound.endValue])
    }
  3. When the radius is set to a value below 10, no document is returned. To factor out GPS-precision being low (because I am inside a house), I ran multiple tests with slightly different currentLocations (all within ~10 Meters of my current real location)
  4. Only once the radius is set to 10, the document showed up.
  5. I then added another document with a locationHash about 140 Meters away.
  6. This document does not get returned with radius = 10 (even though 140m < 10km)
  7. It seems to that the radius is actually measured in meters and not in Kilometers as specified.