Add near and withinBounds filters with local filtering support#36
Add near and withinBounds filters with local filtering support#36
Conversation
Generated by 🚫 Danger |
| /// | ||
| /// - Returns: A dictionary representation of the filter in `RawJSON` format. | ||
| public func toRawJSON() -> [String: RawJSON] { | ||
| public func toRawJSONDictionary() -> [String: RawJSON] { |
There was a problem hiding this comment.
This is used for API requests in the Feeds SDK. rawJSON above comes from the FilterValue protocol and is used by toRawJSONDictionary. All in all, toRawJSONDictionary is just a convenience for API requests.
rawJSON was moved to the protocol since then it is better to manage conformance of all the types. Discovered some mapping issues like Int was not correctly encoded to RawJSON thanks to this change (there was a big switch statement before which).
| /// let center = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) | ||
| /// let region = CircularRegion(center: center, radiusInMeters: 5000) | ||
| /// ``` | ||
| public struct CircularRegion { |
There was a problem hiding this comment.
Naming comes from Apple's CLCircularRegion
There was a problem hiding this comment.
maybe we move this location stuff in a separate extension? Up to you though.
There was a problem hiding this comment.
and how are other SDKs calling this? Better to align on SDKs convention, over Apple's.
There was a problem hiding this comment.
I will have a chat with others about the naming and will rename if needed.
| func contains(_ coordinate: CLLocationCoordinate2D) -> Bool { | ||
| let centerLocation = CLLocation(latitude: center.latitude, longitude: center.longitude) | ||
| let coordinateLocation = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude) | ||
| let distance = centerLocation.distance(from: coordinateLocation) |
There was a problem hiding this comment.
This takes the Earth's curvature into account, same as what backend does.
| /// let sw = CLLocationCoordinate2D(latitude: 40.7580, longitude: -73.9855) | ||
| /// let boundingBox = BoundingBox(northeast: ne, southwest: sw) | ||
| /// ``` | ||
| public struct BoundingBox { |
There was a problem hiding this comment.
Naming coming from MapBox and other location related frameworks.
martinmitrevski
left a comment
There was a problem hiding this comment.
LGTM ✅ Just left 2 small remarks, but feel free to merge.
| /// let center = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) | ||
| /// let region = CircularRegion(center: center, radiusInMeters: 5000) | ||
| /// ``` | ||
| public struct CircularRegion { |
There was a problem hiding this comment.
maybe we move this location stuff in a separate extension? Up to you though.
| /// let center = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194) | ||
| /// let region = CircularRegion(center: center, radiusInMeters: 5000) | ||
| /// ``` | ||
| public struct CircularRegion { |
There was a problem hiding this comment.
and how are other SDKs calling this? Better to align on SDKs convention, over Apple's.
|



🔗 Issue Links
Fixes: IOS-1237
🎯 Goal
Add near and withinBounds filters with local filtering support new in feeds backend
🛠 Implementation
Feeds backend added new filter operators
nearandwithin_bounds. One for matching circular regions using Haversine formula (takes Earth's curvature into account), other just matching to bounds.☑️ Contributor Checklist
docs-contentrepo