-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement LineString simplification #55
Conversation
This trait currently uses the Ramer–Douglas–Peucker algorithm to simplify a LineString, while preserving its overall shape
assert_eq!(dist, 0.7071067811865475); | ||
} | ||
#[test] | ||
fn rdp_test() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a test doing simplify
on an empty LineString
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or should we expect all LineString
s to have at least two points? If so, we should make it explicit in the doc comment and add an assert
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. A 2-point LineString
can't be simplified anyway, and both it and an empty LineString
are valid, so it makes sense to me to just return them both unmodified.
Return it unmodified
These can't be simplified, so the output should be identical to the input
Everything here looks good to me, is this still a WIP? |
No, I'm pretty happy with it. How do you feel about the thoroughness of the tests, though? I feel like some tests for pathological input (tiny epsilon, gigantic LineString) would probably be a good idea at some point, although in the latter case that should probably happen further up the chain. |
Sounds great, thanks for this! 🎊 |
\o/ |
:D One of these I want to get some sort of basic Rust GUI for geo data (maybe written in conrod) so that we can visualize all these rust-geo algorithms and operations. |
This trait currently uses the Ramer–Douglas–Peucker algorithm to
simplify a LineString (see #54), while preserving its overall shape.
This is WIP, for two reasons:
rdp()
currently usesunwrap()
, because thefirst()
andlast()
methods on slices returnOption
. It's not immediately clear to me how these could fail in this context, but all input is welcome.point_line_distance()
andrdp()
are implemented as helper functions, and called by theSimplify
trait. This is mainly becauserdp()
is recursive and uses sub-slices of its initial input, which AFAICS can't be easily obtained from aLineString
.