-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query all documents given coordinate and radius and understanding GFGeoHashQuery. #7
Comments
I do not believe that you need to use your own code for this. Just query
Firestore and stop the query after the initial fetch.
…On Sun, Sep 23, 2018 at 7:58 AM levieggert ***@***.***> wrote:
Hey first off, thanks a lot for this library. It is very handy.
I'm trying to better understand how to use GFGeoHashQuery in order to do
my own querying against Firestore.
First, I'll run through what I am trying to accomplish and provide a code
sample. Then, I will follow up with some questions.
1. What I am trying to accomplish is, given a coordinate and radius,
query all documents in Firestore that are within the radius of the given
coordinate. I only need to query Firestore once because I will grab the
user's current location and never ask for it again until the app is
re-launched.
Here is some sample code for this.
let coordinate: CLLocationCoordinate2D = some-coordinatelet metersToMile: Double = 1609.34let miles: Double = 50let meters: Double = metersToMile * miles
let geoHashQueries: Set<AnyHashable> = GFGeoHashQuery.queries(forLocation: coordinate, radius: meters)let geoHashQueriesArray: [AnyHashable] = Array(geoHashQueries)
if let queryHash = geoHashQueriesArray.first as? GFGeoHashQuery
{
let query: Query = self.eventsCollection.order(by: "g").whereField("g", isGreaterThanOrEqualTo: queryHash.startValue).whereField("g", isLessThanOrEqualTo: queryHash.endValue)
query.getDocuments { (snapshot: QuerySnapshot?, error: Error?) in
//map snapshot documents }
}
The main thing I notice is GFGeoHashQuery.queries(forLocation: coordinate,
radius: meters) can return an array of geo hash queries with 0 or more
objects.
-
Shouldn't it only return 1 geo hash?
-
If there are multiple geo hash objects, do I have to query against
Firestore with each geo hash?
-
Can multiple geo hash objects return results from Firestore?
I appreciate any feedback you can give me. After looking through your code
Geofirestore.swift I feel like I am on the right track here. Also what are
your thoughts on implementing something similar to this in GeoFirestore?
Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AaSzNuEvityrKJAXjbB7G57JvZRrc73Uks5ud6GBgaJpZM4W1u-N>
.
|
I also have this problem. I just want to have all the documents that are in the radius. |
Has anyone been able to solve this problem? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey first off, thanks a lot for this library. It is very handy.
I'm trying to better understand how to use GFGeoHashQuery in order to do my own querying against Firestore.
First, I'll run through what I am trying to accomplish and provide a code sample. Then, I will follow up with some questions.
Here is some sample code for this.
The main thing I notice is GFGeoHashQuery.queries(forLocation: coordinate, radius: meters) can return an array of geo hash queries with 0 or more objects.
Shouldn't it only return 1 geo hash?
If there are multiple geo hash objects, do I have to query against Firestore with each geo hash?
Can multiple geo hash objects return results from Firestore?
I appreciate any feedback you can give me. After looking through your code in GeoFirestore.swift I feel like I am on the right track here. Also what are your thoughts on implementing something similar to this in GeoFirestore?
Thanks
The text was updated successfully, but these errors were encountered: