Skip to content

Conversation

@gpunto
Copy link
Collaborator

@gpunto gpunto commented Nov 25, 2025

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):

  • Add support for near and withinBounds operations following the same pattern as other ops
  • Add CircularRegion and BoundingBox convenience classes to use with the new operations
  • Rename existing Any.contains function to Any.doesContain to avoid overloading contains which made it error prone
  • Add LocationCoordinate to have a lightweight, typed container for lat & lng
  • Add Distance value class to reduce the chance of unit conversion errors

Testing

Checklist

  • Issue linked (if any)
  • Tests/docs updated
  • I have signed the Stream CLA (required for external contributors)

@gpunto gpunto requested a review from Copilot November 25, 2025 14:19
@gpunto gpunto added the pr:new-feature New feature label Nov 25, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

Copilot finished reviewing on behalf of gpunto November 25, 2025 14:22
Copy link
Contributor

Copilot AI left a 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, and BoundingBox classes for type-safe location handling
  • Added near and withinBounds filter operations with support for both typed objects and API map formats
  • Renamed Any.contains to Any.doesContain in FilterOperations to avoid overloading the built-in contains method

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.

@gpunto gpunto force-pushed the and-919/location-filtering branch from bd4c64d to c9898ab Compare November 26, 2025 13:11
@gpunto gpunto marked this pull request as ready for review November 26, 2025 13:45
@gpunto gpunto force-pushed the and-919/location-filtering branch from 2c94eeb to 573bba9 Compare November 26, 2025 14:16
@gpunto gpunto marked this pull request as draft November 26, 2025 14:21
@gpunto gpunto force-pushed the and-919/location-filtering branch 3 times, most recently from ab5dc98 to ff81d66 Compare November 26, 2025 16:25
@gpunto gpunto marked this pull request as ready for review November 27, 2025 10:06
@gpunto gpunto force-pushed the and-919/location-filtering branch from e5482d3 to d84acf7 Compare November 27, 2025 11:14
@gpunto gpunto force-pushed the and-919/location-filtering branch from d84acf7 to f435ef7 Compare November 27, 2025 11:14
Copy link
Contributor

@VelikovPetar VelikovPetar left a 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!

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
79.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@VelikovPetar VelikovPetar merged commit 50c3431 into develop Nov 28, 2025
5 of 6 checks passed
@VelikovPetar VelikovPetar deleted the and-919/location-filtering branch November 28, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:new-feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants