CreateFromWkt() публичный Метод

Creates a spatial reference object given its Well-known text representation. The output object may be either a IGeographicCoordinateSystem or a IProjectedCoordinateSystem.
public CreateFromWkt ( string WKT ) : ICoordinateSystem
WKT string The Well-known text representation for the spatial reference
Результат ICoordinateSystem
        private static ICoordinateSystem GetCoordinateSystemForSrid(int srid)
        {
            if (srid <= 0)
            {
                return(null);
            }

            ICoordinateSystem res = null;

#if !DotSpatialProjections
            if (_sridCoordinateSystem.TryGetValue(srid, out res))
            {
                return(res);
            }

            var wkt = Converters.WellKnownText.SpatialReference.SridToWkt(srid);
            if (string.IsNullOrEmpty(wkt))
            {
                Logger.Error(fmh => fmh("No definition for SRID {0}!", srid));
                return(null);
            }

            var csFactory = new CoordinateSystemFactory();
            try
            {
                res = csFactory.CreateFromWkt(wkt);
            }
            catch (Exception)
            {
                Logger.Error(fmh => fmh("Could not parse definition for SRID {0}:\n{1}", srid, wkt));
                return(null);
            }
            _sridCoordinateSystem.Add(srid, res);
#else
            try
            {
                if (_sridDefinition != null)
                {
                    string proj4;
                    if (_sridDefinition.TryGetValue(srid, out proj4))
                    {
                        res = ICoordinateSystem.FromProj4String(proj4);
                    }
                }

                if (res == null)
                {
                    res = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(srid);
                }
            }
            catch (Exception)
            {
                Logger.Error(fmh => fmh("Could not get coordinate system for SRID {0}!", srid));
                return(null);
            }
#endif
            return(res);
        }
 /// <summary>
 /// Method to create a coordinate system based on the <paramref name="wellKnownText"/> coordinate system definition.
 /// </summary>
 /// <param name="wellKnownText"></param>
 /// <returns>A coordinate system, <value>null</value> if no coordinate system could be created.</returns>
 public CoordinateSystem CreateCoordinateSystem(string wellKnownText)
 {
     try
     {
         return(_coordinateSystemFactory.CreateFromWkt(wellKnownText.Replace("ELLIPSOID", "SPHEROID")));
     }
     catch (Exception)
     {
         // as a fallback we ignore projections not supported
         return(null);
     }
 }
Пример #3
0
        // gets transform between raster's native projection and the map projection
        private void GetTransform(CoordinateSystems.ICoordinateSystem mapProjection)
        {
            if (mapProjection == null || _projection == "")
            {
                _transform = null;
                return;
            }

            CoordinateSystemFactory cFac = new CoordinateSystemFactory();

            // get our two projections
            ICoordinateSystem srcCoord = cFac.CreateFromWkt(_projection);
            ICoordinateSystem tgtCoord = mapProjection;

            // raster and map are in same projection, no need to transform
            if (srcCoord.WKT == tgtCoord.WKT)
            {
                _transform = null;
                return;
            }

            // create transform
            _transform = new CoordinateTransformationFactory().CreateFromCoordinateSystems(srcCoord, tgtCoord);
        }
Пример #4
0
        // get raster projection
        public ICoordinateSystem GetProjection()
        {
            CoordinateSystemFactory cFac = new CoordinateSystemFactory();

            try
            {
                if (_projection != "")
                    return cFac.CreateFromWkt(_projection);
            }
            catch { }

            return null;
        }