File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed
Expand file tree Collapse file tree 3 files changed +10
-3
lines changed File renamed without changes.
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public struct Polygon:
3434
3535 /// The receiver's outer ring.
3636 public var outerRing : Ring ? {
37- guard ! coordinates. isEmpty else { return nil }
37+ guard coordinates. isNotEmpty else { return nil }
3838 return Ring ( coordinates [ 0 ] )
3939 }
4040
@@ -55,7 +55,7 @@ public struct Polygon:
5555
5656 /// Try to initialize a Polygon with some coordinates.
5757 public init ? ( _ coordinates: [ [ Coordinate3D ] ] , calculateBoundingBox: Bool = false ) {
58- guard ! coordinates. isEmpty ,
58+ guard coordinates. isNotEmpty ,
5959 coordinates [ 0 ] . count >= 3
6060 else { return nil }
6161
Original file line number Diff line number Diff line change @@ -29,7 +29,14 @@ public struct Ring: Sendable {
2929
3030 /// Try to initialize a Ring with some coordinates.
3131 public init ? ( _ coordinates: [ Coordinate3D ] ) {
32- // TODO: Close the ring, if necessary
32+ // Close the ring, if necessary
33+ var coordinates = coordinates
34+ if coordinates. count >= 3 ,
35+ coordinates. first != coordinates. last
36+ {
37+ coordinates. append ( coordinates [ 0 ] )
38+ }
39+
3340 guard coordinates. count >= 4 else { return nil }
3441
3542 self . init ( unchecked: coordinates)
You can’t perform that action at this time.
0 commit comments