コード例 #1
0
ファイル: TransformTests.aspx.cs プロジェクト: cugkgq/Project
    private void TestAlbers()
    {
        CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

        IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot);

        IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null);
        IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum,
                                                                                  PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                  new AxisInfo("Lat", AxisOrientationEnum.North));
        List <ProjectionParameter> parameters = new List <ProjectionParameter>();

        parameters.Add(new ProjectionParameter("central_meridian", -96));
        parameters.Add(new ProjectionParameter("latitude_of_origin", 23));
        parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5));
        parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5));
        parameters.Add(new ProjectionParameter("false_easting", 0));
        parameters.Add(new ProjectionParameter("false_northing", 0));
        IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters);

        IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

        ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

        SharpMap.Geometries.Point pGeo  = new SharpMap.Geometries.Point(-75, 35);
        SharpMap.Geometries.Point pUtm  = new Point(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
        SharpMap.Geometries.Point pGeo2 = new Point(trans.MathTransform.Inverse().Transform(pUtm.ToDoubleArray()));

        result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Point(1885472.7, 1535925), pGeo2, "Albers Conical Equal Area test");
    }
コード例 #2
0
        /// <summary>
        /// Тестирование решения прямой и обратной задач
        /// </summary>
        /// <remarks>
        /// Тест состоит из нескольких частей:
        ///     1. Задаются координаты между которыми рассчитывается ортодромическая дистанция и определяется азимут
        ///         - решается обратная геодезическая задача
        ///     2. По первой координате, дистанции и прямому направлению (азимуту) находим вторую координату
        ///         - решается прямая геодезическая задача
        ///     3. Выполняется проверка
        ///         - вторая координата из условий обратной задачи должна совпасть с координатой из решения прямой задачи,
        ///         - обратный азимут из решения обратной задачи, должен совпадать с обратным азимутом из решения прямой задачи
        ///     4. По второй координате, дистанции и обратному направлению (азимуту) находим первую координату
        ///         - решаетая прямая геодезическая задача
        ///     5. Выполняется проверка
        ///         - первая координата из условий обратной задачи должна совпасть с координатой из решения прямой задачи
        ///         - прямой азимут из решения обратной задачи, должен совпадать с обратным азимутом из решения прямой задачи
        /// </remarks>
        public override void Tests(Point point1, Point point2, IEllipsoid ellipsoid)
        {
            var inverseProblemService = new InverseProblemService(ellipsoid);
            var directProblemService  = new DirectProblemService(ellipsoid);

            // Решение обратной задачи
            var inverseAnswer = inverseProblemService.OrthodromicDistance(point1, point2);

            // Решение прямой задачи 1
            var directAnswerForward = directProblemService.DirectProblem(point1,
                                                                         inverseAnswer.ForwardAzimuth, inverseAnswer.Distance);
            var distance1 =
                inverseProblemService.OrthodromicDistance(
                    new Point(directAnswerForward.Сoordinate.Longitude, directAnswerForward.Сoordinate.Latitude),
                    point2).Distance;

            Assert.AreEqual(distance1, 0, 0.0006); // 0.06 мм
            Assert.AreEqual(directAnswerForward.Сoordinate.Longitude, point2.Longitude, 0.000000001);
            Assert.AreEqual(directAnswerForward.Сoordinate.Latitude, point2.Latitude, 0.000000001);
            Assert.AreEqual(inverseAnswer.ReverseAzimuth, directAnswerForward.ReverseAzimuth, 0.000000001);

            // Решение прямой задачи 2
            var directAnswerReverse = directProblemService.DirectProblem(point2,
                                                                         inverseAnswer.ReverseAzimuth, inverseAnswer.Distance);
            var distance2 =
                inverseProblemService.OrthodromicDistance(
                    new Point(directAnswerReverse.Сoordinate.Longitude, directAnswerReverse.Сoordinate.Latitude),
                    point1)
                .Distance;

            Assert.AreEqual(distance2, 0, 0.0006); // 0.06 мм
            Assert.AreEqual(directAnswerReverse.Сoordinate.Longitude, point1.Longitude, 0.000000001);
            Assert.AreEqual(directAnswerReverse.Сoordinate.Latitude, point1.Latitude, 0.000000001);
            Assert.AreEqual(inverseAnswer.ForwardAzimuth, directAnswerReverse.ReverseAzimuth, 0.000000001);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static IHorizontalDatum ReadHorizontalDatum(WktStreamTokenizer tokenizer)
        {
            //DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]
            Wgs84ConversionInfo wgsInfo = null;
            string authority            = String.Empty;
            long   authorityCode        = -1;

            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("SPHEROID");
            IEllipsoid ellipsoid = ReadEllipsoid(tokenizer);

            tokenizer.NextToken();
            while (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                if (tokenizer.GetStringValue() == "TOWGS84")
                {
                    wgsInfo = ReadWGS84ConversionInfo(tokenizer);
                    tokenizer.NextToken();
                }
                else if (tokenizer.GetStringValue() == "AUTHORITY")
                {
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                    tokenizer.ReadToken("]");
                }
            }
            // make an assumption about the datum type.
            IHorizontalDatum horizontalDatum = new HorizontalDatum(ellipsoid, wgsInfo, DatumType.HD_Geocentric, name, authority, authorityCode, String.Empty, String.Empty, String.Empty);

            return(horizontalDatum);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tokenizer"></param>
        /// <returns></returns>
        private static IHorizontalDatum ReadHorizontalDatum(WktStreamTokenizer tokenizer)
        {
            Wgs84ConversionInfo info = null;
            string authority         = string.Empty;
            long   authorityCode     = -1L;

            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("SPHEROID");
            IEllipsoid ellipsoid = ReadEllipsoid(tokenizer);

            tokenizer.NextToken();
            while (tokenizer.GetStringValue() == ",")
            {
                tokenizer.NextToken();
                if (tokenizer.GetStringValue() == "TOWGS84")
                {
                    info = ReadWGS84ConversionInfo(tokenizer);
                    tokenizer.NextToken();
                }
                else if (tokenizer.GetStringValue() == "AUTHORITY")
                {
                    tokenizer.ReadAuthority(ref authority, ref authorityCode);
                    tokenizer.ReadToken("]");
                }
            }
            return(new HorizontalDatum(ellipsoid, info, DatumType.HD_Geocentric, name, authority, authorityCode, string.Empty, string.Empty, string.Empty));
        }
コード例 #5
0
        public static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid)
        {
            ParameterList parameterList = new ParameterList();
            for(int i=0; i< projection.NumParameters; i++)
            {
                ProjectionParameter param = projection.GetParameter(i);
                parameterList.Add(param.Name,param.Value);
            }
            parameterList.Add("semi_major",ellipsoid.SemiMajorAxis);
            parameterList.Add("semi_minor",ellipsoid.SemiMinorAxis);

            IMathTransform transform = null;
            switch(projection.Name.ToLower())
            {
                case "mercator":
                    //1SP
                    transform = new MercatorProjection(parameterList);
                    break;
                case "transverse_mercator":
                    transform = new TransverseMercatorProjection(parameterList);
                    break;
                case "albers":
                    transform = new AlbersProjection(parameterList);
                    break;
                case "lambert":
                    transform = new LambertConformalConic2SPProjection(parameterList);
                    break;
                default:
                    throw new NotSupportedException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Projection {0} is not supported.",projection.AuthorityCode));
            }
            return transform;
        }
コード例 #6
0
        private static CoordinateSystemFactory CreateNad83ToLambertFactory(out IGeographicCoordinateSystem gcs, out IProjectedCoordinateSystem coordsys)
        {
            CoordinateSystemFactory cfac = new CoordinateSystemFactory();

            // Define ellipsoid GRS 1980 used by NAD83
            IEllipsoid ellipsoid = cfac.CreateFlattenedSphere("GRS 1980", 6378137, 298.257222101, LinearUnit.Metre);

            // Define NAD83 system
            IHorizontalDatum datum = cfac.CreateHorizontalDatum("NAD83 (CSRS)", DatumType.HD_Other, ellipsoid, null);

            gcs = cfac.CreateGeographicCoordinateSystem("NAD83 (CSRS)", AngularUnit.Degrees, datum,
                                                        PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North));

            // Define Lambert parameters
            List <ProjectionParameter> parameters = new List <ProjectionParameter>(5);

            parameters.Add(new ProjectionParameter("latitude_of_origin", 44));
            parameters.Add(new ProjectionParameter("central_meridian", -70));
            parameters.Add(new ProjectionParameter("standard_parallel_1", 50));
            parameters.Add(new ProjectionParameter("standard_parallel_2", 46));
            parameters.Add(new ProjectionParameter("false_easting", 800000));
            parameters.Add(new ProjectionParameter("false_northing", 0));
            IProjection projection = cfac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters);

            coordsys = cfac.CreateProjectedCoordinateSystem("NAD83/Lambert", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

            return(cfac);
        }
コード例 #7
0
        public void TestTransverseMercator_Projection()
        {
            CoordinateSystemFactory cFac = new CoordinateSystemFactory();

            IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre);

            IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null);
            IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum,
                                                                                      PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                      new AxisInfo("Lat", AxisOrientationEnum.North));
            List <ProjectionParameter> parameters = new List <ProjectionParameter>(5);

            parameters.Add(new ProjectionParameter("latitude_of_origin", 49));
            parameters.Add(new ProjectionParameter("central_meridian", -2));
            parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717));
            parameters.Add(new ProjectionParameter("false_easting", 400000));
            parameters.Add(new ProjectionParameter("false_northing", -100000));
            IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters);

            IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

            ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

            double[] pGeo  = new double[] { 0.5, 50.5 };
            double[] pUtm  = trans.MathTransform.Transform(pGeo);
            double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);

            double[] expected = new double[] { 577274.99, 69740.50 };
            Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("TransverseMercator forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString()));
            Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("TransverseMercator reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString()));
        }
コード例 #8
0
ファイル: TransformTests.aspx.cs プロジェクト: cugkgq/Project
    private void TestMercator_1SP()
    {
        CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

        IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre);

        IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null);
        IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum,
                                                                                  PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                  new AxisInfo("Lat", AxisOrientationEnum.North));
        List <ProjectionParameter> parameters = new List <ProjectionParameter>();

        parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
        parameters.Add(new ProjectionParameter("central_meridian", 110));
        parameters.Add(new ProjectionParameter("scale_factor", 0.997));
        parameters.Add(new ProjectionParameter("false_easting", 3900000));
        parameters.Add(new ProjectionParameter("false_northing", 900000));
        IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters);

        IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

        ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

        SharpMap.Geometries.Point pGeo  = new SharpMap.Geometries.Point(120, -3);
        SharpMap.Geometries.Point pUtm  = new Point(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
        SharpMap.Geometries.Point pGeo2 = new Point(trans.MathTransform.Inverse().Transform(pUtm.ToDoubleArray()));

        result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Point(5009726.58, 569150.82), pGeo2, "Mercator_1SP test");
    }
コード例 #9
0
ファイル: TransformTests.aspx.cs プロジェクト: cugkgq/Project
    private void TestLambertConicConformal_2SP()
    {
        CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

        IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot);

        IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null);
        IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum,
                                                                                  PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                  new AxisInfo("Lat", AxisOrientationEnum.North));
        List <ProjectionParameter> parameters = new List <ProjectionParameter>();

        parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333));
        parameters.Add(new ProjectionParameter("central_meridian", -99));
        parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333));
        parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333));
        parameters.Add(new ProjectionParameter("false_easting", 2000000));
        parameters.Add(new ProjectionParameter("false_northing", 0));
        IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters);

        IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

        ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

        SharpMap.Geometries.Point pGeo  = new SharpMap.Geometries.Point(-96, 28.5);
        SharpMap.Geometries.Point pUtm  = new Point(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
        SharpMap.Geometries.Point pGeo2 = new Point(trans.MathTransform.Inverse().Transform(pUtm.ToDoubleArray()));

        result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Point(2963503.91, 254759.80), pGeo2, "Lambert Conic Conformal 2SP test");
    }
コード例 #10
0
        public void TestMercator_2SP_Projection()
        {
            CoordinateSystemFactory cFac = new CoordinateSystemFactory();

            IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre);

            IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null);
            IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum,
                                                                                      PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                      new AxisInfo("Lat", AxisOrientationEnum.North));
            List <ProjectionParameter> parameters = new List <ProjectionParameter>(5);

            parameters.Add(new ProjectionParameter("latitude_of_origin", 42));
            parameters.Add(new ProjectionParameter("central_meridian", 51));
            parameters.Add(new ProjectionParameter("false_easting", 0));
            parameters.Add(new ProjectionParameter("false_northing", 0));
            IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters);

            IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

            ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

            double[] pGeo  = new double[] { 53, 53 };
            double[] pUtm  = trans.MathTransform.Transform(pGeo);
            double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);

            double[] expected = new double[] { 165704.29, 5171848.07 };
            Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_2SP forward transformation outside tolerance, Expected {0}, got {1}", expected.ToString(), pUtm.ToString()));
            Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_2SP reverse transformation outside tolerance, Expected {0}, got {1}", pGeo.ToString(), pGeo2.ToString()));
        }
