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
- TablesDB `updateRows` returns `database_...
Hi Appwrite team! I’m seeing a strange issue with TablesDB bulk row updates on a self-hosted Appwrite instance. **Environment** - Appwrite self-hosted `1.9.0` ...
- Updating GitHub App access throws error
Steps to reproduce - 1. Have some private repos allowed on the install access 2. New Site/Func > Connect GitHub > see the side card saying `Missing a repo` > cl...
- Update row sheet not loading
After right clicking a row header and click update, the sidebar fails to load (never-ending skeleton)