Exemple #1
0
        /// <summary>
        /// Creates a new instance of Antarctica
        /// </summary>
        public Antarctica()
        {
            AustralianAntarctic1998   = ProjectionInfo.FromProj4String("+proj=longlat +ellps=GRS80 +no_defs ");
            CampAreaAstro             = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            DeceptionIsland           = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk80 +no_defs ");
            Petrels1972               = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            PointeGeologiePerroud1950 = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");

            AustralianAntarctic1998.Name = "GCS_Australian_Antarctic_1998";
            AustralianAntarctic1998.GeographicInfo.Name = "GCS_Australian_Antarctic_1998";
            CampAreaAstro.Name = "GCS_Camp_Area";
            CampAreaAstro.GeographicInfo.Name = "GCS_Camp_Area";
            DeceptionIsland.Name = "GCS_Deception_Island";
            DeceptionIsland.GeographicInfo.Name = "GCS_Deception_Island";
            Petrels1972.Name = "GCS_Petrels_1972";
            Petrels1972.GeographicInfo.Name = "GCS_Petrels_1972";
            PointeGeologiePerroud1950.Name  = "GCS_Pointe_Geologie_Perroud_1950";
            PointeGeologiePerroud1950.GeographicInfo.Name = "GCS_Pointe_Geologie_Perroud_1950";

            AustralianAntarctic1998.GeographicInfo.Datum.Name   = "D_Australian_Antarctic_1998";
            CampAreaAstro.GeographicInfo.Datum.Name             = "D_Camp_Area";
            DeceptionIsland.GeographicInfo.Datum.Name           = "D_Deception_Island";
            Petrels1972.GeographicInfo.Datum.Name               = "D_Petrels_1972";
            PointeGeologiePerroud1950.GeographicInfo.Datum.Name = "D_Pointe_Geologie_Perroud_1950";
        }
Exemple #2
0
        private void ReadHeader()
        {
            DataType = typeof(T);
            base.NumColumnsInFile = _dataset.RasterXSize;
            base.NumColumns       = base.NumColumnsInFile;
            base.NumRowsInFile    = _dataset.RasterYSize;
            base.NumRows          = base.NumRowsInFile;
            // Todo: look for prj file if GetProjection returns null.
            // Do we need to read this as an Esri string if we don't get a proj4 string?
            string projString = _dataset.GetProjection();

            Projection = ProjectionInfo.FromProj4String(projString);
            if (_band != null)
            {
                double val;
                int    hasInterval;
                _band.GetNoDataValue(out val, out hasInterval);
                base.NoDataValue = val;
            }
            double[] affine = new double[6];
            _dataset.GetGeoTransform(affine);
            ProjectionString = projString;
            Bounds           = new RasterBounds(base.NumRows, base.NumColumns, affine);
            PixelSpace       = System.Runtime.InteropServices.Marshal.SizeOf(typeof(T));
        }
Exemple #3
0
        /// <summary>
        /// Creates a new instance of Australia
        /// </summary>
        public Australia()
        {
            AustralianGeodeticDatum1966    = ProjectionInfo.FromProj4String("+proj=longlat +ellps=aust_SA +no_defs ");
            AustralianGeodeticDatum1984    = ProjectionInfo.FromProj4String("+proj=longlat +ellps=aust_SA +no_defs ");
            ChathamIslands1979             = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            GeocentricDatumofAustralia1994 = ProjectionInfo.FromProj4String("+proj=longlat +ellps=GRS80 +no_defs ");
            NewZealandGeodeticDatum1949    = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            NZGD2000 = ProjectionInfo.FromProj4String("+proj=longlat +ellps=GRS80 +no_defs ");

            AustralianGeodeticDatum1966.IsLatLon    = true;
            AustralianGeodeticDatum1984.IsLatLon    = true;
            ChathamIslands1979.IsLatLon             = true;
            GeocentricDatumofAustralia1994.IsLatLon = true;
            NewZealandGeodeticDatum1949.IsLatLon    = true;
            NZGD2000.IsLatLon = true;

            AustralianGeodeticDatum1966.GeographicInfo.Name    = "GCS_Australian_1966";
            AustralianGeodeticDatum1984.GeographicInfo.Name    = "GCS_Australian_1984";
            ChathamIslands1979.GeographicInfo.Name             = "GCS_Chatham_Islands_1979";
            GeocentricDatumofAustralia1994.GeographicInfo.Name = "GCS_GDA_1994";
            NewZealandGeodeticDatum1949.GeographicInfo.Name    = "GCS_New_Zealand_1949";
            NZGD2000.GeographicInfo.Name = "GCS_NZGD_2000";

            AustralianGeodeticDatum1966.GeographicInfo.Datum.Name    = "D_Australian_1966";
            AustralianGeodeticDatum1984.GeographicInfo.Datum.Name    = "D_Australian_1984";
            ChathamIslands1979.GeographicInfo.Datum.Name             = "D_Chatham_Islands_1979";
            GeocentricDatumofAustralia1994.GeographicInfo.Datum.Name = "D_GDA_1994";
            NewZealandGeodeticDatum1949.GeographicInfo.Datum.Name    = "D_New_Zealand_1949";
            NZGD2000.GeographicInfo.Datum.Name = "D_NZGD_2000";
        }