コード例 #11
0
ファイル: TransformTests.aspx.cs プロジェクト: cugkgq/Project
    private void TestMercator_2SP()
    {
        CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

        IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Krassowski 1940", 6378245.0, 298.3, LinearUnit.Metre);

        IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Krassowski 1940", DatumType.HD_Geocentric, ellipsoid, null);
        IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Krassowski 1940", AngularUnit.Degrees, datum,
                                                                                  PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                  new AxisInfo("Lat", AxisOrientationEnum.North));
        List <ProjectionParameter> parameters = new List <ProjectionParameter>();

        parameters.Add(new ProjectionParameter("latitude_of_origin", 42));
        parameters.Add(new ProjectionParameter("central_meridian", 51));
        parameters.Add(new ProjectionParameter("false_easting", 0));
        parameters.Add(new ProjectionParameter("false_northing", 0));
        IProjection projection = cFac.CreateProjection("Mercator_2SP", "Mercator_2SP", parameters);

        IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Pulkovo 1942 / Mercator Caspian Sea", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

        ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

        SharpMap.Geometries.Point pGeo  = new SharpMap.Geometries.Point(53, 53);
        SharpMap.Geometries.Point pUtm  = new Point(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
        SharpMap.Geometries.Point pGeo2 = new Point(trans.MathTransform.Inverse().Transform(pUtm.ToDoubleArray()));

        result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Point(165704.29, 5171848.07), pGeo2, "Mercator_2SP test");
    }
コード例 #12
0
        private static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid)
        {
            List<ProjectionParameter> parameterList = new List<ProjectionParameter>(projection.NumParameters);
            for (int i = 0; i < projection.NumParameters; i++)
                parameterList.Add(projection.GetParameter(i));

            parameterList.Add(new ProjectionParameter("semi_major", ellipsoid.SemiMajorAxis));
            parameterList.Add(new ProjectionParameter("semi_minor", ellipsoid.SemiMinorAxis));

            IMathTransform transform = null;
            switch (projection.ClassName.ToLower())
            {
                case "mercator_1sp":
                case "mercator_2sp":
                    //1SP
                    transform = new Mercator(parameterList);
                    break;
                case "transverse_mercator":
                    transform = new TransverseMercator(parameterList);
                    break;
                case "albers":
                    transform = new AlbersProjection(parameterList);
                    break;
                case "lambert_conformal_conic":
                case "lambert_conformal_conic_2sp":
                    transform = new LambertConformalConic2SP(parameterList);
                    break;
                default:
                    throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.ClassName));
            }
            return transform;
        }
コード例 #13
0
ファイル: TransformTests.aspx.cs プロジェクト: cugkgq/Project
    private void TestTransverseMercator()
    {
        CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

        IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Airy 1830", 6377563.396, 299.32496, LinearUnit.Metre);

        IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Airy 1830", DatumType.HD_Geocentric, ellipsoid, null);
        IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Airy 1830", AngularUnit.Degrees, datum,
                                                                                  PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                  new AxisInfo("Lat", AxisOrientationEnum.North));
        List <ProjectionParameter> parameters = new List <ProjectionParameter>();

        parameters.Add(new ProjectionParameter("latitude_of_origin", 49));
        parameters.Add(new ProjectionParameter("central_meridian", -2));
        parameters.Add(new ProjectionParameter("scale_factor", 0.9996012717));
        parameters.Add(new ProjectionParameter("false_easting", 400000));
        parameters.Add(new ProjectionParameter("false_northing", -100000));
        IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters);

        IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("OSGB 1936 / British National Grid", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

        ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

        SharpMap.Geometries.Point pGeo  = new SharpMap.Geometries.Point(0.5, 50.5);
        SharpMap.Geometries.Point pUtm  = new Point(trans.MathTransform.Transform(pGeo.ToDoubleArray()));
        SharpMap.Geometries.Point pGeo2 = new Point(trans.MathTransform.Inverse().Transform(pUtm.ToDoubleArray()));

        result.Text += PrintResultTable(gcs, coordsys, pGeo, pUtm, new Point(577274.99, 69740.50), pGeo2, "Transverse Mercator test");
    }
コード例 #14
0
        private static IHorizontalDatum ReadHorizontalDatum(WktStreamTokenizer tokenizer)
        {
            //DATUM["OSGB 1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]]TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6277"]]

            tokenizer.ReadToken("[");
            string name = tokenizer.ReadDoubleQuotedWord();

            tokenizer.ReadToken(",");
            tokenizer.ReadToken("SPHEROID");
            IEllipsoid ellipsoid = ReadEllipsoid(tokenizer);

            tokenizer.ReadToken("TOWGS84");
            WGS84ConversionInfo wgsInfo = ReadWGS84ConversionInfo(tokenizer);

            tokenizer.ReadToken(",");
            string authority     = "";
            string authorityCode = "";

            tokenizer.ReadAuthority(ref authority, ref authorityCode);
            // make an assumption about the datum type.
            DatumType        datumType       = DatumType.IHD_Geocentric;
            IHorizontalDatum horizontalDatum = new HorizontalDatum(name, datumType, ellipsoid, wgsInfo, "", authority, authorityCode, "", "");

            tokenizer.ReadToken("]");
            return(horizontalDatum);
        }
コード例 #15
0
        public static Point3D ToCartesian(IPoint geodeticPoint, IEllipsoid ellipsoid)
        {
            var scale = Math.PI / 180.0;

            var phi = geodeticPoint.Y * scale;

            var lambda = geodeticPoint.X * scale;

            var cosPhi = Math.Cos(phi);

            var sinPhi = Math.Sin(phi);

            var cosLambda = Math.Cos(lambda);

            var sinLambda = Math.Sin(lambda);

            var N = ellipsoid.CalculateN(geodeticPoint.Y);

            var x = ellipsoid.DatumTranslation.X.Value + N * cosPhi * cosLambda;

            var y = ellipsoid.DatumTranslation.Y.Value + N * cosPhi * sinLambda;

            var z = ellipsoid.DatumTranslation.Z.Value + N * ellipsoid.SemiMinorAxis.Value * ellipsoid.SemiMinorAxis.Value / (ellipsoid.SemiMajorAxis.Value * ellipsoid.SemiMajorAxis.Value) * sinPhi;

            return(new Point3D(x, y, z));
        }
コード例 #16
0
        public void TestAlbersProjectionFeet()
        {
            CoordinateSystemFactory cFac = new CoordinateSystemFactory();

            IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 6378206.4, 294.9786982138982, LinearUnit.USSurveyFoot);

            IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null);
            IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum,
                                                                                      PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                      new AxisInfo("Lat", AxisOrientationEnum.North));
            List <ProjectionParameter> parameters = new List <ProjectionParameter>(5);

            parameters.Add(new ProjectionParameter("central_meridian", -96));
            parameters.Add(new ProjectionParameter("latitude_of_center", 23));
            parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5));
            parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5));
            parameters.Add(new ProjectionParameter("false_easting", 0));
            parameters.Add(new ProjectionParameter("false_northing", 0));
            IProjection projection = cFac.CreateProjection("Albers Conical Equal Area", "albers", parameters);

            IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers Conical Equal Area", gcs, projection, LinearUnit.Foot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

            ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

            double[] pGeo  = new double[] { -75, 35 };
            double[] pUtm  = trans.MathTransform.Transform(pGeo);
            double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);

            double[] expected = new double[] { 1885472.7 / LinearUnit.Foot.MetersPerUnit, 1535925 / LinearUnit.Foot.MetersPerUnit };
            Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.1), String.Format("Albers forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1]));
            Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Albers reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1]));
        }
コード例 #17
0
        public void TestLambertConicConformal2SP_Projection()
        {
            CoordinateSystemFactory cFac = new CoordinateSystemFactory();

            IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Clarke 1866", 20925832.16, 294.97470, LinearUnit.USSurveyFoot);

            IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Clarke 1866", DatumType.HD_Geocentric, ellipsoid, null);
            IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Clarke 1866", AngularUnit.Degrees, datum,
                                                                                      PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                      new AxisInfo("Lat", AxisOrientationEnum.North));
            List <ProjectionParameter> parameters = new List <ProjectionParameter>(5);

            parameters.Add(new ProjectionParameter("latitude_of_origin", 27.833333333));
            parameters.Add(new ProjectionParameter("central_meridian", -99));
            parameters.Add(new ProjectionParameter("standard_parallel_1", 28.3833333333));
            parameters.Add(new ProjectionParameter("standard_parallel_2", 30.2833333333));
            parameters.Add(new ProjectionParameter("false_easting", 2000000 / LinearUnit.USSurveyFoot.MetersPerUnit));
            parameters.Add(new ProjectionParameter("false_northing", 0));
            IProjection projection = cFac.CreateProjection("Lambert Conic Conformal (2SP)", "lambert_conformal_conic_2sp", parameters);

            IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("NAD27 / Texas South Central", gcs, projection, LinearUnit.USSurveyFoot, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

            ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

            double[] pGeo  = new double[] { -96, 28.5 };
            double[] pUtm  = trans.MathTransform.Transform(pGeo);
            double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);

            double[] expected = new double[] { 2963503.91 / LinearUnit.USSurveyFoot.MetersPerUnit, 254759.80 / LinearUnit.USSurveyFoot.MetersPerUnit };
            Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.05), String.Format("LambertConicConformal2SP forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1]));
            Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("LambertConicConformal2SP reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1]));
        }
コード例 #18
0
        /// <summary>
        /// Creates a UTM projection for the northern/// hemisphere based on the WGS84 datum
        /// </summary>
        /// <param name="utmZone">Utm Zone</param>
        /// <returns>Projection</returns>
        private IProjectedCoordinateSystem CreateUtmProjection(int utmZone)
        {
            CoordinateSystemFactory cFac = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
            //CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

            //Create geographic coordinate system based on the WGS84 datum
            IEllipsoid                  ellipsoid = cFac.CreateFlattenedSphere("WGS 84", 6378137, 298.257223563, LinearUnit.Metre);
            IHorizontalDatum            datum     = cFac.CreateHorizontalDatum("WGS_1984", DatumType.HD_Geocentric, ellipsoid, null);
            IGeographicCoordinateSystem gcs       = cFac.CreateGeographicCoordinateSystem("WGS 84", AngularUnit.Degrees, datum,
                                                                                          PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                          new AxisInfo("Lat", AxisOrientationEnum.North));

            //Create UTM projection
            List <ProjectionParameter> parameters = new List <ProjectionParameter>();

            parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
            parameters.Add(new ProjectionParameter("central_meridian", -183 + 6 * utmZone));
            parameters.Add(new ProjectionParameter("scale_factor", 0.9996));
            parameters.Add(new ProjectionParameter("false_easting", 500000));
            parameters.Add(new ProjectionParameter("false_northing", 0.0));
            IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse Mercator", parameters);

            return(cFac.CreateProjectedCoordinateSystem("WGS 84 / UTM zone " + utmZone.ToString() + "N", gcs,
                                                        projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East),
                                                        new AxisInfo("North", AxisOrientationEnum.North)));
        }
コード例 #19
0
ファイル: Ellipsoid.cs プロジェクト: MohammadUT/IRI.Japey
 public bool AreTheSame(IEllipsoid other)
 {
     return
         (other.SemiMajorAxis.GetType() == this.SemiMajorAxis.GetType() &&
          this.SemiMajorAxis.Value == other.SemiMajorAxis.Value &&
          this.FirstEccentricity == other.FirstEccentricity);
 }
コード例 #20
0
        public void TestMercator_1SP_Projection()
        {
            CoordinateSystemFactory cFac = new CoordinateSystemFactory();

            IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("Bessel 1840", 6377397.155, 299.15281, LinearUnit.Metre);

            IHorizontalDatum            datum = cFac.CreateHorizontalDatum("Bessel 1840", DatumType.HD_Geocentric, ellipsoid, null);
            IGeographicCoordinateSystem gcs   = cFac.CreateGeographicCoordinateSystem("Bessel 1840", AngularUnit.Degrees, datum,
                                                                                      PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
                                                                                      new AxisInfo("Lat", AxisOrientationEnum.North));
            List <ProjectionParameter> parameters = new List <ProjectionParameter>(5);

            parameters.Add(new ProjectionParameter("latitude_of_origin", 0));
            parameters.Add(new ProjectionParameter("central_meridian", 110));
            parameters.Add(new ProjectionParameter("scale_factor", 0.997));
            parameters.Add(new ProjectionParameter("false_easting", 3900000));
            parameters.Add(new ProjectionParameter("false_northing", 900000));
            IProjection projection = cFac.CreateProjection("Mercator_1SP", "Mercator_1SP", parameters);

            IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Makassar / NEIEZ", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));

            ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, coordsys);

            double[] pGeo  = new double[] { 120, -3 };
            double[] pUtm  = trans.MathTransform.Transform(pGeo);
            double[] pGeo2 = trans.MathTransform.Inverse().Transform(pUtm);

            double[] expected = new double[] { 5009726.58, 569150.82 };
            Assert.IsTrue(ToleranceLessThan(pUtm, expected, 0.02), String.Format("Mercator_1SP forward transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", expected[0], expected[1], pUtm[0], pUtm[1]));
            Assert.IsTrue(ToleranceLessThan(pGeo, pGeo2, 0.0000001), String.Format("Mercator_1SP reverse transformation outside tolerance, Expected [{0},{1}], got [{2},{3}]", pGeo[0], pGeo[1], pGeo2[0], pGeo2[1]));
        }
