imperiumlabs / GeoFirestore-iOS

GeoFirestore for iOS - Realtime location queries with Firestore
MIT License
127 stars 46 forks source link

Simple, and highly useful feature request #5

Closed swafsarl closed 5 years ago

swafsarl commented 6 years ago

Hello, i already use Geofire With Firebase Realtime database on android and i don't know why on android there is the "data event" feature ( https://github.com/imperiumlabs/GeoFirestore-Android#data-events ) and not present on iOS. I really need the data in the whole document not only the Location.

In fact i have many other parameter in the document where i set the geofire location., and when i execute a query to find who is in a certain geoCircle, i still need to check if those "returned results" comply with the other criterias

My question is: are you planning on adding "data events" support for iOS ? other wise i will have to retrieve all document ID and do a firestore query with every single id to check if those documents comply with the other criterias than location. And according to firstore pricing scheme, u know this way of doing this is a deal breaker. I am waiting for response. Keep up the good work

Cheers

swafsarl commented 6 years ago

i think u may just update this: internal func childAdded(_ snapshot: DocumentSnapshot?)

rtemple6 commented 6 years ago

@swafsarl I would also be interested in this feature. If there is some way I can contribute I would love to help! 👍

swafsarl commented 6 years ago

Hello, in fact, i have found a workaround based on GeoFirestore code, here what i did: https://pastebin.com/Bz1YJLgZ

Don't forget to import GeoFire in order to use GFGeoHashQuery I have copied the GeoFirestore.swift in my project folder.

Well, it works, but i havent spent more time on this task, but we could of course clean the code and get rid of the queries?.forEach

But it does the job, of course, for every change we receive all the items in the mentioned Radius around the center location. While GeoFire tries to only send incremental updates.

dhruvshah1214 commented 6 years ago

If you have a clean solution, we humbly request that you fork the repo and submit a pull request to help out the community.

RvAgrawal commented 6 years ago

I have done some changes in geofirestore.swift file.

internal func fireStoreQueryForGeoHashQuery(query: GFGeoHashQuery) -> Query {
var queryFireStore : Query?
queryFireStore = self.myGeofirestore.query
            queryFireStore = queryFireStore?.order(by: "g")
queryFireStore = queryFireStore?.order(by: PUBLISHED_DATE_TIME, descending: true)

            queryFireStore = queryFireStore?.whereField("g", isGreaterThanOrEqualTo: query.startValue).whereField("g", isLessThanOrEqualTo: query.endValue)
return queryFireStore!
}

I have also change public typealias GFSQueryResultBlock = (String?, CLLocation?, DocumentSnapshot?) -> Void to get whole document and these changes working fine.

I am facing issue in result data, like i am passing radius of 10 Km, in a result it displays the data greater than that radius.

If anyone can help me it will be great help. Thanks in advance.

swafsarl commented 6 years ago

response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} The Link between degrees and km dépends on where you are located on earth. When u say "greater", how greater It is? Like thé error is about 1% ? 5% ? 10% ? In other words, when u say 10km radius It is merely aproximative distance.  Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 14:54À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5) I have done some changes in geofirestore.swift file.

internal func fireStoreQueryForGeoHashQuery(query: GFGeoHashQuery) -> Query { var queryFireStore : Query? queryFireStore = self.myGeofirestore.query             queryFireStore = queryFireStore?.order(by: "g") queryFireStore = queryFireStore?.order(by: PUBLISHED_DATE_TIME, descending: true)                         queryFireStore = queryFireStore?.whereField("g", isGreaterThanOrEqualTo: query.startValue).whereField("g", isLessThanOrEqualTo: query.endValue) return queryFireStore! }

I have also change public typealias GFSQueryResultBlock = (String?, CLLocation?, DocumentSnapshot?) -> Void to get whole document and these changes working fine. I am facing issue in result data, like i am passing radius of 10 Km, in a result it displays the data greater than that radius. If anyone can help me it will be great help. Thanks in advance.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

RvAgrawal commented 6 years ago

response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} The Link between degrees and km dépends on where you are located on earth. When u say "greater", how greater It is? Like thé error is about 1% ? 5% ? 10% ? In other words, when u say 10km radius It is merely aproximative distance.  Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 14:54À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5) I have done some changes in geofirestore.swift file. internal func fireStoreQueryForGeoHashQuery(query: GFGeoHashQuery) -> Query { var queryFireStore : Query? queryFireStore = self.myGeofirestore.query             queryFireStore = queryFireStore?.order(by: "g") queryFireStore = queryFireStore?.order(by: PUBLISHED_DATE_TIME, descending: true)                         queryFireStore = queryFireStore?.whereField("g", isGreaterThanOrEqualTo: query.startValue).whereField("g", isLessThanOrEqualTo: query.endValue) return queryFireStore! } I have also change public typealias GFSQueryResultBlock = (String?, CLLocation?, DocumentSnapshot?) -> Void to get whole document and these changes working fine. I am facing issue in result data, like i am passing radius of 10 Km, in a result it displays the data greater than that radius. If anyone can help me it will be great help. Thanks in advance. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

Thank you for the quick reply. The location is 25Km away than the current location, and if I set radius of 10Km to my current location and fire a query, that 25Km location is also displaying :-(

swafsarl commented 6 years ago

response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} Seems It is displaying all thé locations available ignoring thé location. Am i wrong ? Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 15:31À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5)

