Beispiel #1
0
        public void CanRoundtrip(int x, int y)
        {
            SwissGridLocation expected = new SwissGridLocation(x, y);
            ILocation         location = expected.ToWgs84Approx();
            SwissGridLocation actual   = SwissGridLocation.FromWgs84Approx(location);

            Assert.AreEqual(expected.X, actual.X);
            Assert.AreEqual(expected.Y, actual.Y);
        }
Beispiel #2
0
        public void CanRoundtrip(int x, int y)
        {
            SwissGridLocation expected = new SwissGridLocation(x, y);
            Wgs84Location     location = SwissGridHelper.ToWgs84(expected);
            SwissGridLocation actual   = location.ToSwissGrid();

            Assert.AreEqual(expected.X, actual.X);
            Assert.AreEqual(expected.Y, actual.Y);
        }
Beispiel #3
0
        public void CanConvertToLocation(int x, int y, double latitude, double longitude)
        {
            SwissGridLocation sg       = new SwissGridLocation(x, y);
            ILocation         location = sg.ToWgs84Approx();

            if (Math.Abs(latitude - location.Latitude) > 0.000003)
            {
                Assert.Fail("Expected Value {0} for Latitude is not Eual to actual Value {1}. (Diff: {2})", latitude, location.Latitude, Math.Abs(latitude - location.Latitude));
            }
            if (Math.Abs(longitude - location.Longitude) > 0.00001)
            {
                Assert.Fail("Expected Value {0} for Longitude is not Eual to actual Value {1}. (Diff: {2})", longitude, location.Longitude, Math.Abs(longitude - location.Longitude));
            }
        }
        public static Wgs84Location ToWgs84(this SwissGridLocation sg)
        {
            Reframe reframe = new Reframe();

            double height = 555;
            double x      = sg.X;
            double y      = sg.Y;

            try
            {
                bool outsideSwitzerland = reframe.ComputeReframe(ref x, ref y, ref height, Reframe.PlanimetricFrame.LV03_Military, Reframe.PlanimetricFrame.LV95, Reframe.AltimetricFrame.LN02, Reframe.AltimetricFrame.Ellipsoid);
                reframe.ComputeGpsref(ref x, ref y, ref height, Reframe.ProjectionChange.LV95ToETRF93Geographic);
            }
            catch (Exception ex)
            {
                return(new Wgs84Location());
            }
            return(new Wgs84Location(y, x));
        }
Beispiel #5
0
        public void CalculateDistance(int x1, int y1, int x2, int y2, double expectedDistance)
        {
            double distance = new SwissGridLocation(x1, y1).DistanceTo(new SwissGridLocation(x2, y2));

            Assert.AreEqual(expectedDistance, distance, 0.1);
        }
Beispiel #6
0
 public BatNode()
 {
     Location = new SwissGridLocation(600000, 200000);
 }