-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Holes in polygons where not subtracted from the outer ring ar…
…ea (#61)
- Loading branch information
Showing
2 changed files
with
49 additions
and
16 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,32 @@ | ||
@testable import GISTools | ||
import XCTest | ||
|
||
final class AreaTests: XCTestCase { | ||
|
||
func testArea() throws { | ||
let polygon1 = try XCTUnwrap(Polygon([[ | ||
Coordinate3D(x: 0.0, y: 0.0), | ||
Coordinate3D(x: 100.0, y: 0.0), | ||
Coordinate3D(x: 100.0, y: 100.0), | ||
Coordinate3D(x: 0.0, y: 100.0), | ||
Coordinate3D(x: 0.0, y: 0.0) | ||
]])) | ||
let polygon2 = try XCTUnwrap(Polygon([[ | ||
Coordinate3D(x: 0.0, y: 0.0), | ||
Coordinate3D(x: 100.0, y: 0.0), | ||
Coordinate3D(x: 100.0, y: 100.0), | ||
Coordinate3D(x: 0.0, y: 100.0), | ||
Coordinate3D(x: 0.0, y: 0.0) | ||
], [ | ||
Coordinate3D(x: 25.0, y: 25.0), | ||
Coordinate3D(x: 75.0, y: 25.0), | ||
Coordinate3D(x: 75.0, y: 75.0), | ||
Coordinate3D(x: 25.0, y: 75.0), | ||
Coordinate3D(x: 25.0, y: 25.0) | ||
]])) | ||
|
||
XCTAssertEqual(polygon1.area, 10000.0, accuracy: 0.1) | ||
XCTAssertEqual(polygon2.area, 7500.0, accuracy: 0.1) | ||
} | ||
|
||
} |