1

I'm new in Android Developing and will greatly appreciate any guidance. I would like to know if there is a way to decode the GeoHashes generated by GeoFire when saving coordinates to Firebase. I don't see services from GeoFire that decode the coordinates to get only the Latitude or the Longitude. If there is a library for that please let me know, I'm stuck in a project, doing lots of research but don't find anything valuable yet. Thanks again!

Database

----------------CODE SNIPPET-------------------------

DatabaseReference mUser;
GeoFire geoFire;
FirebaseUser mFirebase;

Marker mCurrent;
Circle mPerimeter;
SupportMapFragment mapFragment;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    // SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
    mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);


    //Init View

    //-------AUTHENTICATION--------------
    FirebaseAuth mAuth = FirebaseAuth.getInstance();
    String userID;
    userID = mAuth.getCurrentUser().getUid();

    //-------AUTHENTICATION--------------

    startLocationUpdates();
    displayLocation();
    Snackbar.make(mapFragment.getView(), "You are online",Snackbar.LENGTH_SHORT)
            .show(); 

    //--------SEND COORDINATES TO FIREBASE-------------
    mUser = FirebaseDatabase.getInstance().getReference().child("Location");

    geoFire =new GeoFire(mUser);
    //--------SEND COORDINATES TO FIREBASE-------------

    //------------------LOOKING FOR INSTRUCTIONS TO QUERY USERS LATITUDE OR LONGITUDE AND SAVE THEM TO A LOCAL VARIABLE

    double latitude;
    double longitude;

    latitude =

    longitude=

    //------------------LOOKING FOR INSTRUCTIONS TO QUERY USERS LATITUDE OR LONGITUDE AND SAVE THEM TO A LOCAL VARIABLE

    setUpLocation();

}

    //Press Ctrl + O to override
    //Request runtime permissions and override OnRequestPermissionResult method

----------------CODE SNIPPET-------------------------

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
BBQCoder
  • 13
  • 4
  • This sounds a bit like a [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). What are you trying to accomplish here? Can you show the [minimal code that reproduces where you are stuck](http://stackoverflow.com/help/mcve) (read the link please, it's useful)? If you want to learn more about geohashes and what they contain, see https://www.youtube.com/watch?v=mx1mMdHBi5Q – Frank van Puffelen Jan 27 '19 at 04:55
  • I added two pictures to the original message. One contains a snippet of the code and the other a picture of the database. Don't know if that is enough info to reproduce where I'm stuck, let me know if you need anything more. What I just would like to know is if there is an instruction to decode the geohash and obtain the (Latitude only) or (Longitude only). I want to store the value in a local variable, then send it to another node. I don't want to alter the original data produced by GeoFire, just copy the values below USERS. My goal, have only one value in one field to normalize data. – BBQCoder Jan 27 '19 at 18:58
  • Please replace both with the actual text, so that it's searchable, and can be copy/pasted. For the JSON, you can get this by clicking the "Export JSON" link in the overflow menu (⠇) on your [Firebase Database console](https://console.firebase.google.com/project/_/database/data). – Frank van Puffelen Jan 27 '19 at 20:50
  • I replaced the section of the code with the actual text. As for the JSON, I read that it is not a good idea to share it publicly as it contains credentials. – BBQCoder Jan 27 '19 at 22:44
  • The screenshot you have left is from your database, and that's what I'm referring to. The only unique ID I see in there, are [UIDs and those are not secrets](https://stackoverflow.com/q/37221760). Even if they were, a malicious user can just as easily get those values from your screenshot, while the friendly developer trying to help is hindered by it. Finally: if you are really worried about sharing certain details, sharing the JSON as text allows you to simply replace them with random values in your question question. – Frank van Puffelen Jan 27 '19 at 23:52
  • I really appreciate your help Frank, thanks for taking interest in my problem. I see that the geohash field is an array, with index [0] storing Latitude and index [1] storing Longitude. Would it be possible to give me an example of the syntax I need to capture index [0] in a query? If not, can you suggest me a good source to learn how to query nested fields in Firebase? I'm used to relational database systems and feel very lost with Firebase Data Structure. Thanks again. – BBQCoder Jan 28 '19 at 00:47

0 Answers0