It uses a combination of Douglas-Peucker and Radial Distance algorithms. Works both on browser and server platforms.
★★ Star our github repository to help us! ★★
Polyline simplification dramatically reduces the number of points in a polyline while retaining its shape, giving a huge performance boost when processing it and also reducing visual noise. For example, it's essential when rendering a 70k-points line chart or a map route in the browser using MapKit.
- iOS 8.0, watchOS 2.0, tvOS 9.0
- Swift 5.x+
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
SwiftSimplify is available through CocoaPods. To install it, simply add the following line to your Podfile:
Usage is pretty straightforward: in fact you need just call the SwiftSimplify's class method simplify by passing your configuration:
let allPoints: [Point2DRepresentable] = ... let simplifiedPoints = SwiftSimplify.simplify(allPoints, tolerance: tolerance)
Allowed parameters are:
points: An array of points. SwiftSimplify supports Swift's generic so you can pass an array of objects which are conforms to
CLLocationCoordinate2Dobjects supports it).
tolerance: (1 by default) Affects the amount of simplification (in the same metric as the point coordinates)
highQuality: (false by default) Excludes distance-based preprocessing step which leads to highest quality simplification but runs ~10-20 times slower.
Daniele Margutti, email@example.com
You can reach me on twitter @danielemargutti.
My web site is danielemargutti.com
SwiftSimplify is available under the MIT license. See the LICENSE file for more info.
You may find interesting
SwiftSimplify 1.1.0 - Swift 5.1+ - 2020-10-05 19:15:13
Released on 2019-09-14
- #17 [NEW] Added support for Swift 5.1+
SwiftSimplify 1.1.1 - Swift 5.3+ - 2020-10-05 19:13:43
Released on 2020-10-05
- #20 [NEW] Added support for Swift 5.3
SwiftSimplify 0.2.0 - Swift 3 - 2019-06-28 16:54:55
SwiftSimplify 1.0.0 - Swift 5.0+ - 2019-06-28 16:54:41
RELEASED ON: 2019-06-28
- Swift 5 compatibility
UIBezierPathsmooth drawing method