Skip to main content

encode_simplified_batch

Function encode_simplified_batch 

Source
pub fn encode_simplified_batch(
    coordinates_batch: &[Vec<LngLat>],
    tolerance_m: f64,
    method: SimplifyMethod,
    precision: u8,
) -> PolylineResult<Vec<String>>
Expand description

Simplifies and encodes multiple coordinate sequences to polyline strings in parallel.

This combines simplification and encoding in a single operation for efficiency.

§Arguments

  • coordinates_batch - A slice of coordinate sequences to simplify and encode
  • tolerance_m - Simplification tolerance in meters
  • method - Distance calculation method for simplification
  • precision - Number of decimal places to preserve (typically 5 or 6)

§Examples

use rapidgeo_polyline::batch::encode_simplified_batch;
use rapidgeo_simplify::SimplifyMethod;
use rapidgeo_distance::LngLat;

let batch = vec![
    vec![LngLat::new_deg(-120.2, 38.5), LngLat::new_deg(-120.95, 40.7)],
    vec![LngLat::new_deg(-126.453, 43.252), LngLat::new_deg(-122.4194, 37.7749)],
];

let encoded_batch = encode_simplified_batch(&batch, 1000.0, SimplifyMethod::GreatCircleMeters, 5).unwrap();
assert_eq!(encoded_batch.len(), 2);