response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} The Link between degrees and km dépends on where you are located on earth. When u say "greater", how greater It is? Like thé error is about 1% ? 5% ? 10% ? In other words, when u say 10km radius It is merely aproximative distance.  Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 14:54À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5) I have done some changes in geofirestore.swift file. internal func fireStoreQueryForGeoHashQuery(query: GFGeoHashQuery) -> Query { var queryFireStore : Query? queryFireStore = self.myGeofirestore.query             queryFireStore = queryFireStore?.order(by: "g") queryFireStore = queryFireStore?.order(by: PUBLISHED_DATE_TIME, descending: true)                         queryFireStore = queryFireStore?.whereField("g", isGreaterThanOrEqualTo: query.startValue).whereField("g", isLessThanOrEqualTo: query.endValue) return queryFireStore! } I have also change public typealias GFSQueryResultBlock = (String?, CLLocation?, DocumentSnapshot?) -> Void to get whole document and these changes working fine. I am facing issue in result data, like i am passing radius of 10 Km, in a result it displays the data greater than that radius. If anyone can help me it will be great help. Thanks in advance. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

Thank you for the quick reply. The location is 25Km far than the current location, and if I set radius 10Km on my current location and fire a query that 25Km location is also displaying.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

RvAgrawal commented 6 years ago

response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} Seems It is displaying all thé locations available ignoring thé location. Am i wrong ? Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 15:31À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5) #response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} The Link between degrees and km dépends on where you are located on earth. When u say "greater", how greater It is? Like thé error is about 1% ? 5% ? 10% ? In other words, when u say 10km radius It is merely aproximative distance.  Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 14:54À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5) I have done some changes in geofirestore.swift file. internal func fireStoreQueryForGeoHashQuery(query: GFGeoHashQuery) -> Query { var queryFireStore : Query? queryFireStore = self.myGeofirestore.query             queryFireStore = queryFireStore?.order(by: "g") queryFireStore = queryFireStore?.order(by: PUBLISHED_DATE_TIME, descending: true)                         queryFireStore = queryFireStore?.whereField("g", isGreaterThanOrEqualTo: query.startValue).whereField("g", isLessThanOrEqualTo: query.endValue) return queryFireStore! } I have also change public typealias GFSQueryResultBlock = (String?, CLLocation?, DocumentSnapshot?) -> Void to get whole document and these changes working fine. I am facing issue in result data, like i am passing radius of 10 Km, in a result it displays the data greater than that radius. If anyone can help me it will be great help. Thanks in advance. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread. Thank you for the quick reply. The location is 25Km far than the current location, and if I set radius 10Km on my current location and fire a query that 25Km location is also displaying. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

No actually if set radius to 8Km and fire a query then that location is not coming in result.. so query is working but not perfectly.

swafsarl commented 6 years ago

response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} Than maybe It is really thé ratio between km and degrees thé problem.  Try to trigger a query for 1km and see "till when" It will show results. So u can see thé ratio between km and degrees.  Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 4:25 PMÀ: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5)

response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} Seems It is displaying all thé locations available ignoring thé location. Am i wrong ? Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 15:31À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5) #response_container_BBPPID{font-family: initial; font-size:initial; color: initial;} The Link between degrees and km dépends on where you are located on earth. When u say "greater", how greater It is? Like thé error is about 1% ? 5% ? 10% ? In other words, when u say 10km radius It is merely aproximative distance.  Envoyé de mon BlackBerry - l'appareil mobile le plus sécurisé De: notifications@github.comEnvoyé: 17 septembre 2018 14:54À: GeoFirestore-iOS@noreply.github.comRépondre à: reply@reply.github.comCc: info@swaf.ch; mention@noreply.github.comObjet: Re: [imperiumlabs/GeoFirestore-iOS] Simple, and highly useful feature request (#5) I have done some changes in geofirestore.swift file. internal func fireStoreQueryForGeoHashQuery(query: GFGeoHashQuery) -> Query { var queryFireStore : Query? queryFireStore = self.myGeofirestore.query             queryFireStore = queryFireStore?.order(by: "g") queryFireStore = queryFireStore?.order(by: PUBLISHED_DATE_TIME, descending: true)                         queryFireStore = queryFireStore?.whereField("g", isGreaterThanOrEqualTo: query.startValue).whereField("g", isLessThanOrEqualTo: query.endValue) return queryFireStore! } I have also change public typealias GFSQueryResultBlock = (String?, CLLocation?, DocumentSnapshot?) -> Void to get whole document and these changes working fine. I am facing issue in result data, like i am passing radius of 10 Km, in a result it displays the data greater than that radius. If anyone can help me it will be great help. Thanks in advance. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread. Thank you for the quick reply. The location is 25Km far than the current location, and if I set radius 10Km on my current location and fire a query that 25Km location is also displaying. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

No actually if set radius to 8Km and fire a query then that location is not coming in result.. so query is working but not perfectly.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

Gokugokuman commented 6 years ago

Regarding the query radius issue posted above, I had a similar problem of getting all the location ignoring the search radius. I modified the updateLocationInfo function as follows, and it is working fine now. info?.isInQuery != nil --> info?.isInQuery == true

scm573 commented 5 years ago

Hi @RvAgrawal

Sorry did you work it out? Have you tried @Gokugokuman's suggestion?

scm573 commented 5 years ago

OK so I just tried based on what you guys discussed, changed the type of GFSQueryResultBlock from String(DocumentID) to DocumentSnapshot, and fixed the "isInQuery" check: https://github.com/scm573/GeoFirestore-iOS/pull/1/files Pretty enough for our team now but I cannot say it would fit everyone's requirements...

RvAgrawal commented 5 years ago

@scm573 Yes issue resolved now.. Thanks.