Coder Social home page Coder Social logo

swiftsimplify's Introduction

SwiftSimplify

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

Description

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

Requirements

  • iOS 8.0+ / Mac OS X 10.10+
  • Xcode 6.3
  • Swift 1.2

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, [email protected] 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.

swiftsimplify's People

Contributors

malcommac avatar matvdg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.