PolylineSimplifier 1.0.1
See the version list below for details.
dotnet add package PolylineSimplifier --version 1.0.1
NuGet\Install-Package PolylineSimplifier -Version 1.0.1
<PackageReference Include="PolylineSimplifier" Version="1.0.1" />
<PackageVersion Include="PolylineSimplifier" Version="1.0.1" />
<PackageReference Include="PolylineSimplifier" />
paket add PolylineSimplifier --version 1.0.1
#r "nuget: PolylineSimplifier, 1.0.1"
#:package PolylineSimplifier@1.0.1
#addin nuget:?package=PolylineSimplifier&version=1.0.1
#tool nuget:?package=PolylineSimplifier&version=1.0.1
PolylineSimplifier
An efficient .NET library for simplifying 2D polylines using the Ramer-Douglas-Peucker algorithm. It reduces the number of points in a curve while preserving its visual shape.
Usage
Installation
dotnet add package PolylineSimplifier
Example
using PolylineSimplifier;
public record Point(float X, float Y);
List<Point> points = new List<Point>
{
new(0, 0), new(1, 0.1f), new(2, -0.1f), new(3, 5), new(4, 6),
new(5, 7), new(6, 8.1f), new(7, 9), new(8, 9), new(9, 9)
};
List<Point> simplified = RamerDouglasPeucker2D.Simplify(
points,
epsilon: 1.0f,
getX: p => p.X,
getY: p => p.Y);
Parameters
| Parameter | Description |
|---|---|
points |
The input polyline as a list of points |
epsilon |
Maximum perpendicular distance tolerance. Larger values = more simplification |
getX |
Function to extract the X coordinate from a point |
getY |
Function to extract the Y coordinate from a point |
Benchmarks
Measured on an AMD Ryzen 5 7600X Processor:
| Method | Mean | Allocated | | ------------- | -------: | --------: | | 100 Points | 1.40 μs | 2.11 KB | | 1000 Points | 22.9 μs | 15,6 KB | | 10000 Points | 757 μs | 143 KB | | 100000 Points | 17200 μs | 1440 KB | <small>Note: Epsilon = 1.0 for all benchmarks. A larger epsilon generally decreases the execution time an allocates less memory.</small>
Running Benchmarks
git clone git@github.com:jonataneckeskog/PolylineSimplifier.git
cd PolylineSimplifier
dotnet run -c Release --project tests/PolylineSimplifier.Benchmarks
License
MIT License – see LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.