|
@@ -1,4 +1,5 @@
|
|
|
using System;
|
|
|
+using System.Drawing;
|
|
|
|
|
|
namespace InABox.Core
|
|
|
{
|
|
@@ -35,11 +36,11 @@ namespace InABox.Core
|
|
|
[TextBoxEditor(Editable = Editable.Hidden, Visible = Visible.Optional)]
|
|
|
public string Address { get; set; }
|
|
|
|
|
|
- public double DistanceTo(Location location, UnitOfLength unitOfLength)
|
|
|
+ public static double DistanceBetween(PointF from, PointF to, UnitOfLength unitOfLength)
|
|
|
{
|
|
|
- var baseRad = Math.PI * Latitude / 180;
|
|
|
- var targetRad = Math.PI * location.Latitude / 180;
|
|
|
- var theta = Longitude - location.Longitude;
|
|
|
+ var baseRad = Math.PI * from.Y / 180;
|
|
|
+ var targetRad = Math.PI * to.Y / 180;
|
|
|
+ var theta = from.X - to.X;
|
|
|
var thetaRad = Math.PI * theta / 180;
|
|
|
|
|
|
var dist =
|
|
@@ -52,6 +53,15 @@ namespace InABox.Core
|
|
|
|
|
|
return unitOfLength.ConvertFromMiles(dist);
|
|
|
}
|
|
|
+
|
|
|
+ public double DistanceTo(Location location, UnitOfLength unitOfLength)
|
|
|
+ {
|
|
|
+ return DistanceBetween(
|
|
|
+ new PointF((float)Longitude, (float)Latitude),
|
|
|
+ new PointF((float)location.Longitude, (float)location.Latitude),
|
|
|
+ unitOfLength
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
public void CopyFrom(Location location)
|
|
|
{
|