MKMapRect.contains() returns false when crossing 180th meridian using .union()

Originator:rebello95
Number:rdar://FB9953006 Date Originated:03/10/2022
Status:open Resolved:
Product:iOS + SDK Product Version:13.2.1
Classification:Bug Reproducible:Always
 
When using `MKMapRect.union()` to merge two `MKMapPoint`s (one on either side of the 180th meridian / antemeridian, resulting in a rect that should cross it), calling `.contains()` on the unified rect returns false for a point that is within the rect, rather than true.

import CoreLocation
import MapKit

let southWest = MKMapPoint(CLLocationCoordinate2D(latitude: -15.597850272465658, longitude: 166.90067687320118))
let northEast = MKMapPoint(CLLocationCoordinate2D(latitude: 76.42715026767411, longitude: -90.1312509710639))
let size = MKMapSize(width: 0, height: 0)
let rect = MKMapRect(origin: southWest, size: size).union(MKMapRect(origin: northEast, size: size))

let containedPoint = CLLocationCoordinate2D(latitude: 33.083100, longitude: -117.05982)
print(rect.contains(MKMapPoint(containedPoint))) // false, but should be true

Expected: MKMapRect.contains() to return true in the above example
Actual: False is returned
Very similar to http://www.openradar.appspot.com/33699497, though this is using newer APIs.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!