Commit 24f6a494 authored by Uwe Wienkop's avatar Uwe Wienkop

Berechnung der Höchstgeschwindigkeit hinzugefügt.

parent 08b42e79
This diff is collapsed.
......@@ -89,12 +89,29 @@ namespace _01GPS_Auswertung
UTMNorthing += 10000000.0; //10000000 meter offset for southern hemisphere
}
/// <summary>
/// Berechnet den Abstand zwischen zwei GpsPunkten in Metern
/// </summary>
/// <param name="p1">1. GPS-Punkt</param>
/// <param name="p2">2. GPS-Punkt</param>
/// <returns>Der Abstand in Meter</returns>
public static double GpsDistance(GpsPunkt p1, GpsPunkt p2)
{
double dx = p1.x - p2.x;
double dy = p1.y - p2.y;
return Math.Sqrt(dx * dx + dy * dy);
}
/// <summary>
/// Berechnet die zwischen zwei Punkten gefahrene Geschwindigkeit
/// </summary>
/// <param name="p1">1. GPS-Punkt</param>
/// <param name="p2">2. GPS-Punkt</param>
/// <returns>Geschwindigkeit in km/h</returns>
public static double GpsVelocity(GpsPunkt p1, GpsPunkt p2)
{
return GpsDistance(p1, p2) / (p2.dt - p1.dt).TotalSeconds * 3.6;
}
public double GpsDistance2(GpsPunkt p2)
{
double dx = x - p2.x;
......@@ -111,11 +128,29 @@ namespace _01GPS_Auswertung
public double RouteLength {
get
{
return GpsPunkt.GpsDistance(gpspos[0], gpspos[anzPos - 1]);
//return GpsPunkt.GpsDistance(gpspos[0], gpspos[anzPos - 1]);
//return gpspos[0].GpsDistance(gpspos[anzPos - 1]);
double len = 0;
for (int i = 1; i < anzPos; i++)
len+= GpsPunkt.GpsDistance(gpspos[i-1], gpspos[i]);
return len;
}
}
public double MaxVelocity
{
get
{
double maxVel = -1;
for (int i = 1; i < anzPos; i++)
{
double vel = GpsPunkt.GpsVelocity(gpspos[i - 1], gpspos[i]);
if (vel > maxVel)
maxVel = vel;
}
return maxVel;
}
}
public GpsManager(string name)
{
StreamReader sr = new StreamReader(name);
......@@ -140,6 +175,8 @@ namespace _01GPS_Auswertung
{
GpsManager NReg = new GpsManager(@"..\..\GPS_Daten.txt");
Console.WriteLine(NReg.RouteLength);
Console.WriteLine(NReg.MaxVelocity);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment