-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various bug fixes for LineString.simplify and Polygon.simplify #152
Conversation
Fixes these bugs, too: - Polygon's simplify method didn't square the tolerance parameter when it should have - Polygon's 'highestQuality = false' didn't work at all(!)
Also removes hard-coded test which had wrong values
Also fix compiling using .xcodeproj file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Putting the test fixtures in JSON instead of inline feels a lot cleaner.
} | ||
} | ||
|
||
func XCTAssertEqual(_ expected: [[LocationCoordinate2D]], _ actual: [[LocationCoordinate2D]], accuracy: CLLocationDegrees, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the Bitrise builds are failing because #filePath
requires Swift 5.3, which is in Xcode 12. The readme currently states a minimum requirement of Xcode 9, but this would be a good opportunity to increase the requirement to 12.
@@ -0,0 +1,109 @@ | |||
import Foundation | |||
|
|||
enum Simplifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting use of an enumeration as an effective namespace, rather than a struct that’s more commonly used for this purpose but comes with initializers. This pattern might be worth following elsewhere in the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are passing now that I’ve upgraded the tvOS Bitrise application to Xcode 12.5.
6ecf55b updates the readme to require Xcode 12.0. |
c120ea5 adds the test fixtures to the Xcode project for Carthage-based builds. |
This branch fixes these issues introduced in the port of turf-simplify from #138:
LineString.simplify
withhighestQuality = false
was broken as it was usingstart.coordinate
in one formula when it should have usedcoordinate
Polygon.simplify
ignoredhighestQuality = false
as it first assigned theself.coordinates
to a local variable, then simplified theself.coordinates
, but then passed the previous local variable to the Douglas-Peucker algorithm. That means it always returned results as ifhighestQuality = true
was set.Polygon.simplify
forgot to square the tolerance to the Douglas-Peucker algorithm (LineString.simplify
did it correctly)Polygon.simplify
didn't simplify if any of the exterior/interior polygons was a triangle; now it just skips simplification of the triangle but simplifies the others.I've also refactored the code to remove the code duplication between
LineString.swift
andPolygon.swift
, and ported the turf-simplify test suite using the in/out directory -- excluding the test cases for MultiLineString and MultiPolygon as they aren't supported yet.