npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simplify-ts

v1.0.2

Published

Simplification of a 2D-polyline or a 3D-polyline.

Downloads

11,958

Readme

simplify-ts

The multi-flavor TypeScript port of the "high-performance JavaScript 2D/3D polyline simplification" library Simplify.js - a combination of basic radial distance determination and the Douglas-Peucker algorithm.

Three different importable flavors:

  1. Object-based point collections - Array<{x: number, y: number}>
  2. Array-based point collections - Array<[number, number]>
  3. LatLong-based point collections - Array<{latitude: number, longitude: number}>

Install

npm install --save simplify-ts

Compiled JavaScript and types are included with your NPM install. To run benchmarks, tests and custom builds, use git to clone the repository (then also run npm install in the cloned repository to get the required dependencies for development.)

git clone https://github.com/METACEO/simplify-ts.git

You will then find the benchmarks, src and test folders referenced in the package.json file.

Usage

Object-based point collections:

import {
    Simplify,
    ISimplifyObjectPoint
} from 'simplify-ts';

const points: ISimplifyObjectPoint[] = [ {x: 1, y: 2} /* ... */ ];
const tolerance: number = 0.5;
const highQuality: boolean = true;

const simplified_result = Simplify(points, tolerance, highQuality);

Array-based point collections:

import {
    SimplifyAP,
    ISimplifyArrayPoint
} from 'simplify-ts';

const points: ISimplifyArrayPoint[] = [ [1, 2] /* ... */ ];
const tolerance: number = 0.5;
const highQuality: boolean = true;

const simplified_result = SimplifyAP(points, tolerance, highQuality);

LatLong-based point collections:

import {
    SimplifyLL,
    ISimplifyLatLongPoint
} from './src';

const points: ISimplifyLatLongPoint[] = [ {latitude: 1, longitude: 2} /* ... */ ];
const tolerance: number = 0.5;
const highQuality: boolean = true;

const simplified_result = SimplifyLL(points, tolerance, highQuality);

Tests

Run npm test in the project's repository.

[jamesallen@dev simplify-ts]$ npm test

> [email protected] test /home/jamesallen/simplify-ts
> node test/test.js | faucet

✓ simplifies object-points correctly with the given tolerance
✓ simplifies object-points correctly with the given tolerance and high quality
✓ just return the object-points if it has only one point
✓ just return the object-points if it has no points
✓ simplifies array-points correctly with the given tolerance
✓ simplifies array-points correctly with the given tolerance and high quality
✓ just return the array-points if it has only one point
✓ just return the array-points if it has no points
✓ simplifies latlong-points correctly with the given tolerance
✓ simplifies latlong-points correctly with the given tolerance and high quality
✓ just return the latlong-points if it has only one point
✓ just return the object-points if it has no points
# tests 12
# pass  12
✓ ok

Benchmarks

Run npm run bench in the project's repository.

[jamesallen@dev simplify-ts]$ npm run bench

> [email protected] bench /home/jamesallen/simplify-ts
> node ./benchmarks/1k-objectPoints.js && node ./benchmarks/1k-arrayPoints.js && node ./benchmarks/1k-latlongPoints.js

Benchmarking simplify on 1118 object-points...
simplify (HQ) x 8,918 ops/sec ±0.42% (92 runs sampled)
simplify x 14,739 ops/sec ±0.52% (93 runs sampled)
Benchmarking simplify on 1118 array-points...
simplify (HQ) x 7,506 ops/sec ±0.47% (92 runs sampled)
simplify x 12,023 ops/sec ±0.55% (92 runs sampled)
Benchmarking simplify on 1118 latlong-points...
simplify (HQ) x 9,005 ops/sec ±0.53% (89 runs sampled)
simplify x 14,018 ops/sec ±0.55% (92 runs sampled)