-
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
Add the Length trait and implement Length for LineString and MultiLineString #44
Conversation
@@ -0,0 +1,82 @@ | |||
use num::{Float}; |
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.
You don't need the extra braces here: use num::Float;
let ipoints = vect.iter().zip(vect[1..].iter()); | ||
ipoints.fold(T::zero(), |total_length, (p1, p2)| total_length + p1.distance(&p2)) | ||
} | ||
} |
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.
This might be simpler if you used slice::windows
here.
@@ -26,26 +26,20 @@ pub trait Length<T, RHS = Self> { | |||
impl<T> Length<T> for LineString<T> | |||
where T: Float | |||
{ | |||
/// | |||
/// Length of a LineString. | |||
/// | |||
fn length(&self) -> T { | |||
let vect = &self.0; | |||
if vect.is_empty() || vect.len() == 1 { |
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.
This if
can be removed
Looks good to me, will wait until tonight to merge in case anyone else has comments. |
update to the last geo_types version
No description provided.