- speedtracker.zip
- SpeedTracker
- Screenshots
- Screen01.png
- Screen02.png
- Screen03.png
- Screen04.png
- Screen05.png
- Screen06.png
- Screen07.png
- Screen08.png
- Screen09.png
- Screen10.png
- ScreenShot.jpg
- ScreenShot.png
- ScreenShot1.Jpeg
- ScreenShot2.Jpeg
- ScreenShot3.Jpeg
- speed.png
- SpeedTracker36x36.png
- SpeedTracker45x45.png
- SpeedTracker60x60.png
- SpeedTracker64x64.png
- SpeedTracker90x90.png
- shortcut.xml
- SpeedTracker.4.5.resharper.user
- SpeedTracker.Common
- SpeedTracker.ico
- SpeedTracker.jpg
- SpeedTracker.png
- SpeedTracker.sln
- SpeedTracker
- SpeedTrackerInstaller
- Release
- CabWiz.log
- SpeedTrackerInstaller.CAB
- SpeedTrackerInstaller.inf
- SpeedTrackerInstaller.vddproj
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using SpeedTracker.Common;
namespace SpeedTracker
{
class Utility
{
public delegate float SpeedConversionDelegate(float sourceSpeed);
public const double EarthRadiusInMiles = 3956.0;
public const double EarthRadiusInKilometers = 6367.0;
public const double EarthRadiusInNauticleMiles = 3437.67;
public static double ToRadian(double val) { return val * (Math.PI / 180); }
public static double ToDegree(double val) { return val * 180 / Math.PI; }
public static double DiffRadian(double val1, double val2) { return ToRadian(val2) - ToRadian(val1); }
/// <summary>
/// Calculate the distance between two geocodes. Defaults to using Miles.
/// </summary>
/// <summary>
/// Calculate the distance between two geocodes.
/// </summary>
public static double CalcDistance(double lat1, double lng1, double lat2, double lng2, double radius)
{
return radius * 2 * Math.Asin(Math.Min(1, Math.Sqrt((Math.Pow(Math.Sin((DiffRadian(lat1, lat2)) / 2.0), 2.0) + Math.Cos(ToRadian(lat1)) * Math.Cos(ToRadian(lat2)) * Math.Pow(Math.Sin((DiffRadian(lng1, lng2)) / 2.0), 2.0)))));
}
public static double CalcDistance(Location loc1, Location loc2, DistanceUnit unit)
{
double radius=0d;
switch (unit)
{
case DistanceUnit.Kilometers:
radius = EarthRadiusInKilometers;
break;
case DistanceUnit.Miles:
radius = EarthRadiusInNauticleMiles;
break;
case DistanceUnit.Knots:
radius = EarthRadiusInNauticleMiles;
break;
}
return CalcDistance(loc1.Latitude, loc1.Longitude, loc2.Latitude, loc2.Longitude, radius);
}
public static double CalcSpeed(Location loc1, Location loc2, DistanceUnit unit)
{
double distance = CalcDistance(loc1, loc2, unit);
var ts = loc1.TimeStamp.Subtract(loc2.TimeStamp);
return Math.Abs(distance/ts.TotalHours);
}
public static float KnotsToMph(float knots)
{
return knots*1.15077945f;
}
public static float KnotsToKmph(float knots)
{
return knots*1.852f;
}
public static float NoConversion(float knots)
{
return knots;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.