Skip to content

Commit

Permalink
Code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Jul 26, 2024
1 parent 6ccb95f commit c640758
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Sources/GISTools/Algorithms/LineOverlap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ extension GeoJson {
guard comparison != .notEqual else { continue }

result.append(SegmentOverlapResult(
kind: comparison,
overlap: comparison,
segment: segment,
other: match))
}
Expand Down
18 changes: 9 additions & 9 deletions Tests/GISToolsTests/Algorithms/LineOverlapTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class LineOverlapTests: XCTestCase {

XCTAssertEqual(overlappingSegments.count, 2)

XCTAssertEqual(overlappingSegments.map(\.kind), [.equal, .equal])
XCTAssertEqual(overlappingSegments.map(\.overlap), [.equal, .equal])
XCTAssertEqual(overlappingSegments[0].segment.second, overlappingSegments[1].segment.first)
XCTAssertEqual(overlappingSegments[0].segment.first, Coordinate3D(latitude: -30.0, longitude: 125.0))
XCTAssertEqual(overlappingSegments[1].segment.second, Coordinate3D(latitude: -35.0, longitude: 145.0))
Expand All @@ -25,7 +25,7 @@ final class LineOverlapTests: XCTestCase {

XCTAssertEqual(overlappingSegments.count, 2)

XCTAssertEqual(overlappingSegments.map(\.kind), [.equal, .equal])
XCTAssertEqual(overlappingSegments.map(\.overlap), [.equal, .equal])
XCTAssertEqual(overlappingSegments[0].segment.second, overlappingSegments[1].segment.first)
XCTAssertEqual(overlappingSegments[0].segment.first, Coordinate3D(latitude: -30.0, longitude: 125.0))
XCTAssertEqual(overlappingSegments[1].segment.second, Coordinate3D(latitude: -35.0, longitude: 145.0))
Expand All @@ -39,7 +39,7 @@ final class LineOverlapTests: XCTestCase {

XCTAssertEqual(overlappingSegments.count, 2)

XCTAssertEqual(overlappingSegments.map(\.kind), [.equal, .equal])
XCTAssertEqual(overlappingSegments.map(\.overlap), [.equal, .equal])
XCTAssertEqual(overlappingSegments[0].segment.second, overlappingSegments[1].segment.first)
XCTAssertEqual(overlappingSegments[0].segment.first, Coordinate3D(latitude: -30.0, longitude: 125.0))
XCTAssertEqual(overlappingSegments[1].segment.second, Coordinate3D(latitude: -35.0, longitude: 145.0))
Expand All @@ -53,7 +53,7 @@ final class LineOverlapTests: XCTestCase {
let overlappingSegments = polygon1.overlappingSegments(with: polygon2)

XCTAssertEqual(overlappingSegments.count, 6)
XCTAssertEqual(Set(overlappingSegments.map(\.kind)), [.equalReversed])
XCTAssertEqual(Set(overlappingSegments.map(\.overlap)), [.equalReversed])

let firstSegments = result.lineStrings[0].lineSegments
let secondSegments = result.lineStrings[1].lineSegments
Expand All @@ -79,7 +79,7 @@ final class LineOverlapTests: XCTestCase {
let overlappingSegments = polygon1.overlappingSegments(with: polygon2)

XCTAssertEqual(overlappingSegments.count, 4)
XCTAssertEqual(Set(overlappingSegments.map(\.kind)), [.otherOnThis])
XCTAssertEqual(Set(overlappingSegments.map(\.overlap)), [.otherOnThis])

let firstSegments = result.lineStrings[0].lineSegments
let secondSegments = result.lineStrings[1].lineSegments
Expand All @@ -96,7 +96,7 @@ final class LineOverlapTests: XCTestCase {
let overlappingSegments = polygon1.overlappingSegments(with: polygon2, tolerance: 5000.0)

XCTAssertEqual(overlappingSegments.count, 1)
XCTAssertEqual(Set(overlappingSegments.map(\.kind)), [.otherOnThis])
XCTAssertEqual(Set(overlappingSegments.map(\.overlap)), [.otherOnThis])
XCTAssertEqual(overlappingSegments.map(\.other), result.lineSegments)
}

Expand All @@ -120,8 +120,8 @@ final class LineOverlapTests: XCTestCase {
XCTAssertEqual(overlappingSegments1.count, 1)
XCTAssertEqual(overlappingSegments2.count, 1)

XCTAssertEqual(Set(overlappingSegments1.map(\.kind)), [.thisOnOther])
XCTAssertEqual(Set(overlappingSegments2.map(\.kind)), [.otherOnThis])
XCTAssertEqual(Set(overlappingSegments1.map(\.overlap)), [.thisOnOther])
XCTAssertEqual(Set(overlappingSegments2.map(\.overlap)), [.otherOnThis])

XCTAssertEqual(overlappingSegments1.map(\.segment), result.lineSegments)
XCTAssertEqual(overlappingSegments2.map(\.other), result.lineSegments)
Expand Down Expand Up @@ -213,7 +213,7 @@ final class LineOverlapTests: XCTestCase {
])!

let overlapping = lineString.overlappingSegments(with: nil)
overlapping.forEach({ print("\($0.kind): \($0.segment.coordinates), other: \($0.other.coordinates)") })
overlapping.forEach({ print("\($0.overlap): \($0.segment.coordinates), other: \($0.other.coordinates)") })

XCTAssertEqual(overlapping.count, 6)
}
Expand Down

0 comments on commit c640758

Please sign in to comment.