Skip to content

Commit 0eb12b6

Browse files
committed
Swapped names of simplify and simplified
Mutating methods should be named in the imperative mood; nonmutating methods should be named with past participles.
1 parent 831f77f commit 0eb12b6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Sources/Turf/Geometries/LineString.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ extension LineString {
261261
/// highestQuality: Excludes distance-based preprocessing step which leads to highest quality simplification. High quality simplification runs considerably slower so consider how much precision is needed in your application.
262262
///
263263
/// Ported from https://github.com/Turfjs/turf/blob/master/packages/turf-simplify/lib/simplify.js
264-
public func simplify(tolerance: Double = 1.0, highestQuality: Bool = false) -> LineString {
264+
public func simplified(tolerance: Double = 1.0, highestQuality: Bool = false) -> LineString {
265265
guard coordinates.count > 2 else { return LineString(coordinates) }
266266

267267
var copy = LineString(coordinates)
268-
copy.simplified(tolerance: tolerance, highestQuality: highestQuality)
268+
copy.simplify(tolerance: tolerance, highestQuality: highestQuality)
269269
return copy
270270
}
271271

@@ -277,7 +277,7 @@ extension LineString {
277277
/// highestQuality: Excludes distance-based preprocessing step which leads to highest quality simplification. High quality simplification runs considerably slower so consider how much precision is needed in your application.
278278
///
279279
/// Ported from https://github.com/Turfjs/turf/blob/master/packages/turf-simplify/lib/simplify.js
280-
public mutating func simplified(tolerance: Double = 1.0, highestQuality: Bool = false) {
280+
public mutating func simplify(tolerance: Double = 1.0, highestQuality: Bool = false) {
281281
coordinates = Simplifier.simplify(coordinates, tolerance: tolerance, highestQuality: highestQuality)
282282
}
283283
}

Sources/Turf/Geometries/Polygon.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ extension Polygon {
187187
/// highestQuality: Excludes distance-based preprocessing step which leads to highest quality simplification. High quality simplification runs considerably slower so consider how much precision is needed in your application.
188188
///
189189
/// Ported from https://github.com/Turfjs/turf/blob/master/packages/turf-simplify/lib/simplify.js
190-
public func simplify(tolerance: Double = 1.0, highestQuality: Bool = false) -> Polygon {
190+
public func simplified(tolerance: Double = 1.0, highestQuality: Bool = false) -> Polygon {
191191
var copy = Polygon(coordinates)
192-
copy.simplified(tolerance: tolerance, highestQuality: highestQuality)
192+
copy.simplify(tolerance: tolerance, highestQuality: highestQuality)
193193
return copy
194194
}
195195

@@ -201,7 +201,7 @@ extension Polygon {
201201
/// highestQuality: Excludes distance-based preprocessing step which leads to highest quality simplification. High quality simplification runs considerably slower so consider how much precision is needed in your application.
202202
///
203203
/// Ported from https://github.com/Turfjs/turf/blob/master/packages/turf-simplify/lib/simplify.js
204-
public mutating func simplified(tolerance: Double = 1.0, highestQuality: Bool = false) {
204+
public mutating func simplify(tolerance: Double = 1.0, highestQuality: Bool = false) {
205205
coordinates = coordinates.map { ring in
206206
guard ring.count > 3 else { return ring }
207207

Tests/TurfTests/TurfTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ class TurfTests: XCTestCase {
187187
break // nothing to simplify
188188

189189
case let (.lineString(lineIn), .lineString(lineOut)):
190-
let simplified = lineIn.simplify(tolerance: tolerance, highestQuality: highQuality)
190+
let simplified = lineIn.simplified(tolerance: tolerance, highestQuality: highQuality)
191191
XCTAssertEqual(lineOut.coordinates, simplified.coordinates, accuracy: 0.00001, "Fixture test failed for \(name)")
192192

193193
case let (.polygon(polyIn), .polygon(polyOut)):
194-
let simplified = polyIn.simplify(tolerance: tolerance, highestQuality: highQuality)
194+
let simplified = polyIn.simplified(tolerance: tolerance, highestQuality: highQuality)
195195
XCTAssertEqual(polyOut.coordinates, simplified.coordinates, accuracy: 0.00001, "Fixture test failed for \(name)")
196196

197197
default:

0 commit comments

Comments
 (0)