Tiny high-performance Swift Polyline Simplification Library
Switch branches/tags
Clone or download
Latest commit 5fdfa3e Feb 27, 2017
Permalink
Failed to load latest commit information.
Example Added swift.version Nov 30, 2016
Pod swift 3 update Nov 21, 2016
.swift-version Added swift.version Nov 30, 2016
LICENSE First commit Jul 16, 2015
README.md Added links Feb 26, 2017
SwiftSimplify-logo-source.sketch Updated logo Jan 8, 2017
SwiftSimplify.podspec Added swift.version Nov 30, 2016
logo.png Updated logo Jan 8, 2017
screenshot.png First commit Jul 16, 2015

README.md

SwiftSimplify

[![CI Status](http://img.shields.io/travis/daniele margutti/SwiftSimplify.svg?style=flat)](https://travis-ci.org/daniele margutti/SwiftSimplify) Version License Platform

★★ Star our github repository to help us! ★★

SwiftSimplify

SwiftSimplify is a tiny high-performance Swift polyline simplification library ported from Javascript's Simplify.js. Original work come from Leaflet, a JS interactive maps library by Vladimir Agafonkin. It uses a combination of Douglas-Peucker and Radial Distance algorithms. Works both on browser and server platforms.

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.

SwiftSimplify

You also may like


Do you like SwiftRichString? I'm also working on several other opensource libraries.

Take a look here:

  • SwiftDate - Full features Dates & TimeZone management for iOS,macOS,tvOS and watchOS
  • Hydra - Promise, Async/Await on sterioids!
  • SwiftLocation - CoreLocation and Beacon Monitoring on steroid!
  • SwiftScanner - String scanner in pure Swift with full unicode support
  • SwiftSimplify - Tiny high-performance Swift Polyline Simplification Library
  • SwiftMsgPack - MsgPack Encoder/Decoder in Swit

Requirements

  • iOS 8.0+ / Mac OS X 10.10+
  • Xcode 8.0
  • Swift 3.0

Communication

  • 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.

Installation

SwiftSimplify is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SwiftSimplify"

Usage

Usage is pretty straightforward: in fact you need just call the SwiftSimplify's class method simplify by passing your configuration. Allowed parameters are:

class func simplify<T>(points: [T], tolerance: Float?, highQuality: Bool = false) -> [T];
  • points: An array of points. SwiftSimplify supports Swift's generic so you can pass an array of CGPoint ([CGPoint]) or array of CLLocationCoordinate2D ([CLLocationCoordinate2D).
  • 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.

Author

Daniele Margutti, me@danielemargutti.com You can reach me on twitter @danielemargutti. My web site is danielemargutti.com

License

SwiftSimplify is available under the MIT license. See the LICENSE file for more info.