I am encountering an issue while retrieving documents based on their location data within an Appwrite collection. I'm following the guidance provided in the forum thread (https://appwrite.io/threads/1132861274062082058 and https://levelup.gitconnected.com/building-a-location-based-app-with-appwrite-48a2e2b6d4c2#8e5c) but I'm not getting the expected results.
Current Situation: I have two documents in my collection with attributes named lat and lang containing the following latitude and longitude values: Document 1: lat - 13.030373668739, long - 77.750823773725 Document 2: lat - 14.030373668739, doc - 78.750823773725 I'm calculating bounds using the Bounds.getBounds function with a center point (Point(lng: 14.030373668738747, lat: 78.75082377372495)) and a specific distance (2 in this case). The constructed query uses these bounds to filter documents based on latitude and longitude:
_appwriteService.databases.listDocuments( databaseId: 'databaseID', collectionId:'collectionID', queries: [ Query.greaterThan('lat', location.south.lat), Query.lessThan('lat', location.north.lat), Query.greaterThan('long', location.west.lng), Query.lessThan('long', location.north.lng), ]);
Problem:
Despite the documents having location data within the calculated bounds, the query isn't returning any results.
I would appreciate your assistance in identifying the reason why the documents aren't being retrieved.
Is there a potential issue with the query construction or the bounds calculation? Any suggestions or troubleshooting steps would be greatly helpful.
FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).
sooo what did you get for the bounds?
and what are the permissions on the collection and documents? are you able to get the documents without any filter queries?
Yes, without any query i am able to retrieve both documents
Here are the bounds : east: 78.75082377372495,13.288457667830574, north: 78.8955539432538,14.030373668738747, south: 78.60609360419609,14.030373668738747, west: 78.75082377372495,14.77228966964692
Recommended threads
- How to bypass the rate limit on the back...
Once a month my app has a ton of usage and I always run into the Too many requests 429 error. I am trying to optimize the queues and jobs to manage that, but a...
- 401 - Project not accessible in this reg...
Hi Appwrite team, I’m experiencing a Cloud Console issue with my NYC region project. Problem: - Some Console pages return: “401 - Project is not accessible ...
- 401 - Project not accessible, Singapore ...
Hi, I'm getting a 401 error when I try to open my project from the Appwrite Cloud console dashboard. Project ID : sgp-6a04326f002bd04cc420 Region : Singap...