Exemple #4
0
        /// <summary>
        /// Creates a new instance of Asia
        /// </summary>
        public Asia()
        {
            AsiaLambertConformalConic      = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=30 +lat_2=62 +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ");
            AsiaNorthAlbersEqualAreaConic  = ProjectionInfo.FromProj4String("+proj=aea +lat_1=15 +lat_2=65 +lat_0=30 +lon_0=95 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ");
            AsiaNorthEquidistantConic      = ProjectionInfo.FromProj4String("+proj=eqdc +lat_0=0 +lon_0=0 +lat_1=15 +lat_2=65 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ");
            AsiaNorthLambertConformalConic = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=15 +lat_2=65 +lat_0=30 +lon_0=95 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ");
            AsiaSouthAlbersEqualAreaConic  = ProjectionInfo.FromProj4String("+proj=aea +lat_1=7 +lat_2=-32 +lat_0=-15 +lon_0=125 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ");
            AsiaSouthEquidistantConic      = ProjectionInfo.FromProj4String("+proj=eqdc +lat_0=0 +lon_0=0 +lat_1=7 +lat_2=-32 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ");
            AsiaSouthLambertConformalConic = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=7 +lat_2=-32 +lat_0=-15 +lon_0=125 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ");

            AsiaLambertConformalConic.Name      = "Asia_Lambert_Conformal_Conic";
            AsiaNorthAlbersEqualAreaConic.Name  = "Asia_North_Albers_Equal_Area_Conic";
            AsiaNorthEquidistantConic.Name      = "Asia_North_Equidistant_Conic";
            AsiaNorthLambertConformalConic.Name = "Asia_North_Lambert_Conformal_Conic";
            AsiaSouthAlbersEqualAreaConic.Name  = "Asia_South_Albers_Equal_Area_Conic";
            AsiaSouthEquidistantConic.Name      = "Asia_South_Equidistant_Conic";
            AsiaSouthLambertConformalConic.Name = "Asia_South_Lambert_Conformal_Conic";

            AsiaLambertConformalConic.GeographicInfo.Name      = "GCS_WGS_1984";
            AsiaNorthAlbersEqualAreaConic.GeographicInfo.Name  = "GCS_WGS_1984";
            AsiaNorthEquidistantConic.GeographicInfo.Name      = "GCS_WGS_1984";
            AsiaNorthLambertConformalConic.GeographicInfo.Name = "GCS_WGS_1984";
            AsiaSouthAlbersEqualAreaConic.GeographicInfo.Name  = "GCS_WGS_1984";
            AsiaSouthEquidistantConic.GeographicInfo.Name      = "GCS_WGS_1984";
            AsiaSouthLambertConformalConic.GeographicInfo.Name = "GCS_WGS_1984";

            AsiaLambertConformalConic.GeographicInfo.Datum.Name      = "D_WGS_1984";
            AsiaNorthAlbersEqualAreaConic.GeographicInfo.Datum.Name  = "D_WGS_1984";
            AsiaNorthEquidistantConic.GeographicInfo.Datum.Name      = "D_WGS_1984";
            AsiaNorthLambertConformalConic.GeographicInfo.Datum.Name = "D_WGS_1984";
            AsiaSouthAlbersEqualAreaConic.GeographicInfo.Datum.Name  = "D_WGS_1984";
            AsiaSouthEquidistantConic.GeographicInfo.Datum.Name      = "D_WGS_1984";
            AsiaSouthLambertConformalConic.GeographicInfo.Datum.Name = "D_WGS_1984";
        }
Exemple #5
0
        /// <summary>
        /// Creates a new instance of Europe
        /// </summary>
        public Europe()
        {
            EMEP150KilometerGrid = new ProjectionInfo();
            EMEP150KilometerGrid.ParseEsriString("PROJCS[\"EMEP_150_Kilometer_Grid\", GEOGCS[\"GCS_Sphere_EMEP\", DATUM[\"D_Sphere_EMEP\", SPHEROID[\"Sphere_EMEP\", 6370000.0, 0.0]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"Degree\", 0.0174532925199433]], PROJECTION[\"Stereographic_North_Pole\"], PARAMETER[\"False_Easting\", 3.0], PARAMETER[\"False_Northing\", 37.0], PARAMETER[\"Central_Meridian\", -32.0], PARAMETER[\"Standard_Parallel_1\", 60.0], UNIT[\"150_Kilometers\", 150000.0]]");
            EMEP50KilometerGrid = new ProjectionInfo();
            EMEP50KilometerGrid.ParseEsriString("PROJCS[\"EMEP_50_Kilometer_Grid\", GEOGCS[\"GCS_Sphere_EMEP\", DATUM[\"D_Sphere_EMEP\", SPHEROID[\"Sphere_EMEP\", 6370000.0, 0.0]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"Degree\", 0.0174532925199433]], PROJECTION[\"Stereographic_North_Pole\"], PARAMETER[\"False_Easting\", 8.0], PARAMETER[\"False_Northing\", 110.0], PARAMETER[\"Central_Meridian\", -32.0], PARAMETER[\"Standard_Parallel_1\", 60.0], UNIT[\"50_Kilometers\", 50000.0]]");
            ETRS1989LAEA = ProjectionInfo.FromProj4String("+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs ");
            ETRS1989LCC  = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=35 +lat_2=65 +lat_0=52 +lon_0=10 +x_0=4000000 +y_0=2800000 +ellps=GRS80 +units=m +no_defs ");
            EuropeAlbersEqualAreaConic  = ProjectionInfo.FromProj4String("+proj=aea +lat_1=43 +lat_2=62 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs ");
            EuropeEquidistantConic      = ProjectionInfo.FromProj4String("+proj=eqdc +lat_0=0 +lon_0=0 +lat_1=43 +lat_2=62 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs ");
            EuropeLambertConformalConic = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=43 +lat_2=62 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs ");

            EMEP50KilometerGrid.Name         = "EMEP_50_Kilometer_Grid";
            ETRS1989LAEA.Name                = "ETRS_1989_LAEA";
            ETRS1989LCC.Name                 = "ETRS_1989_LCC";
            EuropeAlbersEqualAreaConic.Name  = "Europe_Albers_Equal_Area_Conic";
            EuropeEquidistantConic.Name      = "Europe_Equidistant_Conic";
            EuropeLambertConformalConic.Name = "Europe_Lambert_Conformal_Conic";

            EMEP150KilometerGrid.GeographicInfo.Name        = "GCS_Sphere_EMEP";
            EMEP50KilometerGrid.GeographicInfo.Name         = "GCS_Sphere_EMEP";
            ETRS1989LAEA.GeographicInfo.Name                = "GCS_ETRS_1989";
            ETRS1989LCC.GeographicInfo.Name                 = "GCS_ETRS_1989";
            EuropeAlbersEqualAreaConic.GeographicInfo.Name  = "GCS_European_1950";
            EuropeEquidistantConic.GeographicInfo.Name      = "GCS_European_1950";
            EuropeLambertConformalConic.GeographicInfo.Name = "GCS_European_1950";

            EMEP150KilometerGrid.GeographicInfo.Datum.Name        = "D_Sphere_EMEP";
            EMEP50KilometerGrid.GeographicInfo.Datum.Name         = "D_Sphere_EMEP";
            ETRS1989LAEA.GeographicInfo.Datum.Name                = "D_ETRS_1989";
            ETRS1989LCC.GeographicInfo.Datum.Name                 = "D_ETRS_1989";
            EuropeAlbersEqualAreaConic.GeographicInfo.Datum.Name  = "D_European_1950";
            EuropeEquidistantConic.GeographicInfo.Datum.Name      = "D_European_1950";
            EuropeLambertConformalConic.GeographicInfo.Datum.Name = "D_European_1950";
        }
        private static FeatureSet NameSearchCity(string name, FeatureType type, SearchRegion region, out long searchTime)
        {
            if (TheRoot.AllStatesByAbbr.TryGetValue(region.Abbr, out State state))
            {
                var projection = ProjectionInfo.FromProj4String(SRID_WGS84);
                projection.Transform = new Transform();
                var featureSet = new FeatureSet(type)
                {
                    Name       = name,
                    Projection = projection,
                };
                var watch = new Stopwatch();
                watch.Start();

                var result = state.AllCitiesByName.Select(item => item.Geom).ToList();

                watch.Stop();
                searchTime = watch.ElapsedMilliseconds;

                PopulateFeatureSet(result, featureSet);
                return(featureSet);
            }

            searchTime = 0;
            return(null);
        }
        private static ProjectionInfo CreateProjectionInfo(ISpatialReference spatialReference)
        {
            var pisr = spatialReference as DotSpatialSpatialReference;

            if (pisr != null && pisr.ProjectionInfo != null)
            {
                return(pisr.ProjectionInfo);
            }

            switch (spatialReference.DefinitionType)
            {
            case SpatialReferenceDefinitionType.Proj4:
                return(ProjectionInfo.FromProj4String(spatialReference.Definition));

            case SpatialReferenceDefinitionType.AuthorityCode:
                var ac   = spatialReference.Definition.Split(new [] { ':' });
                var srid = int.Parse(ac[1]);
                return(ProjectionInfo.FromEpsgCode(srid));

            case SpatialReferenceDefinitionType.WellKnownText:
                return(ProjectionInfo.FromEsriString(spatialReference.Definition));

            default:
                throw new NotSupportedException();
            }
        }
        private static FeatureSet SpatialSearchOtherSpatialLayers(string layerName, SearchRegion region, MultiDimensionalObjectRelationship relationship, out long searchTime)
        {
            var layer = TheRoot.OtherSpatialLayers[layerName];

            if (layer != null)
            {
                var projection = ProjectionInfo.FromProj4String(SRID_None);
                projection.Transform = new Transform();
                var featureSet = new FeatureSet(FeatureType.Unspecified)
                {
                    Name       = layerName,
                    Projection = projection
                };

                var watch = new Stopwatch();
                watch.Start();

                var result = region == null?layer.Geometries.Cast <JoobGeometry>().ToList()
                                 : layer.Geometries.Search(region.Envelope, relationship).Select(item => item.Key);

                watch.Stop();
                searchTime = watch.ElapsedMilliseconds;

                PopulateFeatureSet(result, featureSet);
                return(featureSet);
            }

            searchTime = 0;
            return(null);
        }
        private static FeatureSet NameSearchState(string name, FeatureType type, SearchRegion region, out long searchTime)
        {
            var watch = new Stopwatch();

            watch.Start();

            if (TheRoot.AllStatesByAbbr.TryGetValue(region.Abbr, out State result))
            {
                watch.Stop();
                searchTime = watch.ElapsedMilliseconds;
                var projection = ProjectionInfo.FromProj4String(SRID_WGS84);
                projection.Transform = new Transform();
                var featureSet = new FeatureSet(type)
                {
                    Name       = name,
                    Projection = projection,
                };
                PopulateFeatureSet(new[] { result.Geom }, featureSet);
                return(featureSet);
            }

            watch.Stop();
            searchTime = 0;
            return(null);
        }
        private static FeatureSet SpatialSearch <TMdo, TVal>(JoobRTree <TMdo, TVal> rtree, string name, FeatureType type, SearchRegion region, MultiDimensionalObjectRelationship relationship, out long searchTime)
            where TMdo : JoobObject, IMultiDimensionalObject
            where TVal : JoobObject
        {
            if (rtree.Count > 0)
            {
                var projection = ProjectionInfo.FromProj4String(SRID_WGS84);
                projection.Transform = new Transform();
                var featureSet = new FeatureSet(type)
                {
                    Name       = name,
                    Projection = projection
                };

                var watch = new Stopwatch();
                watch.Start();

                var result = region == null
                    ? rtree.Where(item => item as ObjectWithSpatialInfo != null).Cast <ObjectWithSpatialInfo>().Select(item => item.Geom).ToList()
                    : rtree.Search(region.Envelope as TMdo, relationship).Select(item => item.Key as JoobGeometry).ToList();

                watch.Stop();
                searchTime = watch.ElapsedMilliseconds;

                PopulateFeatureSet(result, featureSet);
                return(featureSet);
            }

            searchTime = 0;
            return(null);
        }
        public Geometry ReprojectGeometry(Geometry geometry, string sourceEpsgCode, string targetEpsgCode)
        {
            var sourceProjection = ProjectionInfo.FromProj4String(sourceEpsgCode);
            var targetProjection = ProjectionInfo.FromProj4String(targetEpsgCode);

            return(ReprojectGeometry(geometry, sourceProjection, targetProjection));
        }
        /// <summary>
        /// Function to get the ProjectionInfo
        /// </summary>
        public override ProjectionInfo GetProjection()
        {
            using (NpgsqlConnection connection = new NpgsqlConnection(ConnectionString))
            {
                connection.Open();
                var commandBuilder = new System.Text.StringBuilder();
                commandBuilder.Append("SELECT \"proj4text\" AS a FROM \"spatial_ref_sys\" as a " +
                                      "INNER JOIN \"geometry_columns\" as b ON a.\"srid\"= b.\"srid\" " +
                                      "WHERE ");
                if (!string.IsNullOrEmpty(TableSpace))
                {
                    commandBuilder.AppendFormat("b.\"f_table_catalog\"={0} AND ", string.Format(DecorateLiterals, TableSpace));
                }
                if (!string.IsNullOrEmpty(Schema))
                {
                    commandBuilder.AppendFormat("b.\"f_table_schema\"={0} AND ", string.Format(DecorateLiterals, Schema));
                }
                commandBuilder.AppendFormat("b.\"f_table_name\"={0} AND b.\"f_geometry_column\"={1};",
                                            string.Format(DecorateLiterals, Table),
                                            string.Format(DecorateLiterals, GeometryColumn));

                using (NpgsqlCommand cmd = new NpgsqlCommand(commandBuilder.ToString(), connection))
                {
                    string proj4 = (string)cmd.ExecuteScalar();
                    return(ProjectionInfo.FromProj4String(proj4));
                }
            }
        }