コード例 #21
0
 internal MagneticCircle(IEllipsoid ellipsoid, double lat, double h, double t,
                         double cphi, double sphi, double t1, double dt0,
                         bool interpolate,
                         CircularEngine circ0, CircularEngine circ1, CircularEngine circ2 = null)
     : this(ellipsoid.EquatorialRadius, ellipsoid.Flattening, lat, h, t, cphi, sphi, t1, dt0, interpolate, circ0, circ1, circ2)
 {
 }
コード例 #22
0
        private static IHorizontalDatum ReadHorizontalDatum(XmlTextReader reader)
        {
            if (!(reader.NodeType == XmlNodeType.Element && reader.Name == "CS_HorizontalDatum"))
            {
                throw new ParseException(String.Format("Expected a IHorizontalDatum but got a {0} at line {1} col {2}", reader.Name, reader.LineNumber, reader.LinePosition));
            }

            /* <IHorizontalDatum DatumType="1001">
             *      <IInfo AuthorityCode="6277" Authority="EPSG" Name="OSGB_1936"/>
             *      <IEllipsoid SemiMajorAxis="6377563.396" SemiMinorAxis="6356256.90923729" InverseFlattening="299.3249646" IvfDefinitive="1">
             *              <IInfo AuthorityCode="7001" Authority="EPSG" Name="Airy 1830"/>
             *              <ILinearUnit MetersPerUnit="1">
             *                      <IInfo AuthorityCode="9001" Abbreviation="m" Authority="EPSG" Name="metre"/>
             *              </ILinearUnit>
             *      </IEllipsoid>
             *      <IWGS84ConversionInfo Dx="375" Dy="-111" Dz="431" Ex="0" Ey="0" Ez="0" Ppm="0"/>
             * </IHorizontalDatum>
             */
            string    datumTypeString = reader.GetAttribute("DatumType");
            DatumType datumType = (DatumType)Enum.Parse(typeof(DatumType), datumTypeString, true);
            string    authority = "", authorityCode = "", abbreviation = "", name = "";

            reader.Read();
            ReadInfo(reader, ref authority, ref authorityCode, ref abbreviation, ref name);
            IEllipsoid          ellipsoid = ReadEllipsoid(reader);
            WGS84ConversionInfo wgs84info = ReadWGS84ConversionInfo(reader);

            reader.Read();
            HorizontalDatum horizontalDatum = new HorizontalDatum(name, datumType, ellipsoid, wgs84info, "", authority, authorityCode, "", abbreviation);

            return(horizontalDatum);
        }
コード例 #23
0
        public EllipsoidalPoint <TLinear, TAngular> ToEllipsoial <TLinear, TAngular>(IEllipsoid ellipsoid, AngleRange horizontalRange)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            double tempSemiMajor = ellipsoid.SemiMajorAxis.ChangeTo <TLinear>().Value;

            double tempSemiMinor = ellipsoid.SemiMinorAxis.ChangeTo <TLinear>().Value;

            double e2TempValue = ellipsoid.FirstEccentricity * ellipsoid.FirstEccentricity;

            double tempX = this.X.ChangeTo <TLinear>().Value;

            double tempY = this.Y.ChangeTo <TLinear>().Value;

            double tempZ = this.Z.ChangeTo <TLinear>().Value;

            PolarPoint <TLinear, TAngular> tempValue = (new Cartesian2DPoint <TLinear>(new TLinear()
            {
                Value = tempX
            }, new TLinear()
            {
                Value = tempY
            })).ToPolar <TLinear, TAngular>(horizontalRange);

            double pTempValue = tempValue.Radius.Value;

            double nTempValue = ellipsoid.SemiMajorAxis.Value;

            double latitudeTempValue1 = Math.Atan(tempZ / pTempValue *
                                                  1 / (1 - (e2TempValue * nTempValue) / (nTempValue + 0)));

            if (latitudeTempValue1.Equals(double.NaN))
            {
                return(new EllipsoidalPoint <TLinear, TAngular>(ellipsoid, tempValue.Angle, (new Radian(0, horizontalRange))));
            }

            double latitudeTempValue2 = 0;

            bool conditionValue = true;

            do
            {
                nTempValue = ellipsoid.CalculateN(new Radian(latitudeTempValue1, AngleRange.MinusPiTOPi)).ChangeTo <TLinear>().Value;

                latitudeTempValue2 = Math.Atan(tempZ / pTempValue *
                                               1 / (1 - (e2TempValue * nTempValue) / (nTempValue + 0)));

                if (Math.Abs(0 - 0) + Math.Abs(latitudeTempValue2 - latitudeTempValue1) < allowedDifference)
                {
                    conditionValue = false;
                }
                else
                {
                    latitudeTempValue1 = latitudeTempValue2;
                }
            } while (conditionValue);

            return(new EllipsoidalPoint <TLinear, TAngular>(ellipsoid, tempValue.Angle, (new Radian(latitudeTempValue2, horizontalRange))));
        }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of a horizontal datum
 /// </summary>
 /// <param name="ellipsoid">Ellipsoid</param>
 /// <param name="toWgs84">Parameters for a Bursa Wolf transformation into WGS84</param>
 /// <param name="type">Datum type</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal HorizontalDatum(
     IEllipsoid ellipsoid, Wgs84ConversionInfo toWgs84, DatumType type,
     string name, string authority, long code, string alias, string remarks, string abbreviation)
     : base(type, name, authority, code, alias, remarks, abbreviation)
 {
     _Ellipsoid = ellipsoid;
     _Wgs84ConversionInfo = toWgs84;
 }
コード例 #25
0
        public void TestCreateEllipsoid1()
        {
            IEllipsoid ellipsoid = _csFactory.CreateEllipsoid("name", 1234.0, 1235, new LinearUnit(1));

            Assertion.AssertEquals("ctor. 1 ", "name", ellipsoid.Name);
            Assertion.AssertEquals("ctor. 2 ", 1234.0, ellipsoid.SemiMajorAxis);
            Assertion.AssertEquals("ctor. 3 ", 1235.0, ellipsoid.SemiMinorAxis);
        }
コード例 #26
0
 /// <summary>
 /// Initializes a new instance of a horizontal datum
 /// </summary>
 /// <param name="ellipsoid">Ellipsoid</param>
 /// <param name="toWgs84">Parameters for a Bursa Wolf transformation into WGS84</param>
 /// <param name="type">Datum type</param>
 /// <param name="name">Name</param>
 /// <param name="authority">Authority name</param>
 /// <param name="code">Authority-specific identification code.</param>
 /// <param name="alias">Alias</param>
 /// <param name="abbreviation">Abbreviation</param>
 /// <param name="remarks">Provider-supplied remarks</param>
 internal HorizontalDatum(
     IEllipsoid ellipsoid, Wgs84ConversionInfo toWgs84, DatumType type,
     string name, string authority, long code, string alias, string remarks, string abbreviation)
     : base(type, name, authority, code, alias, remarks, abbreviation)
 {
     _Ellipsoid           = ellipsoid;
     _Wgs84ConversionInfo = toWgs84;
 }
