-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for location-based filtering #30
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
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds location-based filtering support to the Android core library, enabling filtering by geographic coordinates using near (circular region) and withinBounds (rectangular bounding box) operations. The implementation closely follows the iOS version and maintains consistency with existing filter operation patterns in the codebase.
Key Changes:
- Introduced
LocationCoordinate,Distance,CircularRegion, andBoundingBoxclasses for type-safe location handling - Added
nearandwithinBoundsfilter operations with support for both typed objects and API map formats - Renamed
Any.containstoAny.doesContainin FilterOperations to avoid overloading the built-incontainsmethod
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
LocationCoordinate.kt |
New data class representing geographic coordinates with latitude/longitude |
Distance.kt |
New value class for type-safe distance measurements with automatic unit conversion |
CircularRegion.kt |
New data class for circular geographic regions with contains operator and API serialization |
BoundingBox.kt |
New data class for rectangular geographic regions with contains operator and API serialization |
FilterOperator.kt |
Added NEAR and WITHIN_BOUNDS binary operators |
FilterOperations.kt |
Renamed contains to doesContain; added near and withinBounds operations |
Filters.kt |
Added public API extension functions for near and withinBounds filters |
Filter.kt |
Added support for new operators in filter matching and request conversion |
FilterOperationsNearTest.kt |
Comprehensive tests for the near operation including typed and map formats |
FilterOperationsWithinBoundsTest.kt |
Comprehensive tests for the withinBounds operation including typed and map formats |
CircularRegionTest.kt |
Unit tests for CircularRegion contains logic |
BoundingBoxTest.kt |
Unit tests for BoundingBox contains logic |
FilterToRequestTest.kt |
Integration tests verifying correct API request serialization for location filters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
bd4c64d to
c9898ab
Compare
2c94eeb to
573bba9
Compare
ab5dc98 to
ff81d66
Compare
e5482d3 to
d84acf7
Compare
d84acf7 to
f435ef7
Compare
VelikovPetar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one small clarification question, but I think it looks pretty good!
stream-android-core/src/main/java/io/getstream/android/core/internal/filter/FilterOperations.kt
Show resolved
Hide resolved
|


Goal
AND-919
Currently, we don't support location-based filtering for local filtering, so we should add it.
iOS PRs for reference:
Implementation
The PR seems big, but most of it is documentation and tests. The most relevant changes are the following ones (and almost all of them closely aligned with the iOS implementation):
nearandwithinBoundsoperations following the same pattern as other opsCircularRegionandBoundingBoxconvenience classes to use with the new operationsAny.containsfunction toAny.doesContainto avoid overloadingcontainswhich made it error proneLocationCoordinateto have a lightweight, typed container for lat & lngDistancevalue class to reduce the chance of unit conversion errorsTesting
Checklist