-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from michael-groble/bbox-intersection
add bounding box intersection test
- Loading branch information
Showing
5 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// Geohash.swift | ||
// Geohash | ||
// | ||
// Created by michael groble on 1/8/17. | ||
// | ||
// | ||
|
||
public enum GeohashError : Error { | ||
case invalidPrecision | ||
case invalidLocation | ||
case invalidArguments | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// BoundingBoxTests.swift | ||
// Geohash | ||
// | ||
// Created by michael groble on 1/8/17. | ||
// | ||
// | ||
|
||
import XCTest | ||
@testable import Geohash | ||
|
||
class BoundingBoxTests: XCTestCase { | ||
|
||
var subject: BoundingBox! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
|
||
self.subject = try! BoundingBox( | ||
min: Location(longitude: -10, latitude: -10), | ||
max: Location(longitude: +10, latitude: +10) | ||
) | ||
} | ||
|
||
func testIntersectsIntersecting() throws { | ||
let intersecting = try BoundingBox( | ||
min: Location(longitude: -20, latitude: -20), | ||
max: Location(longitude: -9, latitude: -9) | ||
) | ||
XCTAssertTrue(subject.intersects(intersecting)) | ||
} | ||
|
||
func testIntersectsNonIntersecting() throws { | ||
let intersecting = try BoundingBox( | ||
min: Location(longitude: -20, latitude: -20), | ||
max: Location(longitude: -9, latitude: -10.1) | ||
) | ||
XCTAssertFalse(subject.intersects(intersecting)) | ||
} | ||
} | ||
|
||
extension BoundingBoxTests { | ||
static var allTests = [ | ||
("testIntersectsIntersecting", testIntersectsIntersecting), | ||
("testIntersectsNonIntersecting", testIntersectsNonIntersecting), | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters