Example #1
0
        /// <summary>
        /// 根据指定坐标系代码创建坐标系
        /// </summary>
        /// <param name="factoryCode">坐标系代码</param>
        /// <param name="type">创建的坐标系类别</param>
        /// <returns></returns>
        public static ISpatialReference CreateSpatialRef(int factoryCode, ESrType type = ESrType.Projected)
        {
            if (type == ESrType.Geographic)
            {
                return(new SpatialReferenceEnvironmentClass().CreateGeographicCoordinateSystem(factoryCode));
            }
            if (type == ESrType.Projected)
            {
                return(new SpatialReferenceEnvironmentClass().CreateProjectedCoordinateSystem(factoryCode));
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// 创建与指定要素坐标系相同的坐标系
        /// </summary>
        /// <param name="feature">要素</param>
        /// <param name="type">创建的坐标系类别</param>
        /// <returns></returns>
        public static ISpatialReference CreateSpatialRef(this IFeature feature, ESrType type = ESrType.Projected)
        {
            int factoryCode = feature.Shape.SpatialReference.FactoryCode;

            return(CreateSpatialRef(factoryCode, type));
        }
Example #3
0
        /// <summary>
        /// 创建与指定要素类坐标系相同的坐标系
        /// </summary>
        /// <param name="featureClass">要素类</param>
        /// <param name="type">创建的坐标系类别</param>
        /// <returns></returns>
        public static ISpatialReference CreateSpatialRef(this IFeatureClass featureClass, ESrType type = ESrType.Projected)
        {
            IField souceGeoField = featureClass.Fields.get_Field(featureClass.FindField(featureClass.ShapeFieldName));
            int    factoryCode   = souceGeoField.GeometryDef.SpatialReference.FactoryCode;

            //Console.WriteLine(factoryCode);
            //Console.WriteLine(featureClass.AliasName);
            //Console.WriteLine(YYGISLib.ArcGisHelper.Data.CoordinateSystem.GetCoordinateDetail(featureClass));
            //Console.WriteLine(YYGISLib.ArcGisHelper.FeatureHelper.FeatureClassOpt.GetSourcePath(featureClass));

            return(CreateSpatialRef(factoryCode, type));
        }