private void assignSpeedEvaluation(SpeedEvaluation val) { speedInKmPerHour = val.speed; minSpeedInKmPerHour = val.minSpeed; maxSpeedInKmPerHour = val.maxSpeed; confidence = val.confidence; distance = val.distance; timeframe = val.timeframe; distanceAccuracy = val.distanceAccuracy; skipped = val.skipped; return; }
void UpdateSpeed() { heuristic = Heuristic.TWO_POINT; rawDistance = DistInKm(forelast, last); rawSpeed = SpeedInKmpH(rawDistance, TimeFrameInSeconds(forelast, last)); SpeedEvaluation sel = new SpeedEvaluation(); sel.minSpeed = 1f; sel.maxSpeed = -1f; for (int i = record.Count - 2; i >= 0; i--) { SpeedEvaluation val = new SpeedEvaluation(record[i], last, (record.Count - 2) - i); if (val.confidence > sel.confidence) { sel = val; } if (sel.confidence >= minConfidence) { break; } } assignSpeedEvaluation(sel); // Typically 0 confidence on speed readings // Signals overlapping samples as produced when the device // is not in motion. if (sel.confidence <= 0f) { speedInKmPerHour = 0f; heuristic = Heuristic.NO_CONFIDENCE; } }