コード例 #27
0
 private static void WriteEllipsoid(IEllipsoid ellipsoid, IndentedTextWriter writer)
 {
     writer.WriteLine("SPHEROID[");
     writer.Indent = writer.Indent + 1;
     writer.WriteLine(String.Format("\"{0}\",{1},{2},", ellipsoid.Name, ellipsoid.SemiMajorAxis, ellipsoid.InverseFlattening));
     writer.WriteLine(String.Format("AUTHORITY[\"{0}\",\"{1}\"]", ellipsoid.Authority, ellipsoid.AuthorityCode));
     writer.Indent = writer.Indent - 1;
     writer.WriteLine("]");
 }
コード例 #28
0
        public static Geodetic <TLinear, TAngular> ChangeDatum <TLinear, TAngular>(
            IGeodetic oldGeodeticCoordinate,
            IEllipsoid newDatum)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            ICartesian3D tempCoordinate = GeodeticToAverage <TLinear>(oldGeodeticCoordinate);

            return(AverageToGeodetic <TLinear, TAngular>(tempCoordinate, newDatum, oldGeodeticCoordinate.LongitudinalRange));
        }
コード例 #29
0
        public void TestCreateFlattenedSphere1()
        {
            ICoordinateSystemFactory csFactory = new CoordinateSystemFactory();
            IEllipsoid ellipsoid = csFactory.CreateFlattenedSphere("test", 20926348.0, 294.26068, new LinearUnit(1));

            Assertion.AssertEquals("ctor. 1 ", "test", ellipsoid.Name);
            Assertion.AssertEquals("ctor. 2 ", 20926348.0, ellipsoid.SemiMajorAxis);
            Assertion.AssertEquals("ctor. 3 ", 20855233.000877455, ellipsoid.SemiMinorAxis);
            Assertion.AssertEquals("ctor. 4 ", 294.26068, ellipsoid.InverseFlattening);
        }
コード例 #30
0
        public void TestReadEllipsoid()
        {
            string     testFile  = Global.GetUnitTestRootDirectory() + @"\IO\Spheroid.txt";
            string     wkt1      = FileToString(testFile);
            IEllipsoid Ellipsoid = CoordinateSystemWktReader.Create(wkt1) as IEllipsoid;
            string     wkt2      = Ellipsoid.WKT;
            bool       same      = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Ellipsoid 1", true, same);
        }
コード例 #31
0
 public void TestCreateEllipsoid2()
 {
     try
     {
         IEllipsoid ellipsoid = _csFactory.CreateEllipsoid("test", 1, 2, null);
         Assertion.Fail("ArgumentNullException should be thrown  for null linear unit parameter.");
     }
     catch (ArgumentNullException)
     {
     }
 }
コード例 #32
0
        public void Test_Ellipsoid()
        {
            IEllipsoid ellipsoid = _factory.CreateEllipsoid("7001");

            Assertion.AssertEquals("Ellipsoid Remarks", "Original definition is a=20923713 and b=20853810 feet of 1796.   For the 1936 retriangulation OSGB defines the relationship of feet of 1796 to the International metre through log(1.48401603) exactly [=0.3048007491...]. 1/f is given to 7 decimal places.", ellipsoid.Remarks);
            Assertion.AssertEquals("Ellipsoid Name", "Airy 1830", ellipsoid.Name);
            Assertion.AssertEquals("Ellipsoid Major Axis", "6377563.396", ellipsoid.SemiMajorAxis.ToString());
            Assertion.AssertEquals("Ellipsoid Minor Axis", "6356256.90923729", ellipsoid.SemiMinorAxis.ToString());
            Assertion.AssertEquals("Ellipsoid flattening", 299.3249646, ellipsoid.InverseFlattening);
            Assertion.AssertEquals("Ellipsoid IVF Definitive", true, ellipsoid.IsIvfDefinitive());
        }
コード例 #33
0
        /// <summary>
        /// 转换操作。输入待转坐标,输出目标坐标。
        /// </summary>
        /// <param name="oldCoord">待转坐标,只取其数字部分,参考系取自属性本对象的TargetCrs属性 </param>
        /// <returns></returns>
        public override ICoordinate MatchedTrans(ICoordinate oldCoord)
        {
            IEllipsoid e = (TargetCrs.Datum as GeodeticDatum).Ellipsoid;

            IGeodeticCoord geo = (IGeodeticCoord)oldCoord;
            double         x, y, z;

            GeodeticUtils.GeodeticToXyzCoord(geo.Lon, geo.Lat, geo.Height, out x, out y, out z, e.SemiMajorAxis, e.InverseFlattening);

            return(CoordinateFactory.CreateXyzCoord(x, y, z, oldCoord.Weight));
        }
コード例 #34
0
ファイル: HorizontalDatum.cs プロジェクト: vmoll/geotools
        /// <summary>
        ///  Initializes a new instance of the HorizontalDatum class with the specififed properties.
        /// </summary>
        /// <param name="name">The name of the datum.</param>
        /// <param name="horizontalDatumType">The datum type.</param>
        /// <param name="ellipsoid">The ellipsoid.</param>
        /// <param name="toWGS84">The WGS conversion parameters.</param>
        /// <param name="remarks">Remarks about this object.</param>
        /// <param name="authority">The name of the authority.</param>
        /// <param name="authorityCode">The code the authority uses to identidy this object.</param>
        /// <param name="alias">The alias of the object.</param>
        /// <param name="abbreviation">The abbreviated name of this object.</param>
        public HorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid, WGS84ConversionInfo toWGS84,
			string remarks, string authority, string authorityCode, string alias, string abbreviation)
            : base(horizontalDatumType, remarks, authority, authorityCode, name, alias, abbreviation)
        {
            if (ellipsoid==null)
            {
                throw new ArgumentNullException("ellipsoid");
            }
            _ellipsoid = ellipsoid;
            _wgs84ConversionInfo = toWGS84;
        }
