コード例 #1
0
 /// <summary>Creates the coordinate system from the specified WKT representation.</summary>
 /// <param name="text">The WKT representation of the coordinate system to create.</param>
 /// <param name="id">The identifier of the coordinate system to get.</param>
 /// <returns>The coordinate system.</returns>
 public ICoordinateSystem CreateFromWkt(string text, Srid id)
 {
     var ret=new CoordinateSystem(DsProjections.ProjectionInfo.FromEsriString(text));
     // DotSpatial does not fill this field automatically
     ret.Projection.AuthorityCode=id.Value;
     return ret;
 }
コード例 #2
0
        /// <summary>Gets the coordinate system with the specified <paramref name="id" />.</summary>
        /// <param name="id">The identifier of the coordinate system to get.</param>
        /// <returns>The coordinate system with the specified <paramref name="id" />.</returns>
        public CoordinateSystem GetById(Srid id)
        {
            // WGS84 by default
            if (id.Value==0)
                return Wgs84;

            CoordinateSystem ret=null;

            var args=new CreatingCoordinateSystemEventArgs(id);
            OnCreatingCoordinateSystem(args);

            if (args.CoordinateSystem!=null)
                ret=(CoordinateSystem)args.CoordinateSystem;
            else if (!string.IsNullOrEmpty(args.WellKnownText))
                ret=new CoordinateSystem(DsProjections.ProjectionInfo.FromEsriString(args.WellKnownText));

            if (ret!=null)
            {
                // DotSpatial does not fill this field automatically
                if (ret.Projection.AuthorityCode==0)
                    ret.Projection.AuthorityCode=id.Value;
                OnCreatedCoordinateSystem(new CreatedCoordinateSystemEventArgs(id, ret));
                return ret;
            }

            throw new InvalidOperationException(
                string.Format(
                    CultureInfo.CurrentCulture,
                    SR.CouldNotFindCoordinateSystemDefinitionException,
                    id.Value
                )
            );
        }