Skip to content

Conversation

@xsahil03x
Copy link
Member

Description of the pull request

This change introduces support for location-based queries, enabling filtering by proximity (circular region) and geographic area (bounding box).

Key additions include:

  • Location Primitives: LocationCoordinate, Distance, CircularRegion, and BoundingBox classes to represent geographic data.
  • Filter Logic: Extended the filter matching logic to handle LocationCoordinate comparisons against CircularRegion and BoundingBox objects, including support for raw Map representations.
  • Serialization: Ensured that CircularRegion and BoundingBox objects are correctly serialized to JSON for API requests.
  • File Organization: Refactored filtering-related files into a new query/filter/ directory for better structure.

This change introduces support for location-based queries, enabling filtering by proximity (circular region) and geographic area (bounding box).

**Key additions include:**
*   **Location Primitives**: `LocationCoordinate`, `Distance`, `CircularRegion`, and `BoundingBox` classes to represent geographic data.
*   **Filter Logic**: Extended the filter matching logic to handle `LocationCoordinate` comparisons against `CircularRegion` and `BoundingBox` objects, including support for raw `Map` representations.
*   **Serialization**: Ensured that `CircularRegion` and `BoundingBox` objects are correctly serialized to JSON for API requests.
*   **File Organization**: Refactored filtering-related files into a new `query/filter/` directory for better structure.
@xsahil03x xsahil03x requested a review from a team as a code owner December 9, 2025 14:26
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 34.15%. Comparing base (25ecdbc) to head (5b4c75e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #22      +/-   ##
==========================================
+ Coverage   28.61%   34.15%   +5.53%     
==========================================
  Files          49       53       +4     
  Lines         975     1057      +82     
==========================================
+ Hits          279      361      +82     
  Misses        696      696              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

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 comprehensive location-based filtering support to the stream_core package, enabling queries based on proximity (circular regions) and geographic areas (bounding boxes). The implementation includes new location primitives, filter matching logic, JSON serialization, and a file structure reorganization.

Key changes:

  • Introduced location primitives (LocationCoordinate, Distance, CircularRegion, BoundingBox) for geographic queries
  • Extended filter matching to support location comparisons with both typed objects and Map representations
  • Added JSON serialization for location types to enable API integration

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/stream_core/lib/src/query/filter/location/location_coordinate.dart Implements geographic coordinates with Haversine distance calculations
packages/stream_core/lib/src/query/filter/location/distance.dart Extension type for distance values with meter/kilometer conversions
packages/stream_core/lib/src/query/filter/location/circular_region.dart Circular region class for proximity-based filtering with JSON serialization
packages/stream_core/lib/src/query/filter/location/bounding_box.dart Rectangular bounding box class for area-based filtering with JSON serialization
packages/stream_core/lib/src/query/filter/location/circular_region.g.dart Generated JSON serialization code for CircularRegion
packages/stream_core/lib/src/query/filter/location/bounding_box.g.dart Generated JSON serialization code for BoundingBox
packages/stream_core/lib/src/query/filter/filter_operation_utils.dart Extension methods for location equality checks supporting both typed and Map formats
packages/stream_core/lib/src/query/filter/filter.dart Updated filter matching logic to handle location coordinates, adjusted imports for new structure
packages/stream_core/lib/src/query/filter/filter_operator.dart Comprehensive filter operator definitions (moved to new location)
packages/stream_core/lib/src/query.dart Updated exports to include location types and reflect new file structure
packages/stream_core/test/query/location_test.dart Unit tests for location primitives covering distance calculations and containment checks
packages/stream_core/test/query/filter_test.dart Integration tests for location filtering including edge cases and Map format support
packages/stream_core/CHANGELOG.md Documented new location-based filtering feature
Comments suppressed due to low confidence (1)

packages/stream_core/lib/src/query/filter/filter.dart:262

  • Both isNear() and isWithinBounds() are always called because the results are stored in variables before the OR check. This means both methods execute even though at most one can return true. Use direct short-circuit evaluation instead:
// Special case for location coordinates
if (fieldValue is LocationCoordinate) {
  return fieldValue.isNear(comparisonValue) || 
         fieldValue.isWithinBounds(comparisonValue);
}

This allows the second method to be skipped when the first returns true.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xsahil03x xsahil03x merged commit 4be039e into main Dec 10, 2025
7 checks passed
@xsahil03x xsahil03x deleted the feat/location-filtering branch December 10, 2025 12:22
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

Successfully merging this pull request may close these issues.

3 participants