urschrei / simplification

Very fast Python line simplification using either the RDP or Visvalingam-Whyatt algorithm implemented in Rust
Other
168 stars 18 forks source link

One possible improvement for RDP? #10

Closed warrenbocphet closed 4 years ago

warrenbocphet commented 4 years ago

Hi, The algorithm works pretty fast and accurate. Kudo to you! One problem I see with all implementations of RDP (or RDP itself) is it does not handle the initial two end points well. For example:

import numpy as np
from simplification.cutil import simplify_coords
a = np.array([[0,1], [0,0], [2,0], [2,2], [0,2]])
b = simplify_coords(a)

This would result in b equals a, which is not what I expected. I would expect to have b consists of only 4 vertices. I understand that the theory behind RDP doesn't cover this case but I honestly can't think of a good solution for this other than checking for cases like this manually. Any better ideas?

urschrei commented 4 years ago

Any better ideas?

I don't, I'm afraid!