pub fn simplify_dp_mask(
pts: &[LngLat],
tolerance_m: f64,
method: SimplifyMethod,
mask: &mut Vec<bool>,
)Expand description
Generate a boolean mask indicating which points to keep during simplification.
This is useful when you need to know which original points were kept, or when you want to apply the same simplification to multiple related datasets.
§Arguments
pts- Input polyline pointstolerance_m- Maximum perpendicular distance threshold in meters (or coordinate units for EuclidRaw)method- Distance calculation method to usemask- Output boolean vector (will be resized to match input length)
§Examples
use rapidgeo_distance::LngLat;
use rapidgeo_simplify::{simplify_dp_mask, SimplifyMethod};
let points = vec![
LngLat::new_deg(-122.0, 37.0),
LngLat::new_deg(-121.5, 37.5),
LngLat::new_deg(-121.0, 37.0),
];
let mut mask = Vec::new();
simplify_dp_mask(
&points,
1000.0,
SimplifyMethod::GreatCircleMeters,
&mut mask,
);
assert_eq!(mask.len(), points.len());
assert!(mask[0]); // First endpoint always kept
assert!(mask[2]); // Last endpoint always kept
// Apply mask to get simplified points
let simplified: Vec<_> = points
.iter()
.zip(mask.iter())
.filter_map(|(point, &keep)| if keep { Some(*point) } else { None })
.collect();