malcommac / swiftsimplify Goto Github PK
View Code? Open in Web Editor NEW🥷 High-performance polyline simplification library - port of simplify.js
License: MIT License
🥷 High-performance polyline simplification library - port of simplify.js
License: MIT License
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.
If you do calculations based on latitude/longitude, then:
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).
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.
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.
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.
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.
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)
SwiftSimplify/Package.swift The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99.
Should we an easy fix.
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.
You show time in milliseconds
/* Returns the current CoreAnimation absolute time. This is the result of
@available(iOS 2.0, *)
public func CACurrentMediaTime() -> CFTimeInterval
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.