Exemple #13
0
        private void ReadHeader()
        {
            DataType         = typeof(T);
            NumColumnsInFile = _dataset.RasterXSize;
            NumColumns       = NumColumnsInFile;
            NumRowsInFile    = _dataset.RasterYSize;
            NumRows          = NumRowsInFile;

            // Todo: look for prj file if GetProjection returns null.
            // Do we need to read this as an Esri string if we don't get a proj4 string?
            string projString = _dataset.GetProjection();

            Projection = ProjectionInfo.FromProj4String(projString);
            if (_band != null)
            {
                double val;
                int    hasInterval;
                _band.GetNoDataValue(out val, out hasInterval);
                base.NoDataValue = val;
            }

            double[] affine = new double[6];
            _dataset.GetGeoTransform(affine);

            // in gdal (row,col) coordinates are defined relative to the top-left corner of the top-left cell
            // shift them by half a cell to give coordinates relative to the center of the top-left cell
            affine           = new AffineTransform(affine).TransfromToCorner(0.5, 0.5);
            ProjectionString = projString;
            Bounds           = new RasterBounds(NumRows, NumColumns, affine);
            PixelSpace       = Marshal.SizeOf(typeof(T));
        }
Exemple #14
0
        private void Add(string authorityCode, string name, string proj4String, bool replace)
        {
            var pos = authorityCode.IndexOf(':');

            if (pos == -1)
            {
                throw new ArgumentOutOfRangeException("authorityCode", "Invalid authorityCode");
            }

            if (!replace && _authorityCodeToProjectionInfo.ContainsKey(authorityCode))
            {
                throw new ArgumentOutOfRangeException("authorityCode", "Such projection already added.");
            }
            var pi = ProjectionInfo.FromProj4String(proj4String);

            pi.Authority     = authorityCode.Substring(0, pos);
            pi.AuthorityCode = int.Parse(authorityCode.Substring(pos + 1));
            pi.EpsgCode      = int.Parse(authorityCode.Substring(pos + 1));
            pi.Name          = String.IsNullOrEmpty(name) ? authorityCode : name;

            _authorityCodeToProjectionInfo[authorityCode] = pi;

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (!replace && _authorityNameToProjectionInfo.ContainsKey(name))
            {
                throw new ArgumentOutOfRangeException("name", "Such projection already added.");
            }
            _authorityNameToProjectionInfo[name] = pi;
        }
