Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Update location without remove data #134

Open
inromualdo opened this issue Mar 30, 2018 · 12 comments
Open

Update location without remove data #134

inromualdo opened this issue Mar 30, 2018 · 12 comments

Comments

@inromualdo
Copy link

I have this:

"_id": {
   l: [],
   g: "ede45",
   username: "romuald",
   other: 5
}

If i call setLocation to update location, it will remove username and other.

@samtstern
Copy link
Contributor

@inromualdo thanks for the suggestion.

It does seem like here:
https://github.com/firebase/geofire-java/blob/master/common/src/main/java/com/firebase/geofire/GeoFire.java#L174-L182

We use setValue but we could use updateChildren.

@vanniktech am I being dumb? Is there a reason why updateChildren would not be appropriate here?

@vanniktech
Copy link
Contributor

Good question. Honestly I have no idea since I've never used Geofire for writing.

@inromualdo
Copy link
Author

Can we add updateLocation method?

@puf
Copy link

puf commented Mar 31, 2018

There is no way to store additional information about objects in the same location as the geohashes. If you need to store additional information, store it in a separate node with the same key as you use in Geofire.

@inromualdo
Copy link
Author

But why this listener GeoQueryDataEventListener?
I store additional information in the same location as the geohashes and every thing work well.
Now, i need to update the geohashes.

@vanniktech
Copy link
Contributor

It says that the new API is read only.

@m7mdyahia
Copy link

In the Read me:

https://github.com/firebase/geofire-java#data-events

If you are storing model data and geo data in the same database location, you may want access to the DataSnapshot as part of geo events. In this case, use a GeoQueryDataEventListener rather than a key listener.
what does this mean?

@samtstern
Copy link
Contributor

@m7mdyahia traditionally GeoFire stores the geo information at a separate location from the actual data. Some users override this and store the geo information and the data together. In these cases they can use the other kind of listener to get a full DataSnapshot for geo queries rather than just a String for the key.

jwiesmann pushed a commit to jwiesmann/geofire-java that referenced this issue Sep 1, 2018
…ad of keyRef.setValue also fixes a huge amount of unnecessary 'onDataExited(DataSnapshot dataSnapshot)' events which has not been reported yet. keyRef.updateChildren understands if the data needs to be inserted or updated. No need to use setValue here. Since priorities are not relevant anymore (https://stackoverflow.com/questions/31577915/what-does-priority-mean-in-firebase) i decided to not consider them anymore.
@mcg95
Copy link

mcg95 commented May 2, 2019

@samtstern Is @jwiesmann 's pull request going to be merged anytime soon? It was submitted by jwiesmann on the 1st of Sept. Swift/Obj-C and JS are getting updated regularly though.

@samtstern
Copy link
Contributor

samtstern commented May 2, 2019

@mcg95 I would like to merge that PR but we basically have a big, fundamental problem in geofire-java right now. The library was built to serve Java Server and Android Java users at the same time. It relied on a coincidence: the Android and Java SDKs for Firebase RTDB had all the same signatures.

This is no longer true. The Android and Java Admin SDKs have diverged (for good reasons) so this can no longer be one library.

Before we can really make any more improvements, we have to split the whole library up into geofire-java and geofire-android. I have not had time to do this yet.

@mcg95
Copy link

mcg95 commented May 9, 2019

@samtstern Oh okay. Is there any approximate ETA for the release of this? Maybe 1 or 2 months?

@NONOLGG
Copy link

NONOLGG commented Jun 13, 2020

This is the solution I adopted for this :
You can generate the geHash from your code and set the value from the node directly in the firebase.
GeoHash geoHash = new GeoHash(location);
ref.child("g").setValue(geoHash.getGeoHashString());
ref.child("l").setValue(Arrays.asList(location.latitude, location.longitude));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants