pelorus 0.1.0

A high-performance GPS map-matching library for geospatial road network processing
Documentation
use geo::algorithm::euclidean_distance::EuclideanDistance;
use geo::Point;
use pelorus::matching::MatchedTrace;
use pelorus::road_network::RoadNetwork;

/// Test result analyzer
pub struct TestAnalyzer;

impl TestAnalyzer {
    /// Calculate matching accuracy by comparing matched segments to expected route
    pub fn calculate_matching_accuracy(
        matched_traces: &[MatchedTrace],
        _true_path: &[Point<f64>],
        _network: &RoadNetwork,
    ) -> f64 {
        if matched_traces.is_empty() {
            return 0.0;
        }

        // For now, return a simple accuracy based on how many points were matched
        let total_points: usize = matched_traces.iter().map(|t| t.points.len()).sum();
        let expected_points =
            matched_traces.iter().map(|t| t.points.len()).sum::<usize>();

        if expected_points == 0 {
            return 0.0;
        }

        // Simplified accuracy calculation - in a real implementation, this would
        // compare the matched segments to the expected route segments
        total_points as f64 / expected_points as f64
    }

    /// Calculate route length from matched points
    pub fn calculate_route_length(matched_traces: &[MatchedTrace]) -> f64 {
        let mut total_length = 0.0;

        for trace in matched_traces {
            for i in 1..trace.points.len() {
                let prev = &trace.points[i - 1].projected_point;
                let curr = &trace.points[i].projected_point;

                // Convert from degrees to meters (rough approximation)
                let distance_degrees = prev.euclidean_distance(curr);
                let distance_meters = distance_degrees * 111_000.0;
                total_length += distance_meters;
            }
        }

        total_length
    }

    /// Check if traces are continuous (no breaks detected)
    pub fn check_continuity(matched_traces: &[MatchedTrace]) -> bool {
        // If we have more than one trace, it means breaks were detected
        matched_traces.len() <= 1
    }
}