diff options
author | Jason Wray <friedbunny@users.noreply.github.com> | 2016-05-17 11:02:22 -0400 |
---|---|---|
committer | Jason Wray <friedbunny@users.noreply.github.com> | 2016-05-17 11:02:22 -0400 |
commit | 22447373ae9f975a11a809d1384e72be0d1889cf (patch) | |
tree | 169b19218144e9b4a3b2b6b32cdc1c1e540b0279 /platform/darwin/test/MGLGeometryTests.mm | |
parent | 4434c0438a75e9c5bf0a36229b73ffc352c02639 (diff) | |
download | qtlocation-mapboxgl-22447373ae9f975a11a809d1384e72be0d1889cf.tar.gz |
[ios] Make MGLCoordinateInCoordinateBounds() public (#5053)
Bounds should always be in NE, SW order — any other coordinate order (e.g., NW, SE) will give false results.
Diffstat (limited to 'platform/darwin/test/MGLGeometryTests.mm')
-rw-r--r-- | platform/darwin/test/MGLGeometryTests.mm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/platform/darwin/test/MGLGeometryTests.mm b/platform/darwin/test/MGLGeometryTests.mm index e76c67c5c1..b15916e6fa 100644 --- a/platform/darwin/test/MGLGeometryTests.mm +++ b/platform/darwin/test/MGLGeometryTests.mm @@ -78,4 +78,25 @@ @"Northeast should round-trip."); } +- (void)testCoordinateInCoordinateBounds { + CLLocationCoordinate2D ne = CLLocationCoordinate2DMake(41, -111); + CLLocationCoordinate2D sw = CLLocationCoordinate2DMake(45, -104); + MGLCoordinateBounds wyoming = MGLCoordinateBoundsMake(ne, sw); + + CLLocationCoordinate2D centerOfWyoming = CLLocationCoordinate2DMake(43, -107.5); + + XCTAssertTrue(MGLCoordinateInCoordinateBounds(ne, wyoming)); + XCTAssertTrue(MGLCoordinateInCoordinateBounds(sw, wyoming)); + XCTAssertTrue(MGLCoordinateInCoordinateBounds(centerOfWyoming, wyoming)); + + CLLocationCoordinate2D australia = CLLocationCoordinate2DMake(-25, 135); + CLLocationCoordinate2D brazil = CLLocationCoordinate2DMake(-12, -50); + CLLocationCoordinate2D china = CLLocationCoordinate2DMake(35, 100); + + XCTAssertFalse(MGLCoordinateInCoordinateBounds(australia, wyoming)); + XCTAssertFalse(MGLCoordinateInCoordinateBounds(brazil, wyoming)); + XCTAssertFalse(MGLCoordinateInCoordinateBounds(china, wyoming)); + XCTAssertFalse(MGLCoordinateInCoordinateBounds(kCLLocationCoordinate2DInvalid, wyoming)); +} + @end |