public void ReadProjectionFile(string resourceName)
        {
            string prjFile = System.IO.Path.GetTempFileName();

            try
            {
                System.IO.File.WriteAllText(prjFile, Properties.Resources.ResourceManager.GetString(resourceName, Properties.Resources.Culture));
                ProjectionInfo info = ProjectionInfo.Open(prjFile);

                Assert.AreEqual("WGS_1984_Web_Mercator_Auxiliary_Sphere", info.Name);
                Assert.AreEqual("GCS_WGS_1984", info.GeographicInfo.Name);
                Assert.AreEqual("D_WGS_1984", info.GeographicInfo.Datum.Name);
                Assert.AreEqual("WGS_1984", info.GeographicInfo.Datum.Spheroid.Name);
                Assert.AreEqual(6378137, info.GeographicInfo.Datum.Spheroid.EquatorialRadius, 1e-10);
                Assert.AreEqual(298.257223562997, info.GeographicInfo.Datum.Spheroid.InverseFlattening, 1e-10);
                Assert.AreEqual("Greenwich", info.GeographicInfo.Meridian.Name);
                Assert.AreEqual(0, info.GeographicInfo.Meridian.Longitude, 1e-10);
                Assert.AreEqual("Degree", info.GeographicInfo.Unit.Name);
                Assert.AreEqual(0.0174532925199433, info.GeographicInfo.Unit.Radians, 1e-10);
                Assert.AreEqual("Mercator_Auxiliary_Sphere", info.Transform.Name);
                Assert.AreEqual("Meter", info.Unit.Name);
                Assert.AreEqual(1, info.Unit.Meters, 1e-10);
            }
            finally
            {
                System.IO.File.Delete(prjFile);
            }
        }
Exemple #2
0
        /// <summary>
        /// This uses the fileName of this shapefile to read the prj file of the same name
        /// and stores the result in the Projection class.
        /// </summary>
        public void ReadProjection()
        {
            string prjFile = Path.ChangeExtension(Filename, ".prj");

            if (File.Exists(prjFile))
            {
                Projection = ProjectionInfo.Open(prjFile);
            }
            else
            {
                Projection = new ProjectionInfo();
            }
        }
        //Sample code that will conduct a reprojection by reading in the ESRI.prj file
        public static void ReadingEsriPrjFiles()
        {
            //declares a new ProjectionInfo for the startind and ending coordinate systems
            //sets the start GCS to WGS_1984
            ProjectionInfo pStart   = KnownCoordinateSystems.Geographic.World.WGS1984;
            ProjectionInfo pESRIEnd = ProjectionInfo.Open("C:\\Program Files\\ArcGIS\\Coordinate Systems\\Projected Coordinate Systems\\UTM\\WGS 1984\\WGS 1984 UTM Zone 1N.prj");

            //declares the point(s) that will be reprojected
            double[] xy = new double[2];
            double[] z  = new double[1];
            //calls the reprojection function
            Reproject.ReprojectPoints(xy, z, pStart, pESRIEnd, 0, 1);

            Console.WriteLine("Points have been projected successfully");
        }
Exemple #4
0
        /// <summary>
        /// This uses the fileName of this shapefile to read the prj file of the same name
        /// and stores the result in the Projection class.
        /// </summary>
        public void ReadProjection()
        {
            var prjFile = Path.ChangeExtension(Filename, ".prj");

            Projection = File.Exists(prjFile) ? ProjectionInfo.Open(prjFile) : new ProjectionInfo();
        }