GithubHelp home page GithubHelp logo

malcommac / swiftsimplify Goto Github PK

View Code? Open in Web Editor NEW
300.0 10.0 34.0 3.06 MB

🥷 High-performance polyline simplification library - port of simplify.js

License: MIT License

Swift 94.94% Ruby 5.06%
polyline swift-library simplifyjs polyline-simplification polyline-algorithm cgpoint cllocationcoordinate2d

swiftsimplify's Issues

Pod doesn't work

After installing the pod I tried calling it like I would another pod (say like Alamofire) and the methods were not accessible. It did work, however, if I simply added it to my project.

Use projected coordinates when simplifying CLLocationCoordinate2D data

If you do calculations based on latitude/longitude, then:

  1. You get different scales on the x/y-axis which leads to weird simplification logic
  2. You can't relate to the tolerance value

The solution would be to e.g. convert it to MKMapPoints before simplification and if the data points are MKMapPoints you could interpret the tolerance value as meters and it would be both correct (1 above) and use a tolerance that you can relate to (2 above).

[Enhancement]check count before func simplify

In func simplifyRadialDistance, it use force unwrap var prevPoint: T = points.first! and var point: T = points[1]. This would cause crash when input parameter points is just 0 or 1 count.
Although I add something like guard line.count > 1 before use SwiftSimplify.simplify to avoid crash, hope this check could add, thank you very much.

Extensions not public

Referencing instance method 'simplify(tolerance:highestQuality:)' on 'Array' requires the types 'CLLocationCoordinate2D' and 'Point2DRepresentable' be equivalent

When the lib is added to a project via CocoaPods, the extensions on CLLocationCoordinate2D etc are not visible.

Tolerance not working as intended?

Hi all I'm currently using SwiftSimplify to reduce the number of coordinates while running, I'm testing runs that go on for about 1 KM but after using Simplify and giving it about 20 points, all it does is return start and end coordinates.

Simplify is currently like this.
SwiftSimplify.simplify(self.activityPolyline!, tolerance: 10, highQuality: false)

Giving it an array of coordinates like this:
[(37.330075379999997, -122.02126848), (37.330058049999998, -122.02100589), (37.33000706, -122.02074717000001), (37.329941720000001, -122.02053031), (37.329871330000003, -122.0202987), (37.329823259999998, -122.02006170999999), (37.329705570000002, -122.01986866), (37.329525689999997, -122.01982409), (37.329339840000003, -122.01980544), (37.329133579999997, -122.0197871), (37.328938319999999, -122.01979684), (37.328738469999998, -122.01980584), (37.328532039999999, -122.0198032), (37.32833935, -122.01980995), (37.32814552, -122.01983108), (37.327952580000002, -122.01982651), (37.327758189999997, -122.01980315), (37.327560220000002, -122.01974095), (37.327370989999999, -122.01972170000001), (37.327185819999997, -122.01971872), (37.326979710000003, -122.01972916)]

After simplify I get this:
[(37.330075379999997, -122.02126848), (37.326979710000003, -122.01972916)]

What am I doing wrong? The location manager is currently configured as follows:
locationManager.activityType = .fitness
locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
locationManager.distanceFilter = 20

Appreciate the help.

API for using ArraySlice

For my work I needed to keep array copies at a minimum (dealing with arrays with 100s of 1000s of points) and modified the code here to include an ArraySlice API for dealing with large subsets of the big arrays

Any interest in a pull request for that API? I wasn't sure how to handle the highestQuality parameter - in my use case I took it out to prevent an array copy but I think the simplifyRadialDistance method could be overloaded to slice the input array even thinner.

Returned array with only two values

Hi, I'm using the pods and when I try to simplify my [CCLocation2D] consisting in 2125 points the function return my an array with only 2 values.

I'm doing this:

let simplifiedCoordinates = SwiftSimplify.simplify(coordinates!, tolerance: 1.75) (I've tried also with 1 tolerance, but nothing change)

Error or less-than-ideal-naming on distance functions

public func distanceFrom(_ otherPoint: Self) -> Float {

These appear to be returning a standard Pythagoras result, but the result is not square rooted. AFAIK this is not meant to be the case but I haven't had time to dig (I only know the DP algorithm at a distance).

If this is meant to be a linear distance, it looks like it needs to be square rooted. Else it might help to modify the function names to indicate that this is a squared result - otherwise it looks like a straightforward distance calculation function.

Swift 2.0 & iOS 7

  1. I found out that it perfect works on iOS7. Why you decided to limit podspec on iOS 8+?
  2. Code is not optimized for Swift 2.0

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.