Exemplo n.º 1
0
        public void ShouldDistanceBeSame()
        {
            var distance  = VDNHLocation.DistanceTo(HouseLocation);
            var distance2 = HouseLocation.DistanceTo(VDNHLocation);

            Assert.AreEqual(distance, distance2, GeoPoint.Epsilon);
        }
Exemplo n.º 2
0
        public void Calculation_Fails_GivenGeoPointsWithDifferingReferenceEllipsoids()
        {
            GeoPoint p3 = GeoPoint.Parse(0.0, 0.0, Ellipsoid.GRS80);

            p1.DistanceTo(p3);
            p3.DistanceTo(p2);
        }
Exemplo n.º 3
0
        public void Project_HasToBeChainable()
        {
            GeoPoint pointTwo = geoPoint
                                .Project(Distance.Meters(100), Bearing.DecimalDegrees(0))
                                .Project(Distance.Meters(100), Bearing.DecimalDegrees(90))
                                .Project(Distance.Meters(100), Bearing.DecimalDegrees(180))
                                .Project(Distance.Meters(100), Bearing.DecimalDegrees(270));

            Assert.IsTrue(pointTwo.DistanceTo(geoPoint).In(MetricUnit.meters) < 0.0015);
        }
Exemplo n.º 4
0
        private void SelectClosestRouteStop(GeoPoint location)
        {
            var closestStop = _stops.Select(x => x.Model)
                              .Select(x => new Tuple <double, RouteStop>(location.DistanceTo(x.Location.Position), x))
                              .OrderBy(x => x.Item1)
                              .First();

            if (closestStop.Item1 <= MaxDistanceFromBusStop)
            {
                var closestRouteStop = closestStop.Item2;
                this.Dispatcher.RequestMainThreadAction(() => this.SelectRouteStop(closestRouteStop.Id));
            }
        }
Exemplo n.º 5
0
        private bool CalculateDistance(GeoPoint currentLocation, double maxDistance)
        {
            if (currentLocation.IsEmpty)
            {
                _distance    = 0;
                DistanceRepr = string.Empty;
                return(true);
            }

            _distance    = currentLocation.DistanceTo(_centerStreetPoint);
            DistanceRepr = GetDistanceRepresentation(_distance);

            return(!(maxDistance > 0) || _distance <= maxDistance);
        }
Exemplo n.º 6
0
        public bool InRange(GeoPoint location, double altitude)
        {
            var    distance = location.DistanceTo(Location, altitude - Altitude);
            double elevation;

            if (location != Location)
            {
                elevation = Math.Atan(((altitude - Altitude) / 6076.12) / distance);
            }
            else if (altitude < Altitude)
            {
                elevation = -90;
            }
            else
            {
                elevation = 90;
            }
            if (distance <= Range && elevation > minel && elevation < maxel && distance < Range)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 7
0
 public void Distance_MustBeCommutative()
 {
     Assert.AreEqual(p2.DistanceTo(p1), p1.DistanceTo(p2));
 }
Exemplo n.º 8
0
 public void Distance_ReturnsCorrectValues_GivenZeroDistanceInput()
 {
     Assert.AreEqual(Distance.Meters(0), p1.DistanceTo(p1));
 }
Exemplo n.º 9
0
        public void DistanceToSelfShouldBeZero()
        {
            var gp = new GeoPoint(10, 10);

            Assert.AreEqual(0D, gp.DistanceTo(gp).Radians, 0.0001);
        }
Exemplo n.º 10
0
 private void CalculateDistance(GeoPoint location)
 {
     this.DistanceInMeters = Convert.ToInt32(Math.Round(this.Stops.Min(x => location.DistanceTo(x.Location.Position) * 1000)));
 }
Exemplo n.º 11
0
        public void Project_ReturnsSaneValues()
        {
            GeoPoint p2 = geoPoint.Project(Distance.Meters(300), Bearing.DecimalDegrees(10));

            Assert.IsTrue(p2.DistanceTo(GeoPoint.Parse(-33.63364, 151.33240)).In(MetricUnit.meters) < 1);
        }