From 5c69f5fc55237a2c1dd3431969bc49d65f92cd77 Mon Sep 17 00:00:00 2001 From: Tony Stone Date: Fri, 23 Mar 2018 14:01:52 -0700 Subject: [PATCH] Fixing integration of master branch changes in last merge. --- Sources/GeoFeatures/LineString+Geometry.swift | 44 ++++----- Sources/GeoFeatures/MultiPoint+Geometry.swift | 14 ++- Sources/GeoFeatures/Segment.swift | 44 --------- Tests/LinuxMain.swift | 96 +++++++++++++++---- 4 files changed, 105 insertions(+), 93 deletions(-) delete mode 100644 Sources/GeoFeatures/Segment.swift diff --git a/Sources/GeoFeatures/LineString+Geometry.swift b/Sources/GeoFeatures/LineString+Geometry.swift index 4ff570e..01f46e6 100644 --- a/Sources/GeoFeatures/LineString+Geometry.swift +++ b/Sources/GeoFeatures/LineString+Geometry.swift @@ -130,34 +130,32 @@ extension LineString: Geometry { /// public func isSimple() -> Bool { - return buffer.withUnsafeMutablePointers { (header, elements) -> Bool in - /// If there are no more than two coordinates, there can be at most one line segment, - /// so this line segment cannot self-intersect. - guard header.pointee.count > 2 else { - return true - } + /// If there are no more than two coordinates, there can be at most one line segment, + /// so this line segment cannot self-intersect. + guard coordinates.count > 2 else { + return true + } - /// There must be at least two line segments to get to this point. - for i in 0.. Bool { - return buffer.withUnsafeMutablePointers { (header, elements) -> Bool in - var points = [Element]() + var points = [Element]() - for i in 0.. { - - internal var c1: CoordinateType - internal var c2: CoordinateType - - init(c1: CoordinateType, c2: CoordinateType) { - self.c1 = c1 - self.c2 = c2 - } -} - -/// -/// Segment is Equatable so it can be added to a b-tree and searched. -/// -extension Segment: Equatable {} /// TODO: Siwft 4: where CoordinateType: Equatable - -internal func == (lhs: Segment, rhs: Segment) -> Bool { - return false -} diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index a164b44..29b6ebb 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1263,7 +1263,10 @@ extension MultiPointGeometryCoordinate2DFloatingPrecisionCartesianTests { return [ ("testDimension", testDimension), ("testBoundary", testBoundary), - ("testBoundaryEmpty", testBoundaryEmpty) + ("testBoundaryEmpty", testBoundaryEmpty), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1273,7 +1276,10 @@ extension MultiPointGeometryCoordinate2DMFloatingPrecisionCartesianTests { return [ ("testDimension", testDimension), ("testBoundary", testBoundary), - ("testBoundaryEmpty", testBoundaryEmpty) + ("testBoundaryEmpty", testBoundaryEmpty), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1283,7 +1289,10 @@ extension MultiPointGeometryCoordinate3DFloatingPrecisionCartesianTests { return [ ("testDimension", testDimension), ("testBoundary", testBoundary), - ("testBoundaryEmpty", testBoundaryEmpty) + ("testBoundaryEmpty", testBoundaryEmpty), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1293,7 +1302,10 @@ extension MultiPointGeometryCoordinate3DMFloatingPrecisionCartesianTests { return [ ("testDimension", testDimension), ("testBoundary", testBoundary), - ("testBoundaryEmpty", testBoundaryEmpty) + ("testBoundaryEmpty", testBoundaryEmpty), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1303,7 +1315,10 @@ extension MultiPointGeometryCoordinate2DFixedPrecisionCartesianTests { return [ ("testDimension", testDimension), ("testBoundary", testBoundary), - ("testBoundaryEmpty", testBoundaryEmpty) + ("testBoundaryEmpty", testBoundaryEmpty), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1313,7 +1328,10 @@ extension MultiPointGeometryCoordinate2DMFixedPrecisionCartesianTests { return [ ("testDimension", testDimension), ("testBoundary", testBoundary), - ("testBoundaryEmpty", testBoundaryEmpty) + ("testBoundaryEmpty", testBoundaryEmpty), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1325,7 +1343,10 @@ extension MultiPointGeometryCoordinate3DFixedPrecisionCartesianTests { ("testBoundary", testBoundary), ("testBoundaryEmpty", testBoundaryEmpty), ("testEqualTrue", testEqualTrue), - ("testEqualFalse", testEqualFalse) + ("testEqualFalse", testEqualFalse), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1337,7 +1358,10 @@ extension MultiPointGeometryCoordinate3DMFixedPrecisionCartesianTests { ("testBoundary", testBoundary), ("testBoundaryEmpty", testBoundaryEmpty), ("testEqualTrue", testEqualTrue), - ("testEqualFalse", testEqualFalse) + ("testEqualFalse", testEqualFalse), + ("testIsSimpleWithNoEqualPoints", testIsSimpleWithNoEqualPoints), + ("testIsSimpleWithNoEqualPointsAfterPrecision", testIsSimpleWithNoEqualPointsAfterPrecision), + ("testIsSimpleWithEqualPointsAfterPrecision", testIsSimpleWithEqualPointsAfterPrecision) ] } } @@ -1437,7 +1461,8 @@ extension PointGeometryCoordinate2DFloatingPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -1450,7 +1475,8 @@ extension PointGeometryCoordinate2DMFloatingPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -1463,7 +1489,8 @@ extension PointGeometryCoordinate3DFloatingPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -1476,7 +1503,8 @@ extension PointGeometryCoordinate3DMFloatingPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -1489,7 +1517,8 @@ extension PointGeometryCoordinate2DFixedPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -1502,7 +1531,8 @@ extension PointGeometryCoordinate2DMFixedPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -1515,7 +1545,8 @@ extension PointGeometryCoordinate3DFixedPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -1528,7 +1559,8 @@ extension PointGeometryCoordinate3DMFixedPrecisionCartesianTests { ("testEqualsWithIntOneTrue", testEqualsWithIntOneTrue), ("testEqualsWithIntOneFalse", testEqualsWithIntOneFalse), ("testEqualsWithPointNonPointFalse", testEqualsWithPointNonPointFalse), - ("testBoundary", testBoundary) + ("testBoundary", testBoundary), + ("testIsSimple_True", testIsSimple_True) ] } } @@ -2118,7 +2150,21 @@ extension LineStringGeometryCoordinate2DFloatingPrecisionCartesianTests { ("testBoundaryWith4ElementClosed", testBoundaryWith4ElementClosed), ("testBoundaryEmpty", testBoundaryEmpty), ("testEqualTrue", testEqualTrue), - ("testEqualFalse", testEqualFalse) + ("testEqualFalse", testEqualFalse), + ("testIsSimple_WithNoPoints", testIsSimple_WithNoPoints), + ("testIsSimple_WithOnePoint", testIsSimple_WithOnePoint), + ("testIsSimple_WithTwoPoints", testIsSimple_WithTwoPoints), + ("testIsSimple_WithThreeIdenticalPoints", testIsSimple_WithThreeIdenticalPoints), + ("testIsSimple_WithThreePoints_FirstSecondSame", testIsSimple_WithThreePoints_FirstSecondSame), + ("testIsSimple_WithThreePoints_FirstThirdSame", testIsSimple_WithThreePoints_FirstThirdSame), + ("testIsSimple_WithThreePoints_SecondThirdSame", testIsSimple_WithThreePoints_SecondThirdSame), + ("testIsSimple_WithThreePoints_AllDifferent", testIsSimple_WithThreePoints_AllDifferent), + ("testIsSimple_WithFourPoints_FirstLastSame", testIsSimple_WithFourPoints_FirstLastSame), + ("testIsSimple_WithFourPoints_LastSegmentTouchesButGoesBeyondFirstPoint", testIsSimple_WithFourPoints_LastSegmentTouchesButGoesBeyondFirstPoint), + ("testIsSimple_WithFourPoints_LastSegmentCrossedFirstSegment", testIsSimple_WithFourPoints_LastSegmentCrossedFirstSegment), + ("testIsSimple_WithFivePoints_SecondLastSame", testIsSimple_WithFivePoints_SecondLastSame), + ("testIsSimple_WithFivePoints_FirstFourthSame", testIsSimple_WithFivePoints_FirstFourthSame), + ("testIsSimple_WithFivePoints_ThirdSegmentTouchesFirstSegment", testIsSimple_WithFivePoints_ThirdSegmentTouchesFirstSegment) ] } } @@ -2150,7 +2196,21 @@ extension LineStringGeometryCoordinate3DMFloatingPrecisionCartesianTests { extension LineStringGeometryCoordinate2DFixedPrecisionCartesianTests { static var allTests: [(String, (LineStringGeometryCoordinate2DFixedPrecisionCartesianTests) -> () throws -> Void)] { return [ - ("testDimension", testDimension) + ("testDimension", testDimension), + ("testIsSimple_WithNoPoints", testIsSimple_WithNoPoints), + ("testIsSimple_WithOnePoint", testIsSimple_WithOnePoint), + ("testIsSimple_WithTwoPoints", testIsSimple_WithTwoPoints), + ("testIsSimple_WithThreeIdenticalPoints", testIsSimple_WithThreeIdenticalPoints), + ("testIsSimple_WithThreePoints_FirstSecondSame", testIsSimple_WithThreePoints_FirstSecondSame), + ("testIsSimple_WithThreePoints_FirstThirdSame", testIsSimple_WithThreePoints_FirstThirdSame), + ("testIsSimple_WithThreePoints_SecondThirdSame", testIsSimple_WithThreePoints_SecondThirdSame), + ("testIsSimple_WithThreePoints_AllDifferent", testIsSimple_WithThreePoints_AllDifferent), + ("testIsSimple_WithFourPoints_FirstLastSame", testIsSimple_WithFourPoints_FirstLastSame), + ("testIsSimple_WithFourPoints_LastSegmentTouchesButGoesBeyondFirstPoint", testIsSimple_WithFourPoints_LastSegmentTouchesButGoesBeyondFirstPoint), + ("testIsSimple_WithFourPoints_LastSegmentCrossedFirstSegment", testIsSimple_WithFourPoints_LastSegmentCrossedFirstSegment), + ("testIsSimple_WithFivePoints_SecondLastSame", testIsSimple_WithFivePoints_SecondLastSame), + ("testIsSimple_WithFivePoints_FirstFourthSame", testIsSimple_WithFivePoints_FirstFourthSame), + ("testIsSimple_WithFivePoints_ThirdSegmentTouchesFirstSegment", testIsSimple_WithFivePoints_ThirdSegmentTouchesFirstSegment) ] } }