コード例 #35
0
ファイル: UTM.cs プロジェクト: itaibh/GeoUtils.Net
        public UTMLocation Project(LatLongAlt worldPosition, IEllipsoid ellipsoid)
        {
            double lonDeg = worldPosition.LongitudeNormalized.Degrees;
            double lonRad = lonDeg * Math.PI / 180;

            double latDeg = worldPosition.LatitudeNormalized.Degrees;
            double latRad = latDeg * Math.PI / 180;

            int zone = GetZone(lonDeg, latDeg);

            double lonOrigDeg = (zone - 1) * 6 - 180 + 3;  //+3 puts origin in middle of zone
            double lonOrigRad = lonOrigDeg * Math.PI / 180;
            double ecc2 = ellipsoid.EccentricitySquared;
            double ecc4 = ecc2 * ecc2;
            double ecc6 = ecc4 * ecc2;
            double eccPrimeSquared = ecc2 / (1 - ecc2);

            double a = ellipsoid.SemiMajorAxis.Meters;

            double sinLat = Math.Sin(latRad);
            double cosLat = Math.Cos(latRad);
            double tanLat = Math.Tan(latRad);

            double N = a / Math.Sqrt(1 - ellipsoid.EccentricitySquared * sinLat * sinLat);
            double T = tanLat * tanLat;
            double C = eccPrimeSquared * cosLat * cosLat;
            double A = cosLat * (lonRad - lonOrigRad);
            double A2 = A * A;
            double A3 = A * A * A;

            double M = a * ((1 - ecc2 / 4 - 3 * ecc4 / 64 - 5 * ecc6 / 256) * latRad
                        - (3 * ecc2 / 8 + 3 * ecc4 / 32 + 45 * ecc6 / 1024) * Math.Sin(2 * latRad)
                        + (15 * ecc4 / 256 + 45 * ecc6 / 1024) * Math.Sin(4 * latRad)
                        - (35 * ecc6 / 3072) * Math.Sin(6 * latRad));

            double k0 = 0.9996;

            double easting = (double)(k0 * N * (A + (1 - T + C) * A3 / 6
                            + (5 - 18 * T + T * T + 72 * C - 58 * eccPrimeSquared) * A3 * A2 / 120)
                            + 500000.0);

            double northing = (double)(k0 * (M + N * tanLat * (A2 / 2 + (5 - T + 9 * C + 4 * C * C) * A3 * A / 24
                         + (61 - 58 * T + T * T + 600 * C - 330 * eccPrimeSquared) * A3 * A3 / 720)));

            if (latDeg < 0)
                northing += 10000000.0; //10000000 meter offset for southern hemisphere

            return new UTMLocation(Length.FromMeters(easting), Length.FromMeters(northing), zone);
        }
コード例 #36
0
 public IHorizontalDatum CreateHorizontalDatum(string name, DatumType datumType, IEllipsoid ellipsoid,
     Wgs84ConversionInfo toWgs84)
 {
     throw new NotImplementedException();
 }
        private Projection CreateProjection(int code, IEllipsoid elipsoid)
        {
            var consulta = from nodo in GIGSDataSet.projections
                           where nodo.Code == code
                           select nodo;

            if (0 == consulta.Count())
                return null;

            var dato = consulta.First();

            List<ProjectionParameter> parámetros = new List<ProjectionParameter>();
            AnadeParámetroAListaParámetros(parámetros, dato.Parameter1Name, dato.Parameter1Value, dato.Parameter1Unit);
            AnadeParámetroAListaParámetros(parámetros, dato.Parameter2Name, dato.Parameter2Value, dato.Parameter2Unit);
            AnadeParámetroAListaParámetros(parámetros, dato.Parameter3Name, dato.Parameter3Value, dato.Parameter3Unit);
            AnadeParámetroAListaParámetros(parámetros, dato.Parameter4Name, dato.Parameter4Value, dato.Parameter4Unit);
            AnadeParámetroAListaParámetros(parámetros, dato.Parameter5Name, dato.Parameter5Value, dato.Parameter5Unit);
            AnadeParámetroAListaParámetros(parámetros, dato.Parameter6Name, dato.Parameter6Value, dato.Parameter6Unit);
            AnadeParámetroAListaParámetros(parámetros, dato.Parameter7Name, dato.Parameter7Value, dato.Parameter7Unit);

            return new Projection(dato.NombreOGS, parámetros.ToArray());
        }
コード例 #38
0
 private static void WriteEllipsoid(IEllipsoid ellipsoid, IndentedTextWriter writer)
 {
     writer.WriteLine("SPHEROID[");
     writer.Indent=writer.Indent+1;
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "\"{0}\",{1},{2},", ellipsoid.Name,ellipsoid.SemiMajorAxis, ellipsoid.InverseFlattening ));
     writer.WriteLine(String.Format(System.Globalization.CultureInfo.InvariantCulture, "AUTHORITY[\"{0}\",\"{1}\"]", ellipsoid.Authority, ellipsoid.AuthorityCode));
     writer.Indent=writer.Indent-1;
     writer.WriteLine("]");
 }
コード例 #39
0
ファイル: CoordinateSystemFactory.cs プロジェクト: maxm/osmuy
        /// <summary>
        /// Creates <see cref="HorizontalDatum"/> from ellipsoid and Bursa-World parameters.
        /// </summary>
        /// <remarks>
        /// Since this method contains a set of Bursa-Wolf parameters, the created 
        /// datum will always have a relationship to WGS84. If you wish to create a
        /// horizontal datum that has no relationship with WGS84, then you can 
        /// either specify a <see cref="DatumType">horizontalDatumType</see> of <see cref="DatumType.HD_Other"/>, or create it via WKT.
        /// </remarks>
        /// <param name="name">Name of ellipsoid</param>
        /// <param name="datumType">Type of datum</param>
        /// <param name="ellipsoid">Ellipsoid</param>
        /// <param name="toWgs84">Wgs84 conversion parameters</param>
        /// <returns>Horizontal datum</returns>
        public IHorizontalDatum CreateHorizontalDatum(string name, DatumType datumType, IEllipsoid ellipsoid, Wgs84ConversionInfo toWgs84)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentException("Invalid name");
            if (ellipsoid == null)
                throw new ArgumentException("Ellipsoid was null");

            return new HorizontalDatum(ellipsoid, toWgs84, datumType, name, String.Empty, -1, String.Empty, String.Empty, String.Empty);
        }
コード例 #40
0
		private static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid, ILinearUnit unit)
		{
			var parameterList = new List<ProjectionParameter>(projection.NumParameters);
			for (var i = 0; i < projection.NumParameters; i++)
				parameterList.Add(projection.GetParameter(i));

		    //var toMeter = 1d/ellipsoid.AxisUnit.MetersPerUnit;
            if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_major")) == null)
			    parameterList.Add(new ProjectionParameter("semi_major", /*toMeter * */ellipsoid.SemiMajorAxis));
            if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_minor")) == null)
                parameterList.Add(new ProjectionParameter("semi_minor", /*toMeter * */ellipsoid.SemiMinorAxis));
            if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("unit")) == null)
                parameterList.Add(new ProjectionParameter("unit", unit.MetersPerUnit));

            var operation = ProjectionsRegistry.CreateProjection(projection.ClassName, parameterList);
		    /*
            var mpOperation = operation as MapProjection;
            if (mpOperation != null && projection.AuthorityCode !=-1)
            {
                mpOperation.Authority = projection.Authority;
                mpOperation.AuthorityCode = projection.AuthorityCode;
            }
             */

		    return operation;
		    /*
            switch (projection.ClassName.ToLower(CultureInfo.InvariantCulture).Replace(' ', '_'))
			{
				case "mercator":
				case "mercator_1sp":
				case "mercator_2sp":
					//1SP
					transform = new Mercator(parameterList);
					break;
				case "transverse_mercator":
					transform = new TransverseMercator(parameterList);
					break;
				case "albers":
				case "albers_conic_equal_area":
					transform = new AlbersProjection(parameterList);
					break;
				case "krovak":
					transform = new KrovakProjection(parameterList);
					break;
                case "polyconic":
                    transform = new PolyconicProjection(parameterList);
                    break;
                case "lambert_conformal_conic":
				case "lambert_conformal_conic_2sp":
				case "lambert_conic_conformal_(2sp)":
					transform = new LambertConformalConic2SP(parameterList);
					break;
				default:
					throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.ClassName));
			}
			return transform;
             */
		}
コード例 #41
0
        private static IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid, ILinearUnit unit)
        {
            List<ProjectionParameter> parameterList = new List<ProjectionParameter>(projection.NumParameters);
            for (int i = 0; i < projection.NumParameters; i++)
                parameterList.Add(projection.GetParameter(i));

            parameterList.Add(new ProjectionParameter("semi_major", ellipsoid.SemiMajorAxis));
            parameterList.Add(new ProjectionParameter("semi_minor", ellipsoid.SemiMinorAxis));
            parameterList.Add(new ProjectionParameter("unit", unit.MetersPerUnit));
            IMathTransform transform = null;
            switch (projection.ClassName.ToLower(CultureInfo.InvariantCulture).Replace(' ', '_'))
            {
                case "mercator":
                case "mercator_1sp":
                case "mercator_2sp":
                    //1SP
                    transform = new Mercator(parameterList);
                    break;
                case "transverse_mercator":
                    transform = new TransverseMercator(parameterList);
                    break;
                case "albers":
                case "albers_conic_equal_area":
                    transform = new AlbersProjection(parameterList);
                    break;
                case "krovak":
                    transform = new KrovakProjection(parameterList);
                    break;
                case "lambert_conformal_conic":
                case "lambert_conformal_conic_2sp":
                case "lambert_conic_conformal_(2sp)":
                    transform = new LambertConformalConic2SP(parameterList);
                    break;
                default:
                    throw new NotSupportedException(String.Format("Projection {0} is not supported.", projection.ClassName));
            }
            return transform;
        }
コード例 #42
0
		/// <summary>
		/// Creates horizontal datum from ellipsoid and Bursa-World parameters. Since this method
		/// contains a set of Bursa-Wolf parameters, the created datum will always have a relationship to
		/// WGS84. If you wish to create a horizontal datum that has no relationship with WGS84, then you
		/// can either specify a horizontalDatumType of IHD_Other, or create it via WKT.
		/// </summary>
		/// <param name="name">The name of the datum to create.</param>
		/// <param name="horizontalDatumType">The IDatumType type use when creating the datum.</param>
		/// <param name="ellipsoid">The ellipsoid to use then creating the datum.</param>
		/// <param name="toWGS84">WKGS conversion parameters.</param>
		/// <returns>An object that implements the IHorizontalDatum interface.</returns>
		public IHorizontalDatum CreateHorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid,  WGS84ConversionInfo toWGS84)
		{
			if (name==null)
			{
				throw new ArgumentNullException("name");
			}
			if (ellipsoid==null)
			{
				throw new ArgumentNullException("ellipsoid");
			}
			// no need to check horizontalDatumType and toWGS84 because they are value types.

			return new HorizontalDatum(name, horizontalDatumType, ellipsoid, toWGS84);
		}
コード例 #43
0
        /// <summary>
        /// Given a IProjection and a IEllipsoid, createa a IMathTransform with the required parameters.
        /// </summary>
        /// <param name="projection">The projection information.</param>
        /// <param name="ellipsoid">The ellipsoid to use.</param>
        /// <returns>An object that implements the IMathTransform interface.</returns>
        private IMathTransform CreateCoordinateOperation(IProjection projection, IEllipsoid ellipsoid)
        {
            ParameterList parameterList = new ParameterList();
            for(int i=0; i< projection.NumParameters; i++)
            {
                ProjectionParameter param = projection.GetParameter(i);
                parameterList.Add(param.Name,param.Value);
            }
            parameterList.Add("semi_major",ellipsoid.SemiMajorAxis);
            parameterList.Add("semi_minor",ellipsoid.SemiMinorAxis);

            IMathTransform transform = null;
            switch(projection.AuthorityCode)
            {
                case "9804":
                    //1SP
                    transform = new MercatorProjection(parameterList);
                    break;
                case "9805":
                    //2SP
                    transform = new MercatorProjection(parameterList);
                    break;
                case "9807":
                    transform = new TransverseMercatorProjection(parameterList);
                    break;
                case "9633":
                    // we should get these parameters from the file - but since we know them....
                    ParameterList param = new ParameterList();
                    parameterList.Add("latitude_of_natural_origin",49.0);
                    parameterList.Add("longitude_of_natural_origin",-2.0);
                    parameterList.Add("scale_factor_at_natural_origin",0.999601272);
                    parameterList.Add("false_easting",400000.0);
                    parameterList.Add("false_northing",-100000.0);
                    transform = new MercatorProjection(parameterList);
                    break;
                default:
                    throw new NotSupportedException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "Projection {0} is not supported.",projection.AuthorityCode));
            }
            return transform;
        }
コード例 #44
0
ファイル: HorizontalDatum.cs プロジェクト: vmoll/geotools
 /// <summary>
 ///  Initializes a new instance of the HorizontalDatum class with the specififed properties.
 /// </summary>
 /// <param name="name">The name of the datum.</param>
 /// <param name="horizontalDatumType">The datum type.</param>
 /// <param name="ellipsoid">The ellipsoid.</param>
 /// <param name="toWGS84">The WGS conversion parameters.</param>
 internal HorizontalDatum(string name, DatumType horizontalDatumType, IEllipsoid ellipsoid, WGS84ConversionInfo toWGS84)
     : this(name, horizontalDatumType, ellipsoid, toWGS84,"", "", "", "", "")
 {
 }