Skip to content

AiwendilsCode/Simplification.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simplification.NET

C# wrapper for Rust library by urschrei for Ramer-Douglas-Peucker and Visvalingam-Whyatt algorithms.

Usage

using Simplification.Algorithms;

double[][] input = [
    [0.0, 0.0],
    [5.0, 4.0],
    [11.0, 5.5],
    [17.3, 3.2],
    [27.8, 0.1],
];

ISimplificationAlgorithm rdpAlgorithm = new RdpAlgorithm();

// For RDP, Try an epsilon of 1.0 to start with. Other sensible values include 0.01, 0.001
double[][] simplified = rdpAlgorithm.Simplify(input, 1.0); // returns simplified data
UIntPtr[] simplifiedIndices = rdpAlgorithm.SimplifyIdx(input, 1.0); // returns simplified indices

ISimplificationAlgorithm visvAlgorithm = new VisvalingamWhyattAlgorithm();

simplified = visvAlgorithm.Simplify(input, 1.0); // returns simplified data
simplifiedIndices = visvAlgorithm.SimplifyIdx(input, 1.0); // returns simplified indices

simplified = ((VisvalingamWhyattAlgorithm)visvAlgorithm)
    .PreserveTopologySimplify(input, 1.0); // returns simplified data, while preserving topology

Benchmarks

Ramer-Douglas Peucker algorithm

RDP_benchmark

Visvalingam-Whyatt algorithm

Visvalingam_benchmark

Simplified line

Before simplification

Line_before_simplification

After simplification

RDP 5 tolerance RDP_simplified

Visvalingam 10 tolerance Visvalingam_simplified

Visvalingam preserve topology 10 tolerance VisvalingamPreserveTopology_simplified

Package

https://www.nuget.org/packages/Simplification/1.0.2

About

RDP and Visvalingam-Whyatt algorithms for c#.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published