Subversion Repositories Projects

Rev

Rev 2289 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2289 Rev 2407
Line 435... Line 435...
435
         double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
435
         double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
436
         double dDistance = (Axis / 1000.0) * c;
436
         double dDistance = (Axis / 1000.0) * c;
437
         return dDistance;
437
         return dDistance;
438
      }
438
      }
Line -... Line 439...
-
 
439
 
439
 
440
 
440
      public double GetDistanceInPixels(GPoint point1, GPoint point2)
441
      public double GetDistanceInPixels(GPoint point1, GPoint point2)
441
      {
442
      {
442
         double a = (double)(point2.X - point1.X);
443
         double a = (double)(point2.X - point1.X);
Line 443... Line 444...
443
         double b = (double)(point2.Y - point1.Y);
444
         double b = (double)(point2.Y - point1.Y);
444
 
445
 
Line -... Line 446...
-
 
446
         return Math.Sqrt(a * a + b * b);
-
 
447
      }
-
 
448
 
-
 
449
        /// <summary>
-
 
450
        /// point from distance (in m) to point specified by latitude/longitude
-
 
451
        /// without bearing (bearing = 0°)
-
 
452
        /// for calculating radius of circle around a point
-
 
453
        /// The Haversine formula, http://www.movable-type.co.uk/scripts/latlong.html
-
 
454
        /// </summary>
-
 
455
        /// <param name="p1"></param>
-
 
456
        /// <param name="dDist"></param>
-
 
457
        /// <returns></returns>
-
 
458
        public static PointLatLng GetPointFromDistance(PointLatLng p1, double dDist)
-
 
459
      {
-
 
460
            double R = 6378137;
-
 
461
            double dBearing = 0;
-
 
462
            double dLat1InRad = p1.Lat * (Math.PI / 180);
-
 
463
            double dLong1InRad = p1.Lng * (Math.PI / 180);
-
 
464
 
-
 
465
            double dLat2InRad = Math.Asin(Math.Sin(dLat1InRad) * Math.Cos(dDist / R) + Math.Cos(dLat1InRad) * Math.Sin(dDist / R));
-
 
466
            double dLong2InRad = dLong1InRad + Math.Atan2(Math.Sin(dBearing) * Math.Sin(dDist / R) * Math.Cos(dLat1InRad), Math.Cos(dDist / R) - Math.Sin(dLat1InRad) * Math.Sin(dLat2InRad));
-
 
467
 
-
 
468
            double dLatitude = dLat2InRad / (Math.PI / 180);
-
 
469
            double dLongitude = dLong2InRad / (Math.PI / 180);
445
         return Math.Sqrt(a * a + b * b);
470
 
446
      }
471
            return new PointLatLng(dLatitude, dLongitude);
447
 
472
      }
448
      /// <summary>
473
      /// <summary>
449
      /// Accepts two coordinates in degrees.
474
      /// Accepts two coordinates in degrees.