mourner / simplify-js Goto Github PK
View Code? Open in Web Editor NEWHigh-performance JavaScript polyline simplification library
Home Page: http://mourner.github.io/simplify-js
License: BSD 2-Clause "Simplified" License
High-performance JavaScript polyline simplification library
Home Page: http://mourner.github.io/simplify-js
License: BSD 2-Clause "Simplified" License
I convert your code to a language I'm using.
But it's not possible to get only the 'important' points if needed.
Maybe I can't use your code, maybe I can, I don't know.
Look at this image: http://s16.postimg.org/afccosymd/test_col.png
I have the exact outline coordinate's, what I need is only the corners (in this case)
So 16 x,y points.
When I set the tolerance using your script very high, it will create gaps inside the corners...
I'm looking to reduce the size / complexity of mbtiles.
i have got array of points (x,y) and i need to reduce points of polyline.
const rawLine = '109.550362,18.337531;109.550401,18.337592;.......more than 1k points;109.561543,18.238463;109.561631,18.238322'
const line = rawLine.split(";").map((point) => {
const [x, y] = point.split(",");
return {
x: Number(x),
y: Number(y),
};
});
const simplified = simplify(line, {
tolerance: 0.001,
});
always return 2 points.
what it is not work?
I've noticed a small bug in the simplify() function. I've had trouble with the resulting coordinates almost always being 4-7 length polygons. The answer is to inflate the coordinates before and after, e.g. by a factor of 1000. Only once these values pass through the function are the results useful...
Just a thought at this point, but I'm curious whether this could be substantially faster if some functions could be re-written to be asm.js-compatible. Do you have any thoughts?
hi, is there a way to simplify geoJSON with this awesome algorithm??
It should be possible to allow for configuration of the location field without modifying source code without adding overhead. This could be achieved through having a function that returns a function. https://davidwalsh.name/javascript-functions
Hi,
Would like to see if the library supports self-intersecting paths?
I have been created a dart version
https://github.com/MorochoRochaDarwin/douglas-peucker-dart
I would like to add the repo in README.md
Hi,
Just to tell you I've recently ported your simplify.js library on Swift 1.2 (OSX/iOS) if you want to add it to the porting list in readme file. You can find it https://github.com/malcommac/SwiftSimplify
simplify([])
returns [undefined]
, and simplify([{x: 0, y: 0}])
returns [{x: 0, y: 0}, undefined]
. I would expect these to return []
and [{x: 0, y: 0}]
respectively.
I'm using the lib in a project I'm on:
It works flawlessly and is pretty fast(which is critical, I'm working with very tight performance tolerances)
I'm using it to simplify a pencil line that a user can draw on a canvas. Having less points makes it ideal for real-time collaboration since there's not too much data to transmit between each client for each path.
However, I'd love if there was also smoothing available through the lib.
Most of the smoothing algorithms won't really work since they are distorting the original path.
However Centripetal Catmull–Rom smoothing can actually work since it:
Are there any plans to allow such sort of smoothing through Simplify.js?
An image for comparing between the different Catmull-Rom interpolations:
Love this great little utility.
I'm working with a sketch application that receives pressure data, and applies it to the resulting stroke (width and/or density...etc). I suppose it could considered x, y & z axis data.
I'd love to simplify the curves from the user's raw input, but I need to reapply the pressure data, along with the point locations for the idealized curve.
Do you have any suggestions how that could be done with simplify-js? Any help would be appreciated. :)
I have a problem with the simplify function. I have an array with latitude and longitude of each point. It's like ["45.00", "11.20"]. I noticed that in every example are used values like 200.
i think i will need to convert them. How can i convert from lat and lon to x and y?
Thank you
This may be by design, but should copies of the original points be returned instead of references?
For example:
> a = [{x:0,y:0},{x:1,y:1},{x:2,y:2}];
[object Object],[object Object],[object Object]
> b = simplify(a, 0.8, false);
[object Object],[object Object]
> b[0].x = 5;
5
> a[0].x
5
I would be happy to make a Pull Request, but I wanted to see if this is your preference first.
Would it be possible to add simplification for curves? Simplification for curves would be an unbelievable asset and would draw so much more attention to this library.
Hi I am using the latest version of this lib but I am having issues
My input data are lat,long and I do convert them to x,y
const b = positions.map((position) => {
return {x: position.latitudeDegrees , y: position.longitudeDegrees}
});
Then
const a = simplify(b, 0.1, true);
However the result only has a 2 item array.
(also the lib is not published related to latest master)
Is there a simple way to consider / include time series data (or an arbitrary extra component/unit) or is this better left to post processing? E.g something that could solve for the following:
// a simple track
const timed = [
{ x: 0, y: 0, t: 0},
{ x: 0, y: 1, t: 1}, // speed == 1/t
{ x: 0, y: 1, t: 2}, // speed == 0
{ x: 1, y: 0, t: 3}, // speed == 1
];
simplify(timed, 0.5);
/* Shows losing time context through over-simplification
[
{ x: 0, y: 0, t: 0},
{ x: 0, y: 1, t: 1}, // speed == 1
{ x: 1, y: 0, t: 3}, // speed == 0.5
];
*/
The version published on NPM is 1.2.4
, as is the latest version in this repository, but the TypeScript definitions do not match. The type definitions in the NPM package is missing the generic parameter.
New to simplify. Was curious if there would be a recommended approach to supplying a zoom level to supply to simplify?
When adding this package to a project via
"simplify-js": "latest",
It does not have the TypeScript definition file.
When operating on large data sets (array of 20K+ {x,y} objects), the library throws the stack size exceeded exception.
angular.js:13708 RangeError: Maximum call stack size exceeded
at simplifyDPStep (simplify.js:71)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
at simplifyDPStep (simplify.js:85)
you should upload it to jam it dosn't look like it needs any modifications for it to work with jam.
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.