Skip to content
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

getAtLocation returning an empty list #2

Open
ggutenberg opened this issue Dec 29, 2019 · 0 comments
Open

getAtLocation returning an empty list #2

ggutenberg opened this issue Dec 29, 2019 · 0 comments

Comments

@ggutenberg
Copy link

ggutenberg commented Dec 29, 2019

I've tried the following code, but it's failing to retrieve any snapshots. Using the node.js library works fine with the same center coordinates and same Firestore collection.

Working (node.js):

export const getNear = async (center: number[], radius: number) => {
  const geofirestore: GeoFirestore = new GeoFirestore(firestore);
  const geocollection: GeoCollectionReference = geofirestore.collection(
    "businesses"
  );
  const query: GeoQuery = geocollection.near({
    center: new admin.firestore.GeoPoint(center[0], center[1]),
    radius
  });
  const queryResults = await query.get();
  console.log(queryResults.docs);
  return queryResults.docs.map(doc => doc.data());
};

const getNearResponse = await business.getNear(
  [-1.7970149, -80.757148],
  1000
);

Not working (Dart):

  _populateBusinesses() async {
    final GeoFirestore geocollection =
        GeoFirestore(firestore.collection('businesses'));
    final queryLocation = GeoPoint(-1.7970149, -80.757148);
    List<DocumentSnapshot> snapshots =
        await geocollection.getAtLocation(queryLocation, 1000);
    // snapshots is always an empty List
    final documents = snapshots.map((doc) {
      return doc.data;
    }).toList();
    setState(() {
      _documents = documents;
    });
  }

I managed to trace the calls into this lib, and it seems the issue is occurring in queriesAtLocation(). Specifically in this series of calls:

    queries.add(queryForGeoHash(geoHash, queryBits)); // queries.single: GeoHashQuery
    queries.add(queryForGeoHash(geoHashE, queryBits)); // queries.single: GeoHashQuery
    queries.add(queryForGeoHash(geoHashW, queryBits)); // queries.single: GeoHashQuery
    queries.add(queryForGeoHash(geoHashN, queryBits)); // queries.single: Unhandled exception: Bad state: Too many elements
    // After this things seem broken
    queries.add(queryForGeoHash(geoHashNE, queryBits));
    queries.add(queryForGeoHash(geoHashNW, queryBits));
    queries.add(queryForGeoHash(geoHashS, queryBits));
    queries.add(queryForGeoHash(geoHashSE, queryBits));
    queries.add(queryForGeoHash(geoHashSW, queryBits));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant