mirror of
https://github.com/farcasclaudiu/myfriendsaround.git
synced 2026-06-29 13:02:05 +03:00
offline images
friends list / select friend distance
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MyFriendsAround.WP7.Utils
|
||||
{
|
||||
public class Constants
|
||||
{
|
||||
public const string MYPICTURE_FILE_NAME = "myphoto.jpg";
|
||||
//viewmodels names
|
||||
public const string VM_MAIN = "MainViewModel";
|
||||
public const string VM_SETTINGS = "SettingsViewModel";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MyFriendsAround.WP7.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// The distance type to return the results in.
|
||||
/// </summary>
|
||||
public enum DistanceType { Miles, Kilometers };
|
||||
/// <summary>
|
||||
/// Specifies a Latitude / Longitude point.
|
||||
/// </summary>
|
||||
public struct Position
|
||||
{
|
||||
public double Latitude;
|
||||
public double Longitude;
|
||||
}
|
||||
|
||||
public class Haversine
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the distance in miles or kilometers of any two
|
||||
/// latitude / longitude points.
|
||||
/// </summary>
|
||||
/// <param name=”pos1″></param>
|
||||
/// <param name=”pos2″></param>
|
||||
/// <param name=”type”></param>
|
||||
/// <returns></returns>
|
||||
public static double Distance(Position pos1, Position pos2, DistanceType type)
|
||||
{
|
||||
double R = (type == DistanceType.Miles) ? 3960 : 6371;
|
||||
double dLat = toRadian(pos2.Latitude - pos1.Latitude);
|
||||
double dLon = toRadian(pos2.Longitude - pos1.Longitude);
|
||||
double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
|
||||
Math.Cos(toRadian(pos1.Latitude)) * Math.Cos(toRadian(pos2.Latitude)) *
|
||||
Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
|
||||
double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a)));
|
||||
double d = R * c;
|
||||
return d;
|
||||
}
|
||||
/// <summary>
|
||||
/// Convert to Radians.
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
/// <returns></returns>
|
||||
private static double toRadian(double val)
|
||||
{
|
||||
return (Math.PI / 180) * val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user