Exemple #15
0
    public UTM(int zone, Hemisphere hemisphere)
    {
        double centralMeridian = zone * 6.0 - 183;
        double falseNorthing   = hemisphere == Hemisphere.North ? 0 : 10000000;
        string proj4Format     = "+proj=tmerc +lon_0={0} +lat_0=0 +k=0.9996 +x_0=500000 +y_0={1} +ellps=GRS80 +datum=NAD83 +to_meter=1 +no_defs";

        Projection = ProjectionInfo.FromProj4String(String.Format(proj4Format, centralMeridian, falseNorthing));
    }
Exemple #16
0
        //public static void Load(string directoryName)
        //{
        //    var coords = Web.EpsgWebService.LoadLocal(directoryName);
        //    _cache = coords.ToDictionary(x => x.Code, x => x);
        //}

        static CRSUtil()
        {
            _cache = new Dictionary <int, ProjectionInfo>();
            _cache.Add(2096, ProjectionInfo.FromProj4String(_2096));
            _cache.Add(4326, ProjectionInfo.FromProj4String(_4326));
            _cache.Add(3857, ProjectionInfo.FromProj4String(_3857));
            _cache.Add(5181, ProjectionInfo.FromProj4String(_5181));
        }
        public void ToProj4StringTestDoesReadMatchToString()
        {
            string proj4String = "+proj=longlat +ellps=WGS84 +no_defs ";

            ProjectionInfo target = ProjectionInfo.FromProj4String(proj4String);

            Assert.AreEqual(proj4String.Trim(), target.ToProj4String().Trim());
        }
        public void ProjectionInfoConstructorTest2()
        {
            string         proj4String = null;
            ProjectionInfo actual      = ProjectionInfo.FromProj4String(proj4String);
            ProjectionInfo expected    = new ProjectionInfo();

            Assert.AreEqual(expected.ToProj4String(), actual.ToProj4String());
        }
        public void ProjectionInfoConstructorTest()
        {
            var proj4String = string.Empty;
            var actual      = ProjectionInfo.FromProj4String(proj4String);
            var expected    = new ProjectionInfo();

            Assert.AreEqual(expected.ToProj4String(), actual.ToProj4String());
        }
