-
Notifications
You must be signed in to change notification settings - Fork 0
feat(llc): Add location-based filtering support #22
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
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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 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()andisWithinBounds()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.
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:
LocationCoordinate,Distance,CircularRegion, andBoundingBoxclasses to represent geographic data.LocationCoordinatecomparisons againstCircularRegionandBoundingBoxobjects, including support for rawMaprepresentations.CircularRegionandBoundingBoxobjects are correctly serialized to JSON for API requests.query/filter/directory for better structure.