Пример #1
0
        /// <summary>
        /// Creates a coordinate system that conforms to WGS 84.
        /// </summary>
        /// <returns>IGeographicCoordinateSystem that represents the WKG84 coordinate system.</returns>
        public static IGeographicCoordinateSystem CreateWgs84()
        {
            string wktTargetCS = Projections.WGS84;
            IGeographicCoordinateSystem targetCS = (IGeographicCoordinateSystem)CoordinateSystemWktReader.Create(wktTargetCS);

            return(targetCS);
        }
Пример #2
0
 /// <summary>
 /// Creates a coordinate system object from a Well-Known Text string.
 /// </summary>
 /// <param name="wkt"></param>
 /// <returns></returns>
 public ICoordinateSystem CreateFromWKT(string wkt)
 {
     if (wkt == null)
     {
         throw new ArgumentNullException("wkt");
     }
     return((ICoordinateSystem)CoordinateSystemWktReader.Create(wkt));
 }
Пример #3
0
 public void TestReadUnit2()
 {
     string       wkt1        = "UNIT[\"degree\",0.01745329251994433,AUTHORITY[\"EPSG\",\"9102\"]]";
     IAngularUnit angularUnit = CoordinateSystemWktReader.Create(wkt1) as IAngularUnit;
     string       wkt2        = angularUnit.WKT;
     bool         same        = Compare.CompareAgainstString(Global.GetUnitTestRootDirectory() + @"\IO\AngularUnit.txt", wkt2);
     //Assertion.AssertEquals("test 1",true,same); fails because of issues with double and precsision
 }
Пример #4
0
        public void TestReadHorizontalDatum()
        {
            string           testFile        = Global.GetUnitTestRootDirectory() + @"\IO\HorizontalDatum.txt";
            string           wkt1            = FileToString(testFile);
            IHorizontalDatum horizontalDatum = CoordinateSystemWktReader.Create(wkt1) as IHorizontalDatum;
            string           wkt2            = horizontalDatum.WKT;
            bool             same            = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Horizontal datum 1", true, same);
        }
Пример #5
0
        public void TestReadUnit3()
        {
            string      testFile   = Global.GetUnitTestRootDirectory() + @"\IO\LinearUnit.txt";
            string      wkt1       = FileToString(testFile);
            ILinearUnit linearUnit = CoordinateSystemWktReader.Create(wkt1) as ILinearUnit;
            string      wkt2       = linearUnit.WKT;
            bool        same       = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Unit 3", true, same);
        }
Пример #6
0
        public void TestReadCompoundCoordinateSystem2()
        {
            string testFile = Global.GetUnitTestRootDirectory() + @"\IO\CompoundCoordinateSystem.txt";
            string wkt1     = FileToString(testFile);
            ICompoundCoordinateSystem compoundCoordinateSystem = CoordinateSystemWktReader.Create(wkt1) as ICompoundCoordinateSystem;
            string wkt2 = compoundCoordinateSystem.WKT;
            bool   same = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Compound coordinate system 1", true, same);
        }
Пример #7
0
        public void TestReadPrimeMeridian2()
        {
            string         testFile      = Global.GetUnitTestRootDirectory() + @"\IO\PrimeMeridian.txt";
            string         wkt1          = FileToString(testFile);
            IPrimeMeridian primeMeridian = CoordinateSystemWktReader.Create(wkt1) as IPrimeMeridian;
            string         wkt2          = primeMeridian.WKT;
            bool           same          = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Prime Meridian 1", true, same);
        }
Пример #8
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);
        }
        public void TestReadGeographicCoordinateSystem2()
        {
            string testFile = Global.GetUnitTestRootDirectory() + @"\IO\Testfiles\GeographicCoordinateSystem.txt";
            string wkt1     = FileToString(testFile);
            IGeographicCoordinateSystem geographicCoordinateSystem = CoordinateSystemWktReader.Create(wkt1) as IGeographicCoordinateSystem;
            string wkt2 = geographicCoordinateSystem.WKT;
            bool   same = Compare.CompareAgainstString(testFile, wkt2);

            Assertion.AssertEquals("Geographic coordinate system 1", true, same);
        }
Пример #10
0
        /// <summary>
        /// Creates the projection required for the European raster data from the AA.
        /// </summary>
        /// <returns>ICoordinateTransformation that implements the Mercator projection.</returns>
        public static ICoordinateTransformation CreateEuropeanLambertProjection()
        {
            string wktSourceCS = Projections.EuropeanLambert;

            IProjectedCoordinateSystem  sourceCS = (IProjectedCoordinateSystem)CoordinateSystemWktReader.Create(wktSourceCS);
            IGeographicCoordinateSystem targetCS = CreateWgs84();

            CoordinateTransformationFactory coordTransFactory = new CoordinateTransformationFactory();
            ICoordinateTransformation       projection        = coordTransFactory.CreateFromCoordinateSystems(sourceCS, targetCS);

            return(projection);
        }
Пример #11
0
        /// <summary>
        /// Creates a Meractor projection object.
        /// </summary>
        /// <param name="centralMeridian">The central merdian to use.</param>
        /// <param name="falseNorthing">The false northing to use.</param>
        /// <returns>ICoordinateTransformation that implements the Mercator projection.</returns>
        public static ICoordinateTransformation CreateUKNationalGridProjection(double centralMeridian, double falseNorthing)
        {
            string wktSourceCS = Projections.UKNationalGrid;

            wktSourceCS = String.Format(CultureInfo.InvariantCulture, wktSourceCS, falseNorthing, centralMeridian);

            IProjectedCoordinateSystem  sourceCS = (IProjectedCoordinateSystem)CoordinateSystemWktReader.Create(wktSourceCS);
            IGeographicCoordinateSystem targetCS = CreateWgs84();

            CoordinateTransformationFactory coordTransFactory = new CoordinateTransformationFactory();
            ICoordinateTransformation       projection        = coordTransFactory.CreateFromCoordinateSystems(sourceCS, targetCS);

            return(projection);
        }
Пример #12
0
 public void TestReadUnit1()
 {
     string       wkt         = "UNIT[\"degree\",0.01745329251994433,AUTHORITY[\"EPSG\",\"9102\"]]";
     IAngularUnit angularUnit = CoordinateSystemWktReader.Create(wkt) as IAngularUnit;
 }