Skip to content

How to replace firestore geofire with h3? #167

@mailinger-mate

Description

@mailinger-mate

Hello!

I am using the recommended Geofire library with the Firestore to save documents and query collections using Geohash:
https://firebase.google.com/docs/firestore/solutions/geoqueries

I have read through the issues of #100 and uber/h3#410 on using H3 with Firestore and the H3 Index structure but I still need your help with replacing the Geohash solution with H3 indexes.

I think my use case is simpler than the issues above, because I simply would like to save H3 indexes at resolution 9 on my documents, like this

setDoc(doc(db, 'stores'), { h3: '8965812cb23ffff' }); 

and just run queries to get a collection of documents that are within a hexagon at various higher resolutions:

db.collection('stores').orderBy('h3').startAt('8365aafffffffff').endAt('?');

This way I can aggregate the document count with Firestore and display the number per hexagon on a map depending on the selected location and resolution.

Could you please help me understand how could I derive the correct startAt and endAt values from a location and resolution to use them in aggregate Firestore queries?

Thank you,
Mate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions