Skip to content

Commit

Permalink
Fix for region contains check if needle is bigger than the region and… (
Browse files Browse the repository at this point in the history
#337)

Fix for region contains check if needle is bigger than the region and contains it
  • Loading branch information
nighthawk authored Feb 23, 2024
1 parent 2a6784e commit 626cd31
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/TripKit/server/TKRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,18 @@ public class TKRegion : NSObject, Codable {
guard let simplePolygon = simplePolygon else { return true }

let needle = Polygon(
pairs: [
points: [
MKMapPoint(x: mapRect.minX, y: mapRect.minY),
MKMapPoint(x: mapRect.minX, y: mapRect.maxY),
MKMapPoint(x: mapRect.maxX, y: mapRect.maxY),
MKMapPoint(x: mapRect.maxX, y: mapRect.minY),
]
.map(\.coordinate)
.map { ($0.latitude, $0.longitude) }
.map { Point(latitude: $0.latitude, longitude: $0.longitude) }
)
return simplePolygon.contains(needle) || simplePolygon.intersects(needle)
return simplePolygon.contains(needle)
|| needle.contains(simplePolygon)
|| simplePolygon.intersects(needle)
}

// MARK: Codable
Expand Down

0 comments on commit 626cd31

Please sign in to comment.