本文整理汇总了C#中CLLocation.DistanceFrom方法的典型用法代码示例。如果您正苦于以下问题:C# CLLocation.DistanceFrom方法的具体用法?C# CLLocation.DistanceFrom怎么用?C# CLLocation.DistanceFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLLocation
的用法示例。
在下文中一共展示了CLLocation.DistanceFrom方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateLocation
public static void UpdateLocation(GPSLocate ms, CLLocation newLocation)
{
ms.LblAltitude.Text = newLocation.Altitude.ToString () + " meters";
ms.LblLongitude.Text = newLocation.Coordinate.Longitude.ToString () + "º";
ms.LblLatitude.Text = newLocation.Coordinate.Latitude.ToString () + "º";
ms.LblCourse.Text = newLocation.Course.ToString () + "º";
ms.LblSpeed.Text = newLocation.Speed.ToString () + " meters/s";
// get the distance from here to paris
ms.LblDistanceToParis.Text = (newLocation.DistanceFrom(new CLLocation(48.857, 2.351)) / 1000).ToString() + " km";
var x1 =Convert.ToDouble( "40.023408");
var y1 =Convert.ToDouble( "40.643127");
var x2 =Convert.ToDouble( "30.753657");
var y2 = Convert.ToDouble("30.038635");
var longdute =newLocation.Coordinate.Longitude;
var latidute = newLocation.Coordinate.Latitude;
ms.checkIt.Clicked+= (sender, e) => {
if (longdute > x2 && longdute < x1 && latidute > y2 && latidute < y1)
new UIAlertView("Ankara Dışındasın", "Konum : " + longdute + " " + latidute, null, "OK", null).Show();
else
new UIAlertView("Ankara İçerisindesin", "Konum : " + longdute + " " + latidute, null, "OK", null).Show();
};
}
示例2: getAllBusStops
//Caution: If radius is too large results will be HUGE!
//radius in meters
public IEnumerable<BusStop> getAllBusStops(CLLocation aboutLoc, double radius)
{
List<BusStop> stops = new List<BusStop>(30);
using (LumenWorks.Framework.IO.Csv.CsvReader csv = new LumenWorks.Framework.IO.Csv.CsvReader(getReader("stops.txt"),true)) {
while (csv.ReadNextRecord()){
CLLocation loc = new CLLocation(double.Parse(csv["stop_lat"]), double.Parse(csv["stop_lon"]));
if (loc.DistanceFrom(aboutLoc)<=radius)
stops.Add(new BusStop(csv["stop_name"],int.Parse(csv["stop_id"]), loc));
loc.Dispose();
}
return stops;
}
}
示例3: getClosestStop
public BusStop? getClosestStop(CLLocation aboutLoc)
{
int closestId = -1;
double closestDist=double.MaxValue;
using (CsvReader csv = new CsvReader(getReader("stops.txt"),true)) {
while (csv.ReadNextRecord()){
CLLocation loc = new CLLocation(double.Parse(csv["stop_lat"]), double.Parse(csv["stop_lon"]));
if (loc.DistanceFrom(aboutLoc)<=closestDist)
closestId=int.Parse(csv["stop_id"]);
loc.Dispose();
}
}
return (closestId==-1)?null:getStopInfo(closestId);
}
示例4: Distance
public double Distance(double lat, double lng, XLocation b)
{
var firstPoint = new CLLocation(lat, lng);
var secondPoint = new CLLocation(b.Latitude, b.Longitude);
return firstPoint.DistanceFrom(secondPoint);
}
示例5: UpdateLocation
static public void UpdateLocation (IMainScreen ms, CLLocation newLocation)
{
ms.LblAltitude.Text = newLocation.Altitude.ToString () + " meters";
ms.LblLongitude.Text = newLocation.Coordinate.Longitude.ToString () + "º";
ms.LblLatitude.Text = newLocation.Coordinate.Latitude.ToString () + "º";
ms.LblCourse.Text = newLocation.Course.ToString () + "º";
ms.LblSpeed.Text = newLocation.Speed.ToString () + " meters/s";
// get the distance from here to paris
ms.LblDistanceToParis.Text = (newLocation.DistanceFrom(new CLLocation(48.857, 2.351)) / 1000).ToString() + " km";
}
示例6: nearestStore
//Metodo de busqueda de la tienda mas cercana.
public ProductSearchDetailService nearestStore(CLLocation location, List<ProductSearchDetailService> stores){
Console.WriteLine (""+location.Coordinate.Latitude);
ProductSearchDetailService nearStore = stores.ElementAt (0);
foreach (ProductSearchDetailService store in stores) {
if( (location.DistanceFrom(new CLLocation(Double.Parse(store.tienda_latitud),Double.Parse(store.tienda_longitud)))) < (location.DistanceFrom(new CLLocation(Double.Parse(nearStore.tienda_latitud), Double.Parse(nearStore.tienda_longitud)))) ) {
nearStore = store;
}
}
return nearStore;
}
示例7: nearestStore
//Metodo de busqueda de la tienda mas cercana.
public StoresService nearestStore(CLLocation location, List<StoresService> stores){
StoresService nearStore = stores.ElementAt (0);
foreach (StoresService store in stores) {
if( (location.DistanceFrom(new CLLocation(Double.Parse(store.latitud),Double.Parse(store.longitud)))) < (location.DistanceFrom(new CLLocation(Double.Parse(nearStore.latitud), Double.Parse(nearStore.longitud)))) ) {
nearStore = store;
}
}
return nearStore;
}