Exemple #20
0
        /// <summary>
        /// Creates a new instance of NorthAmerica
        /// </summary>
        public NorthAmerica()
        {
            AlaskanIslands          = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            AmericanSamoa1962       = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            Ammassalik1958          = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            ATS1977                 = ProjectionInfo.FromProj4String("+proj=longlat +a=6378135 +b=6356750.304921594 +no_defs ");
            Barbados                = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk80 +no_defs ");
            Bermuda1957             = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            Bermuda2000             = ProjectionInfo.FromProj4String("+proj=longlat +ellps=WGS84 +no_defs ");
            CapeCanaveral           = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            Guam1963                = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            Helle1954               = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            Jamaica1875             = ProjectionInfo.FromProj4String("+proj=longlat +a=6378249.138 +b=6356514.959419348 +no_defs ");
            Jamaica1969             = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            NAD1927CGQ77            = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            NAD1927Definition1976   = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            NADMichigan             = ProjectionInfo.FromProj4String("+proj=longlat +a=6378450.047 +b=6356826.620025999 +no_defs ");
            NorthAmerican1983CSRS98 = ProjectionInfo.FromProj4String("+proj=longlat +ellps=GRS80 +no_defs ");
            NorthAmerican1983HARN   = ProjectionInfo.FromProj4String("+proj=longlat +ellps=GRS80 +no_defs ");
            NorthAmericanDatum1927  = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs ");
            NorthAmericanDatum1983  = ProjectionInfo.FromProj4String("+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs ");
            OldHawaiian             = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            PuertoRico              = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            Qornoq           = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            Qornoq1927       = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            Scoresbysund1952 = ProjectionInfo.FromProj4String("+proj=longlat +ellps=intl +no_defs ");
            StGeorgeIsland   = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            StLawrenceIsland = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");
            StPaulIsland     = ProjectionInfo.FromProj4String("+proj=longlat +ellps=clrk66 +no_defs ");

            AlaskanIslands.GeographicInfo.Name          = "GCS_Alaskan_Islands";
            AmericanSamoa1962.GeographicInfo.Name       = "GCS_American_Samoa_1962";
            Ammassalik1958.GeographicInfo.Name          = "GCS_Ammassalik_1958";
            ATS1977.GeographicInfo.Name                 = "GCS_ATS_1977";
            Barbados.GeographicInfo.Name                = "GCS_Barbados";
            Bermuda1957.GeographicInfo.Name             = "GCS_Bermuda_1957";
            Bermuda2000.GeographicInfo.Name             = "GCS_Bermuda_2000";
            CapeCanaveral.GeographicInfo.Name           = "GCS_Cape_Canaveral";
            Helle1954.GeographicInfo.Name               = "GCS_Helle_1954";
            Guam1963.GeographicInfo.Name                = "GCS_Guam_1963";
            Jamaica1875.GeographicInfo.Name             = "GCS_Jamaica_1875";
            Jamaica1969.GeographicInfo.Name             = "GCS_Jamaica_1969";
            NAD1927CGQ77.GeographicInfo.Name            = "GCS_NAD_1927_CGQ77";
            NAD1927Definition1976.GeographicInfo.Name   = "GCS_NAD_1927_Definition_1976";
            NADMichigan.GeographicInfo.Name             = "GCS_North_American_Michigan";
            NorthAmerican1983CSRS98.GeographicInfo.Name = "GCS_North_American_1983_CSRS98";
            NorthAmerican1983HARN.GeographicInfo.Name   = "GCS_North_American_1983_HARN";
            NorthAmericanDatum1927.GeographicInfo.Name  = "GCS_North_American_1927";
            NorthAmericanDatum1983.GeographicInfo.Name  = "GCS_North_American_1983";
            OldHawaiian.GeographicInfo.Name             = "GCS_Old_Hawaiian";
            PuertoRico.GeographicInfo.Name              = "GCS_Puerto_Rico";
            Qornoq.GeographicInfo.Name           = String.Empty;
            Qornoq1927.GeographicInfo.Name       = "GCS_Qornoq_1927";
            Scoresbysund1952.GeographicInfo.Name = "GCS_Scoresbysund_1952";
            StGeorgeIsland.GeographicInfo.Name   = "GCS_St_George_Island";
            StLawrenceIsland.GeographicInfo.Name = "GCS_St_Lawrence_Island";
            StPaulIsland.GeographicInfo.Name     = "GCS_St_Paul_Island";
        }
Exemple #21
0
        public ProjectionInfo GetProj4ProjectionInfo()
        {
            string sProj4String;

            SpatialReference osrSpatialref = _ogrLayer.GetSpatialRef();

            osrSpatialref.ExportToProj4(out sProj4String);
            return(ProjectionInfo.FromProj4String(sProj4String));
        }
        public void Geoc_Proj4ExportImport(bool expected)
        {
            var target = ProjectionInfo.FromProj4String(KnownCoordinateSystems.Geographic.World.WGS1984.ToProj4String());

            target.Geoc = expected;
            var proj4str = target.ToProj4String();
            var actual   = ProjectionInfo.FromProj4String(proj4str);

            Assert.AreEqual(target.Geoc, actual.Geoc);
        }
 private static bool TryParseProjectionProj4(string proj4, out ProjectionInfo projectionInfo)
 {
     try{
         projectionInfo = ProjectionInfo.FromProj4String(proj4);
     }
     catch {
         projectionInfo = null;
     }
     return(projectionInfo != null);
 }
