You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The feature request seeks for a function to add points to a linestring with an approximate equidistance.
The screenshot below illustrates the functionality (max_dist = 2):
Number of points to add per segment (additional to the existing points) = ceiling(length(segment)/max_dist) -1
Maybe it would also be helpful to define alternatively min_dist
The text was updated successfully, but these errors were encountered:
Sketch of something that seems to work, based on a max_dist input:
usecrate::LineInterpolatePoint;letmut new_line = vec![];
linestring.lines().for_each(|line| {
new_line.push(line.start_point());let num_segments = ((line.euclidean_length() / max_dist).ceil()asusize) - 1;if num_segments > 0{// distance "unit" for this line based on how many new segments we needlet frac = 1.0 / (num_segments + 1)asf64;(0..num_segments).enumerate().for_each(|(seg, _)| {// multiply distance unit by 1-indexed segment number to get correct offsetlet np = line
.line_interpolate_point(frac *(seg + 1)asf64).unwrap();
new_line.push(np);})}});// we're done, push the last coordinate on to finish
new_line.push(linestring.points().last().unwrap());let nls = LineString::from(new_line);
It'd be nice to be able to pre-allocate new_line's capacity, but I can't think of a good heuristic off the top of my head.
The feature request seeks for a function to add points to a linestring with an approximate equidistance.
The screenshot below illustrates the functionality (
max_dist
= 2):Number of points to add per segment (additional to the existing points) =
ceiling(length(segment)/max_dist) -1
Maybe it would also be helpful to define alternatively
min_dist
The text was updated successfully, but these errors were encountered: