Exemplo n.º 1
0
        public void ToNumberSmallZ()
        {
            GeoCoordinate coord = new GeodeticCoordinate(Locations.TokyoGeodeticLongitude,
                                                         Locations.TokyoGeodeticLatitude);

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                Number num = coord.ToNumber(-1, Tile.DefaultSize, false);
            });
        }
Exemplo n.º 2
0
        public void ToNumberNormal()
        {
            GeoCoordinate coord = new GeodeticCoordinate(Locations.TokyoGeodeticLongitude,
                                                         Locations.TokyoGeodeticLatitude);

            Assert.DoesNotThrow(() =>
            {
                Number num = coord.ToNumber(10, Tile.DefaultSize, false);
            });
        }
Exemplo n.º 3
0
        public void AddNormal()
        {
            Coordinate coordinate1 = new GeodeticCoordinate(1.0, 1.0);
            Coordinate coordinate2 = new GeodeticCoordinate(2.0, 2.0);
            Coordinate result      = new GeodeticCoordinate(3.0, 3.0);

            Coordinate add = coordinate1.Add(coordinate2);

            Assert.True(add == result);
        }
Exemplo n.º 4
0
        public void MultiplyNormal()
        {
            Coordinate coordinate1 = new GeodeticCoordinate(1.0, 1.0);
            Coordinate coordinate2 = new GeodeticCoordinate(2.0, 2.0);
            Coordinate result      = new GeodeticCoordinate(2.0, 2.0);

            Coordinate mul = coordinate1.Multiply(coordinate2);

            Assert.True(mul == result);
        }
Exemplo n.º 5
0
        public void DivideNormal()
        {
            Coordinate coordinate1 = new GeodeticCoordinate(2.0, 2.0);
            Coordinate coordinate2 = new GeodeticCoordinate(1.0, 1.0);
            Coordinate result      = new GeodeticCoordinate(2.0, 2.0);

            Coordinate div = coordinate1.Divide(coordinate2);

            Assert.True(div == result);
        }
Exemplo n.º 6
0
        public void SubtractNormal()
        {
            Coordinate coordinate1 = new GeodeticCoordinate(2.0, 2.0);
            Coordinate coordinate2 = new GeodeticCoordinate(1.0, 1.0);
            Coordinate result      = new GeodeticCoordinate(1.0, 1.0);

            Coordinate sub = coordinate1.Subtract(coordinate2);

            Assert.True(sub == result);
        }
Exemplo n.º 7
0
        public void GridToGeodeticTest()
        {
            var coordinate = new GridCoordinate {
                X = 7094946, Y = 1693701, Projection = SwedishProjections.RT90_25GonV
            };
            var expected = new GeodeticCoordinate {
                Latitude = 63.90786d, Longitude = 19.75247d
            };
            var actual = GaussKruger.GridToGeodetic(coordinate);

            Assert.IsTrue(expected.Equals(actual));
        }
 public void GetProperties() => Assert.DoesNotThrow(() =>
 {
     GeodeticCoordinate coord =
         new GeodeticCoordinate(Locations.TokyoGeodeticLongitude, Locations.TokyoGeodeticLatitude);
     double val = GeodeticCoordinate.MinPossibleLonValue;
     val        = GeodeticCoordinate.MaxPossibleLonValue;
     val        = GeodeticCoordinate.MinPossibleLatValue;
     val        = GeodeticCoordinate.MaxPossibleLatValue;
     val        = coord.Latitude;
     val        = coord.Longitude;
     val        = coord.X;
     val        = coord.Y;
 });
Exemplo n.º 9
0
        public void ToGeoCoordinatesGeodetic()
        {
            GeoCoordinate minCoordinate = null;
            GeoCoordinate maxCoordinate = null;

            Assert.DoesNotThrow(() => (minCoordinate, maxCoordinate) = Locations.TokyoGeodeticNtmsNumber
                                                                       .ToGeoCoordinates(Cs4326, Tile.DefaultSize, false));

            GeodeticCoordinate min = Coordinate.Round((GeodeticCoordinate)minCoordinate, 6);
            GeodeticCoordinate max = Coordinate.Round((GeodeticCoordinate)maxCoordinate, 6);

            Assert.True(min == Locations.TokyoGeodeticMin && max == Locations.TokyoGeodeticMax);
        }
Exemplo n.º 10
0
        public void GetAreasCoordsNullTileSize()
        {
            GeodeticCoordinate minImgCoord = new GeodeticCoordinate(0.0, 0.0);
            GeodeticCoordinate maxImgCoord = new GeodeticCoordinate(1.0, 1.0);
            Size imgSize = new Size(10, 10);

            GeodeticCoordinate minTileCoord = new GeodeticCoordinate(0.0, 0.0);
            GeodeticCoordinate maxTileCoord = new GeodeticCoordinate(1.0, 1.0);

            Assert.Throws <ArgumentNullException>(() =>
            {
                // ReSharper disable once ConvertToLambdaExpressionWhenPossible
                (Area readArea, Area writeArea) = Area.GetAreas(minImgCoord, maxImgCoord, imgSize, minTileCoord, maxTileCoord, null);
            });
        }
Exemplo n.º 11
0
        public void SphericalTest()
        {
            var coordinate1 = new GeodeticCoordinate()
            {
                Latitude = 63.83451, Longitude = 20.24655
            };
            var coordinate2 = new GeodeticCoordinate()
            {
                Latitude = 63.85763, Longitude = 20.33569
            };
            double expected = 5.069d;
            double actual   = DistanceCalculator.Spherical(coordinate1, coordinate2);

            Assert.AreEqual(Math.Round(expected, 3), Math.Round(actual, 3));
        }
Exemplo n.º 12
0
        public void TestPerformance2()
        {
            GeodeticCoordinate coor = new GeodeticCoordinate(43.853626 * Math.PI / 180.0, -79.358981 * Math.PI / 180.0, 231.0);

             Stopwatch watch = Stopwatch.StartNew();
             double tmp;
             for (int i = 0; i < 10000000; i++)
             {
            MCvPoint3D64f ecef = TransformationWGS84.Geodetic2ECEF(coor);
            GeodeticCoordinate coorTransformed = TransformationWGS84.ECEF2Geodetic(ecef);
            tmp = coorTransformed.Altitude;
             }
             watch.Stop();
             Trace.WriteLine(watch.ElapsedMilliseconds);
        }
Exemplo n.º 13
0
        public void TestPerformance2()
        {
            GeodeticCoordinate coor = new GeodeticCoordinate(43.853626 * Math.PI / 180.0, -79.358981 * Math.PI / 180.0, 231.0);

            Stopwatch watch = Stopwatch.StartNew();
            double    tmp;

            for (int i = 0; i < 10000000; i++)
            {
                MCvPoint3D64f      ecef            = TransformationWGS84.Geodetic2ECEF(coor);
                GeodeticCoordinate coorTransformed = TransformationWGS84.ECEF2Geodetic(ecef);
                tmp = coorTransformed.Altitude;
            }
            watch.Stop();
            Trace.WriteLine(watch.ElapsedMilliseconds);
        }
Exemplo n.º 14
0
        public void GetAreasCoordsTileMinEqualsMax()
        {
            GeodeticCoordinate minImgCoord = new GeodeticCoordinate(0.0, 0.0);
            GeodeticCoordinate maxImgCoord = new GeodeticCoordinate(1.0, 1.0);
            Size imgSize = new Size(10, 10);

            GeodeticCoordinate minTileCoord = new GeodeticCoordinate(0.0, 0.0);
            GeodeticCoordinate maxTileCoord = minTileCoord;
            Size tileSize = Tile.DefaultSize;

            Assert.Throws <ArgumentException>(() =>
            {
                // ReSharper disable once ConvertToLambdaExpressionWhenPossible
                (Area readArea, Area writeArea) = Area.GetAreas(minImgCoord, maxImgCoord, imgSize, minTileCoord, maxTileCoord, tileSize);
            });
        }
Exemplo n.º 15
0
        public void CoordFromDistanceTest()
        {
            var start = new GeodeticCoordinate()
            {
                Latitude = 63.83451, Longitude = 20.24655
            };
            double bearing  = 140d;
            double distance = 1.3d;
            var    expected = new GeodeticCoordinate()
            {
                Latitude = 63.8256, Longitude = 20.2636
            };
            var actual = DistanceCalculator.CoordFromDistance(start, bearing, distance);

            Assert.IsTrue(expected.Equals(actual));
        }
Exemplo n.º 16
0
        public void TestPerformance1()
        {
            GeodeticCoordinate coor = new GeodeticCoordinate(43.853626 * Math.PI / 180.0, -79.358981 * Math.PI / 180.0, 231.0);
             GeodeticCoordinate refCoor = new GeodeticCoordinate(43.853374 * Math.PI / 180.0, -79.358321 * Math.PI / 180.0, 230.312);

             Stopwatch watch = Stopwatch.StartNew();
             double tmp;
             for (int i = 0; i < 10000000; i++)
             {
            MCvPoint3D64f ned = TransformationWGS84.Geodetic2NED(coor, refCoor);
            GeodeticCoordinate coorTransformed = TransformationWGS84.NED2Geodetic(ned, refCoor);
            tmp = coorTransformed.Altitude;
             }
             watch.Stop();
             Trace.WriteLine(watch.ElapsedMilliseconds);
        }
Exemplo n.º 17
0
        public void TestPerformance1()
        {
            GeodeticCoordinate coor    = new GeodeticCoordinate(43.853626 * Math.PI / 180.0, -79.358981 * Math.PI / 180.0, 231.0);
            GeodeticCoordinate refCoor = new GeodeticCoordinate(43.853374 * Math.PI / 180.0, -79.358321 * Math.PI / 180.0, 230.312);

            Stopwatch watch = Stopwatch.StartNew();
            double    tmp;

            for (int i = 0; i < 10000000; i++)
            {
                MCvPoint3D64f      ned             = TransformationWGS84.Geodetic2NED(coor, refCoor);
                GeodeticCoordinate coorTransformed = TransformationWGS84.NED2Geodetic(ned, refCoor);
                tmp = coorTransformed.Altitude;
            }
            watch.Stop();
            Trace.WriteLine(watch.ElapsedMilliseconds);
        }
Exemplo n.º 18
0
      /// <summary>
      /// Convert geodetic coordinate to ECEF coordinate
      /// </summary>
      /// <param name="coordinate">the geodetic coordinate</param>
      /// <returns>The ECEF coordinate</returns>
      public static MCvPoint3D64f Geodetic2ECEF(GeodeticCoordinate coordinate)
      {
#if PINVOKE
         MCvPoint3D64f res = new MCvPoint3D64f();
         transformGeodetic2ECEF(ref coordinate, ref res);
         return res;
#else
         double sinPhi = Math.Sin(coordinate.Latitude);

         double N = A / Math.Sqrt(1.0 - E * E * sinPhi * sinPhi);

         double tmp1 = (N + coordinate.Altitude) * Math.Cos(coordinate.Latitude);

         return new MCvPoint3D64f(
            tmp1 * Math.Cos(coordinate.Longitude), 
            tmp1 * Math.Sin(coordinate.Longitude),
            ((B * B) / (A * A) * N + coordinate.Altitude) * sinPhi);
#endif
      }
Exemplo n.º 19
0
        public void TestConvertion()
        {
            GeodeticCoordinate coor = new GeodeticCoordinate(43.853626 * Math.PI / 180.0, -79.358981 * Math.PI / 180.0, 231.0);
             MCvPoint3D64f ecef = TransformationWGS84.Geodetic2ECEF(coor);
             GeodeticCoordinate coorTransformed = TransformationWGS84.ECEF2Geodetic(ecef);

             GeodeticCoordinate refCoor = new GeodeticCoordinate(43.853374 * Math.PI / 180.0, -79.358321 * Math.PI / 180.0, 230.312);

             GeodeticCoordinate delta = coorTransformed - coor;
             Assert.Less(Math.Abs(delta.Altitude), _epsilon);
             Assert.Less(Math.Abs(delta.Latitude), _epsilon);
             Assert.Less(Math.Abs(delta.Longitude), _epsilon);

             MCvPoint3D64f ned = TransformationWGS84.Geodetic2NED(coor, refCoor);
             coorTransformed = TransformationWGS84.NED2Geodetic(ned, refCoor);
             delta = coorTransformed - coor;
             Assert.Less(Math.Abs(delta.Altitude), _epsilon);
             Assert.Less(Math.Abs(delta.Latitude), _epsilon);
             Assert.Less(Math.Abs(delta.Longitude), _epsilon);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Write the geo information into the tiff file
        /// </summary>
        /// <param name="originCoordinate">The coordinate of the origin. To be specific, this is the coordinate of the upper left corner of the pixel in the origin</param>
        /// <param name="pixelResolution">The resolution of the pixel in meters</param>
        /// <param name="imageSize">The size of the image</param>
        public void WriteGeoTag(GeodeticCoordinate originCoordinate, Size imageSize, MCvPoint2D64f pixelResolution)
        {
            GeodeticCoordinate lowerRight = Datum.WGS84.NED2Geodetic(
                new MCvPoint3D64f(pixelResolution.x * imageSize.Height, pixelResolution.y * imageSize.Width, 0.0),
                originCoordinate);
            MCvPoint3D64f res = new MCvPoint3D64f(
                (lowerRight.Longitude - originCoordinate.Longitude) * (180.0 / Math.PI) / imageSize.Width,
                (lowerRight.Latitude - originCoordinate.Latitude) * (180.0 / Math.PI) / imageSize.Height,
                0.0);

            double latitude  = lowerRight.Latitude * (180.0 / Math.PI);
            double longitude = lowerRight.Longitude * (180.0 / Math.PI);

            double[] modelTiepoint =
            {
                0,                0, 0,
                longitude, latitude, 0
            };
            double[] modelPixelScale = { res.x, res.y, 0.0 };
            WriteGeoTag(modelTiepoint, modelPixelScale);
        }
Exemplo n.º 21
0
        public void GetAreasCoordsNormal()
        {
            GeodeticCoordinate minImgCoord = new GeodeticCoordinate(139.74999904632568, 35.61293363571167);
            GeodeticCoordinate maxImgCoord = new GeodeticCoordinate(139.8459792137146, 35.688271522521973);

            GeodeticCoordinate minTileCoord = new GeodeticCoordinate(139.74609375, 35.68359375);
            GeodeticCoordinate maxTileCoord = new GeodeticCoordinate(139.921875, 35.859375);
            Size tileSize = Tile.DefaultSize;

            PixelCoordinate expectedReadCoord  = new PixelCoordinate(0.0, 0.0);
            PixelCoordinate expectedWriteCoord = new PixelCoordinate(5.6875, 249.1875);
            Size            expectedReadSize   = new Size(4473, 218);
            Size            expectedWriteSize  = new Size(140, 7);

            Area calcReadArea  = null;
            Area calcWriteArea = null;

            Assert.DoesNotThrow(() => (calcReadArea, calcWriteArea) = Area.GetAreas(minImgCoord, maxImgCoord, _in4326Size, minTileCoord, maxTileCoord, tileSize));
            Assert.True(calcReadArea.OriginCoordinate == expectedReadCoord && calcReadArea.Size == expectedReadSize);
            Assert.True(calcWriteArea.OriginCoordinate == expectedWriteCoord && calcWriteArea.Size == expectedWriteSize);
        }
Exemplo n.º 22
0
        public void TestConvertion()
        {
            GeodeticCoordinate coor            = new GeodeticCoordinate(43.853626 * Math.PI / 180.0, -79.358981 * Math.PI / 180.0, 231.0);
            MCvPoint3D64f      ecef            = TransformationWGS84.Geodetic2ECEF(coor);
            GeodeticCoordinate coorTransformed = TransformationWGS84.ECEF2Geodetic(ecef);

            GeodeticCoordinate refCoor = new GeodeticCoordinate(43.853374 * Math.PI / 180.0, -79.358321 * Math.PI / 180.0, 230.312);

            GeodeticCoordinate delta = coorTransformed - coor;

            Assert.Less(Math.Abs(delta.Altitude), _epsilon);
            Assert.Less(Math.Abs(delta.Latitude), _epsilon);
            Assert.Less(Math.Abs(delta.Longitude), _epsilon);

            MCvPoint3D64f ned = TransformationWGS84.Geodetic2NED(coor, refCoor);

            coorTransformed = TransformationWGS84.NED2Geodetic(ned, refCoor);
            delta           = coorTransformed - coor;
            Assert.Less(Math.Abs(delta.Altitude), _epsilon);
            Assert.Less(Math.Abs(delta.Latitude), _epsilon);
            Assert.Less(Math.Abs(delta.Longitude), _epsilon);
        }
Exemplo n.º 23
0
 private extern static void transformGeodetic2ECEF(IntPtr datum, ref GeodeticCoordinate coordinate, ref MCvPoint3D64f ecef);
Exemplo n.º 24
0
 private extern static void transformECEF2Geodetic(IntPtr datum, ref MCvPoint3D64f ecef, ref GeodeticCoordinate coordinate);
Exemplo n.º 25
0
 /// <summary>
 /// Convert <paramref name="coor"/> to ENU (East North UP) coordinate using the reference coordinate <paramref name="refCoor"/>
 /// </summary>
 /// <param name="coor">The Geodetic Coordinate to be converted</param>
 /// <param name="refCoor">The reference Geodetic coordinate</param>
 /// <returns>The ENU (East North UP) coordinate related to the reference coordinate</returns>
 public MCvPoint3D64f Geodetic2ENU(GeodeticCoordinate coor, GeodeticCoordinate refCoor)
 {
    return Geodetic2ENU(coor, refCoor, Geodetic2ECEF(refCoor));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Convert <paramref name="enu"/> to Geodetic coordinate using the reference coordinate <paramref name="refCoor"/>
 /// </summary>
 /// <param name="enu">The ENU (East North UP) coordinate to be converted</param>
 /// <param name="refCoor">The reference Geodetic coordinate</param>
 /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
 /// <returns>The Geodetic coordinate</returns>
 public GeodeticCoordinate ENU2Geodetic(MCvPoint3D64f enu, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
 {
    GeodeticCoordinate coor = new GeodeticCoordinate();
    transformENU2Geodetic(_ptr, ref enu, ref refCoor, ref refEcef, ref coor);
    return coor;
 }
Exemplo n.º 27
0
 /// <summary>
 /// Convert <paramref name="coor"/> to NED (North East Down) coordinate using the reference coordinate <paramref name="refCoor"/>
 /// </summary>
 /// <param name="coor">The Geodetic Coordinate to be converted</param>
 /// <param name="refCoor">The reference Geodetic coordinate</param>
 /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
 /// <returns>The NED (North East Down) coordinate related to the reference coordinate</returns>
 public MCvPoint3D64f Geodetic2NED(GeodeticCoordinate coor, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
 {
    MCvPoint3D64f ned = new MCvPoint3D64f();
    transformGeodetic2NED(_ptr, ref coor, ref refCoor, ref refEcef, ref ned);
    return ned;
 }
 public void ResolutionNormal() => Assert.DoesNotThrow(() =>
 {
     double res = GeodeticCoordinate.Resolution(10, Tile.DefaultSize);
 });
 public void ResolutionNullTileSize() => Assert.Throws <ArgumentNullException>(() =>
 {
     double res = GeodeticCoordinate.Resolution(10, null);
 });
Exemplo n.º 30
0
        public void NotEqualsOperatorCoordinate2Null()
        {
            Coordinate coordinate1 = new GeodeticCoordinate(10.0, 10.0);

            Assert.True(coordinate1 != null);
        }
Exemplo n.º 31
0
 private extern static void transformNED2Geodetic(IntPtr datum, ref MCvPoint3D64f ned, ref GeodeticCoordinate refCoor, ref MCvPoint3D64f refEcef, ref GeodeticCoordinate coor);
Exemplo n.º 32
0
        public void NotEqualsOperatorCoordinate1Null()
        {
            Coordinate coordinate2 = new GeodeticCoordinate(10.0, 10.0);

            Assert.True(null != coordinate2);
        }
Exemplo n.º 33
0
 private extern static void transformGeodetic2NED(ref GeodeticCoordinate coor, ref GeodeticCoordinate refCoor, ref MCvPoint3D64f refEcef, ref MCvPoint3D64f ned);
Exemplo n.º 34
0
 /// <summary>
 /// Convert geodetic coordinate to ECEF coordinate
 /// </summary>
 /// <param name="coordinate">the geodetic coordinate</param>
 /// <returns>The ECEF coordinate</returns>
 public MCvPoint3D64f Geodetic2ECEF(GeodeticCoordinate coordinate)
 {
    MCvPoint3D64f res = new MCvPoint3D64f();
    transformGeodetic2ECEF(_ptr, ref coordinate, ref res);
    return res;
 }
Exemplo n.º 35
0
 /// <summary>
 /// Convert <paramref name="ned"/> to Geodetic coordinate using the reference coordinate <paramref name="refCoor"/>
 /// </summary>
 /// <param name="ned">The NED (North East Down) coordinate to be converted</param>
 /// <param name="refCoor">The reference Geodetic coordinate</param>
 /// <returns>The Geodetic coordinate</returns>
 public GeodeticCoordinate NED2Geodetic(MCvPoint3D64f ned, GeodeticCoordinate refCoor)
 {
    return NED2Geodetic(ned, refCoor, Geodetic2ECEF(refCoor));
 }
 public void CreateGeodeticCoordinateNormal() => Assert.DoesNotThrow(() =>
 {
     GeodeticCoordinate coord =
         new GeodeticCoordinate(Locations.TokyoGeodeticLongitude, Locations.TokyoGeodeticLatitude);
 });
Exemplo n.º 37
0
 /// <summary>
 /// Convert <paramref name="ned"/> to Geodetic coordinate using the reference coordinate <paramref name="refCoor"/>
 /// </summary>
 /// <param name="ned">The NED (North East Down) coordinate to be converted</param>
 /// <param name="refCoor">The reference Geodetic coordinate</param>
 /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
 /// <returns>The Geodetic coordinate</returns>
 public GeodeticCoordinate NED2Geodetic(MCvPoint3D64f ned, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
 {
    GeodeticCoordinate coor = new GeodeticCoordinate();
    transformNED2Geodetic(_ptr, ref ned, ref refCoor, ref refEcef, ref coor);
    return coor;
 }
 public void CreateGeodeticCoordinateBigLat() => Assert.Throws <ArgumentOutOfRangeException>(() =>
 {
     GeodeticCoordinate coord = new GeodeticCoordinate(Locations.TokyoGeodeticLongitude, 91.0);
 });
Exemplo n.º 39
0
 /// <summary>
 /// Convert <paramref name="enu"/> to Geodetic coordinate using the reference coordinate <paramref name="refCoor"/>
 /// </summary>
 /// <param name="enu">The ENU (East North UP) coordinate to be converted</param>
 /// <param name="refCoor">The reference Geodetic coordinate</param>
 /// <returns>The Geodetic coordinate</returns>
 public GeodeticCoordinate ENU2Geodetic(MCvPoint3D64f enu, GeodeticCoordinate refCoor)
 {
    return ENU2Geodetic(enu, refCoor, Geodetic2ECEF(refCoor));
 }
Exemplo n.º 40
0
 /// <summary>
 /// Convert <paramref name="coor"/> to ENU (East North UP) coordinate using the reference coordinate <paramref name="refCoor"/>
 /// </summary>
 /// <param name="coor">The Geodetic Coordinate to be converted</param>
 /// <param name="refCoor">The reference Geodetic coordinate</param>
 /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
 /// <returns>The ENU (East North UP) coordinate related to the reference coordinate</returns>
 public MCvPoint3D64f Geodetic2ENU(GeodeticCoordinate coor, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
 {
    MCvPoint3D64f p = new MCvPoint3D64f();
    transformGeodetic2ENU(_ptr, ref coor, ref refCoor, ref refEcef, ref p);
    return p;
 }
Exemplo n.º 41
0
      /// <summary>
      /// Convert <paramref name="enu"/> to Geodetic coordinate using the reference coordinate <paramref name="refCoor"/>
      /// </summary>
      /// <param name="enu">The ENU (East North UP) coordinate to be converted</param>
      /// <param name="refCoor">The reference Geodetic coordinate</param>
      /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
      /// <returns>The Geodetic coordinate</returns>
      public static GeodeticCoordinate ENU2Geodetic(MCvPoint3D64f enu, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
      {
#if PINVOKE
         GeodeticCoordinate coor = new GeodeticCoordinate();
         transformENU2Geodetic(ref enu, ref refCoor, ref refEcef, ref coor);
         return coor;
#else
         double sinPhi = Math.Sin(refCoor.Latitude);
         double cosPhi = Math.Cos(refCoor.Latitude);
         double sinLambda = Math.Sin(refCoor.Longitude);
         double cosLambda = Math.Cos(refCoor.Longitude);

         double sinPhi_EnuY = sinPhi * enu.y;
         double cosPhi_EnuZ = cosPhi * enu.z;
         MCvPoint3D64f ecefDelta = new MCvPoint3D64f(
            -sinLambda * enu.x - cosLambda * sinPhi_EnuY + cosLambda * cosPhi_EnuZ,
            cosLambda * enu.x - sinLambda * sinPhi_EnuY + sinLambda * cosPhi_EnuZ,
            cosPhi * enu.y + sinPhi * enu.z);

         return ECEF2Geodetic(ecefDelta + refEcef);
#endif
      }
Exemplo n.º 42
0
 private extern static void transformGeodetic2ENU(IntPtr datum, ref GeodeticCoordinate coor, ref GeodeticCoordinate refCoor, ref MCvPoint3D64f refEcef, ref MCvPoint3D64f enu);
Exemplo n.º 43
0
 private extern static void transformENU2Geodetic(ref MCvPoint3D64f enu, ref GeodeticCoordinate refCoor, ref MCvPoint3D64f refEcef, ref GeodeticCoordinate coor);
Exemplo n.º 44
0
 /// <summary>
 /// Convert ECEF coordinate to geodetic coordinate
 /// </summary>
 /// <param name="ecef">The ecef coordinate</param>
 /// <returns>The geodetic coordinate</returns>
 public GeodeticCoordinate ECEF2Geodetic(MCvPoint3D64f ecef)
 {
    GeodeticCoordinate res = new GeodeticCoordinate();
    transformECEF2Geodetic(_ptr, ref ecef, ref res);
    return res;
 }
Exemplo n.º 45
0
      /// <summary>
      /// Convert <paramref name="coor"/> to NED (North East Down) coordinate using the reference coordinate <paramref name="refCoor"/>
      /// </summary>
      /// <param name="coor">The Geodetic Coordinate to be converted</param>
      /// <param name="refCoor">The reference Geodetic coordinate</param>
      /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
      /// <returns>The NED (North East Down) coordinate related to the reference coordinate</returns>
      public static MCvPoint3D64f Geodetic2NED(GeodeticCoordinate coor, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
      {
#if PINVOKE
         MCvPoint3D64f ned = new MCvPoint3D64f();
         transformGeodetic2NED(ref coor, ref refCoor, ref refEcef, ref ned);
         return ned;
#else
         MCvPoint3D64f enu = Geodetic2ENU(coor, refCoor, refEcef);
         return new MCvPoint3D64f(enu.y, enu.x, -enu.z);
#endif
      }
Exemplo n.º 46
0
      /// <summary>
      /// Convert <paramref name="ned"/> to Geodetic coordinate using the reference coordinate <paramref name="refCoor"/>
      /// </summary>
      /// <param name="ned">The NED (North East Down) coordinate to be converted</param>
      /// <param name="refCoor">The reference Geodetic coordinate</param>
      /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
      /// <returns>The Geodetic coordinate</returns>
      public static GeodeticCoordinate NED2Geodetic(MCvPoint3D64f ned, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
      {
#if PINVOKE
         GeodeticCoordinate coor = new GeodeticCoordinate();
         transformNED2Geodetic(ref ned, ref refCoor, ref refEcef, ref coor);
         return coor;
#else
         MCvPoint3D64f enu = new MCvPoint3D64f(ned.y, ned.x, -ned.z);
         return ENU2Geodetic(enu, refCoor, refEcef);
#endif
      }
 public void ResolutionSmallZ() => Assert.Throws <ArgumentOutOfRangeException>(() =>
 {
     double res = GeodeticCoordinate.Resolution(-1, Tile.DefaultSize);
 });
Exemplo n.º 48
0
        public void MultiplyNullCoordinate2()
        {
            Coordinate coordinate1 = new GeodeticCoordinate(1.0, 1.0);

            Assert.Throws <ArgumentNullException>(() => coordinate1.Multiply(null));
        }
 public void ResolutionNotSquareTileSize() => Assert.Throws <ArgumentException>(() =>
 {
     Size size  = new Size(10, 20);
     double res = GeodeticCoordinate.Resolution(10, size);
 });
Exemplo n.º 50
0
        public void DivideNullCoordinate2()
        {
            Coordinate coordinate1 = new GeodeticCoordinate(2.0, 2.0);

            Assert.Throws <ArgumentNullException>(() => coordinate1.Divide(null));
        }
 public void CreateGeodeticCoordinateSmallLon() => Assert.Throws <ArgumentOutOfRangeException>(() =>
 {
     GeodeticCoordinate coord = new GeodeticCoordinate(-181.0, Locations.TokyoGeodeticLatitude);
 });
Exemplo n.º 52
0
        public void RoundSmallDigits()
        {
            Coordinate coord = new GeodeticCoordinate(12.341, 13.561);

            Assert.Throws <ArgumentOutOfRangeException>(() => coord.Round <Coordinate>(-1));
        }
Exemplo n.º 53
0
      /// <summary>
      /// Convert <paramref name="coor"/> to ENU (East North UP) coordinate using the reference coordinate <paramref name="refCoor"/>
      /// </summary>
      /// <param name="coor">The Geodetic Coordinate to be converted</param>
      /// <param name="refCoor">The reference Geodetic coordinate</param>
      /// <param name="refEcef"><paramref name="refCoor"/> in ECEF format. If this is provided, it speeds up the computation</param>
      /// <returns>The ENU (East North UP) coordinate related to the reference coordinate</returns>
      public static MCvPoint3D64f Geodetic2ENU(GeodeticCoordinate coor, GeodeticCoordinate refCoor, MCvPoint3D64f refEcef)
      {
#if PINVOKE
         MCvPoint3D64f p = new MCvPoint3D64f();
         transformGeodetic2ENU(ref coor, ref refCoor, ref refEcef, ref p);
         return p;
#else
         MCvPoint3D64f delta = Geodetic2ECEF(coor) - refEcef;
         double sinPhi = Math.Sin(refCoor.Latitude);
         double cosPhi = Math.Cos(refCoor.Latitude);
         double sinLambda = Math.Sin(refCoor.Longitude);
         double cosLambda = Math.Cos(refCoor.Longitude);

         double cosLambda_DeltaX = cosLambda * delta.x;
         double sinLambda_DeltaY = sinLambda * delta.y;

         return new MCvPoint3D64f(
            -sinLambda * delta.x + cosLambda * delta.y,
            -sinPhi * cosLambda_DeltaX - sinPhi * sinLambda_DeltaY + cosPhi * delta.z,
            cosPhi * cosLambda_DeltaX + cosPhi * sinLambda_DeltaY + sinPhi * delta.z);
#endif
      }
Exemplo n.º 54
0
      /// <summary>
      /// Convert ECEF coordinate to geodetic coordinate
      /// </summary>
      /// <param name="ecef">The ecef coordinate</param>
      /// <returns>The geodetic coordinate</returns>
      public static GeodeticCoordinate ECEF2Geodetic(MCvPoint3D64f ecef)
      {
#if PINVOKE
         GeodeticCoordinate res = new GeodeticCoordinate();
         transformECEF2Geodetic(ref ecef, ref res);
         return res;
#else
         GeodeticCoordinate coor = new GeodeticCoordinate();
         double p = Math.Sqrt(ecef.x * ecef.x + ecef.y * ecef.y);
         double theta = Math.Atan2(ecef.z * A, p * B);
         double sinTheta = Math.Sin(theta);
         double cosTheta = Math.Cos(theta);

         coor.Longitude = Math.Atan2(ecef.y, ecef.x);
         coor.Latitude = Math.Atan2(
            ecef.z + EP * EP * B * sinTheta * sinTheta * sinTheta,
            p - E * E * A * cosTheta * cosTheta * cosTheta);
         double sinLat = Math.Sin(coor.Latitude);
         double N = A / Math.Sqrt(1.0 - E * E * sinLat * sinLat);
         double cosLat = Math.Cos(coor.Latitude);
         coor.Altitude = p / cosLat - N;
         
         return coor;
#endif
      }