Exemple #24
0
 static CRSUtil()
 {
     _cache = new Dictionary <int, ProjectionInfo>
     {
         { 2096, ProjectionInfo.FromProj4String(_2096) },
         { 4326, ProjectionInfo.FromProj4String(_4326) },
         { 3857, ProjectionInfo.FromProj4String(_3857) },
         { 5181, ProjectionInfo.FromProj4String(_5181) }
     };
 }
Exemple #25
0
        public void LAEA_Reprojection_NoNANs()
        {
            var source = ProjectionInfo.FromProj4String("proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
            // Any LAEA projection
            var dest = ProjectionInfo.FromProj4String("+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +datum=WGS84");

            double[] vertices = { 13.5, 51.3 };
            Reproject.ReprojectPoints(vertices, null, source, dest, 0, 1);

            Assert.IsTrue(!double.IsNaN(vertices[0]));
            Assert.IsTrue(!double.IsNaN(vertices[1]));
        }
        private void Add(string authorityCode, string name, string proj4String, bool replace)
        {
            var pos = authorityCode.IndexOf(':');

            if (pos == -1)
            {
                throw new ArgumentOutOfRangeException("authorityCode", "Invalid authorityCode");
            }

            if (!replace && _authorityCodeToProjectionInfo.ContainsKey(authorityCode))
            {
                throw new ArgumentOutOfRangeException("authorityCode", "Such projection already added.");
            }
            ProjectionInfo pi;

            try
            {
                pi = ProjectionInfo.FromProj4String(proj4String);

                // Removed exception being thrown when projection is not found
                if (pi.Transform == null)
                {
                    return;
                }
            }
            catch (ProjectionException)
            {
                // todo: geocent not supported yet by DS
                if (proj4String.Contains("+proj=geocent"))
                {
                    return;
                }
                throw;
            }

            pi.Authority     = authorityCode.Substring(0, pos);
            pi.AuthorityCode = int.Parse(authorityCode.Substring(pos + 1), CultureInfo.InvariantCulture);
            pi.Name          = string.IsNullOrEmpty(name) ? authorityCode : name;

            _authorityCodeToProjectionInfo[authorityCode] = pi;

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            if (!replace && _authorityNameToProjectionInfo.ContainsKey(name))
            {
                throw new ArgumentOutOfRangeException("name", "Such projection already added.");
            }
            _authorityNameToProjectionInfo[name] = pi;
        }
        public void ProjectionInfoConstructorTest1()
        {
            string         proj4String = "+proj=longlat +ellps=WGS84 +no_defs ";
            ProjectionInfo expected    = ProjectionInfo.FromProj4String(proj4String);

            ProjectionInfo actual = new ProjectionInfo();

            actual.GeographicInfo.Datum.Spheroid = new Spheroid("WGS84");
            actual.NoDefs   = true;
            actual.IsLatLon = true;

            Assert.AreEqual(expected.ToProj4String(), actual.ToProj4String());
        }
        private void Add(string authorityCode, string name, string proj4String, bool replace)
        {
            if (replace && _authorityCodeToProjectionInfo.ContainsKey(authorityCode))
                _authorityCodeToProjectionInfo.Remove(authorityCode);
            _authorityCodeToProjectionInfo.Add(authorityCode, ProjectionInfo.FromProj4String(proj4String));

            if (string.IsNullOrEmpty(name))
                return;

            if (replace && _authorityNameToProjectionInfo.ContainsKey(name))
                _authorityNameToProjectionInfo.Remove(name);
            _authorityNameToProjectionInfo.Add(name, ProjectionInfo.FromProj4String(proj4String));
        }
        /// <summary>
        /// Common part of constructors
        /// </summary>
        /// <param name="geo">LatLon structure with geographic coordinates</param>
        /// <param name="r3d">origin point of Rail3D layout</param>
        /// <param name="UTMfuse">zone for UTM conversions</param>
        private void setValues(LatLon geo, XY r3d, int UTMfuse)
        {
            this.GeoCenter = geo;
            this.R3Dcenter = r3d;
            this.UTMfuse   = UTMfuse;

            this.pOrigin = KnownCoordinateSystems.Geographic.World.WGS1984;
            this.pTarget = ProjectionInfo.FromProj4String(
                string.Format("+proj=utm +zone={0} {1} +ellps=WGS84 +datum=WGS84 +units=m +no_defs ",
                              UTMfuse, geo.Lat < 0 ? "+south" : ""));

            this.UTMcenter = ToUTM(geo);
        }
Exemple #30
0
        /// <summary>
        /// Creates a new instance of NorthAmerica
        /// </summary>
        public NorthAmerica()
        {
            AlaskaAlbersEqualAreaConic            = ProjectionInfo.FromProj4String("+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            CanadaAlbersEqualAreaConic            = ProjectionInfo.FromProj4String("+proj=aea +lat_1=50 +lat_2=70 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            CanadaLambertConformalConic           = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=50 +lat_2=70 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            HawaiiAlbersEqualAreaConic            = ProjectionInfo.FromProj4String("+proj=aea +lat_1=8 +lat_2=18 +lat_0=13 +lon_0=-157 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            NorthAmericaAlbersEqualAreaConic      = ProjectionInfo.FromProj4String("+proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            NorthAmericaEquidistantConic          = ProjectionInfo.FromProj4String("+proj=eqdc +lat_0=0 +lon_0=0 +lat_1=20 +lat_2=60 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            NorthAmericaLambertConformalConic     = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            USAContiguousAlbersEqualAreaConic     = ProjectionInfo.FromProj4String("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            USAContiguousAlbersEqualAreaConicUSGS = ProjectionInfo.FromProj4String("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            USAContiguousEquidistantConic         = ProjectionInfo.FromProj4String("+proj=eqdc +lat_0=0 +lon_0=0 +lat_1=33 +lat_2=45 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");
            USAContiguousLambertConformalConic    = ProjectionInfo.FromProj4String("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=39 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ");

            AlaskaAlbersEqualAreaConic.Name            = "Alaska_Albers_Equal_Area_Conic";
            CanadaAlbersEqualAreaConic.Name            = "Canada_Albers_Equal_Area_Conic";
            CanadaLambertConformalConic.Name           = "Canada_Lambert_Conformal_Conic";
            HawaiiAlbersEqualAreaConic.Name            = "Hawaii_Albers_Equal_Area_Conic";
            NorthAmericaAlbersEqualAreaConic.Name      = "North_America_Albers_Equal_Area_Conic";
            NorthAmericaEquidistantConic.Name          = "North_America_Equidistant_Conic";
            NorthAmericaLambertConformalConic.Name     = "North_America_Lambert_Conformal_Conic";
            USAContiguousAlbersEqualAreaConic.Name     = "USA_Contiguous_Albers_Equal_Area_Conic";
            USAContiguousAlbersEqualAreaConicUSGS.Name = "USA_Contiguous_Albers_Equal_Area_Conic_USGS_version";
            USAContiguousEquidistantConic.Name         = "USA_Contiguous_Equidistant_Conic";
            USAContiguousLambertConformalConic.Name    = "USA_Contiguous_Lambert_Conformal_Conic";

            AlaskaAlbersEqualAreaConic.GeographicInfo.Name            = "GCS_North_American_1983";
            CanadaAlbersEqualAreaConic.GeographicInfo.Name            = "GCS_North_American_1983";
            CanadaLambertConformalConic.GeographicInfo.Name           = "GCS_North_American_1983";
            HawaiiAlbersEqualAreaConic.GeographicInfo.Name            = "GCS_North_American_1983";
            NorthAmericaAlbersEqualAreaConic.GeographicInfo.Name      = "GCS_North_American_1983";
            NorthAmericaEquidistantConic.GeographicInfo.Name          = "GCS_North_American_1983";
            NorthAmericaLambertConformalConic.GeographicInfo.Name     = "GCS_North_American_1983";
            USAContiguousAlbersEqualAreaConic.GeographicInfo.Name     = "GCS_North_American_1983";
            USAContiguousAlbersEqualAreaConicUSGS.GeographicInfo.Name = "GCS_North_American_1983";
            USAContiguousEquidistantConic.GeographicInfo.Name         = "GCS_North_American_1983";
            USAContiguousLambertConformalConic.GeographicInfo.Name    = "GCS_North_American_1983";

            AlaskaAlbersEqualAreaConic.GeographicInfo.Datum.Name            = "D_North_American_1983";
            CanadaAlbersEqualAreaConic.GeographicInfo.Datum.Name            = "D_North_American_1983";
            CanadaLambertConformalConic.GeographicInfo.Datum.Name           = "D_North_American_1983";
            HawaiiAlbersEqualAreaConic.GeographicInfo.Datum.Name            = "D_North_American_1983";
            NorthAmericaAlbersEqualAreaConic.GeographicInfo.Datum.Name      = "D_North_American_1983";
            NorthAmericaEquidistantConic.GeographicInfo.Datum.Name          = "D_North_American_1983";
            NorthAmericaLambertConformalConic.GeographicInfo.Datum.Name     = "D_North_American_1983";
            USAContiguousAlbersEqualAreaConic.GeographicInfo.Datum.Name     = "D_North_American_1983";
            USAContiguousAlbersEqualAreaConicUSGS.GeographicInfo.Datum.Name = "D_North_American_1983";
            USAContiguousEquidistantConic.GeographicInfo.Datum.Name         = "D_North_American_1983";
            USAContiguousLambertConformalConic.GeographicInfo.Datum.Name    = "D_North_American_1983";
        }