SharpMap.CoordinateSystems.CoordinateSystemFactory.CreateFromWkt C# (CSharp) 메소드

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
        public ICoordinateSystem CreateFromWkt(string WKT)
        {
            return SharpMap.Converters.WellKnownText.CoordinateSystemWktReader.Parse(WKT) as ICoordinateSystem;
        }

Usage Example

        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);
        }
All Usage Examples Of SharpMap.CoordinateSystems.CoordinateSystemFactory::CreateFromWkt