コード例 #1
0
ファイル: frmCoorTrans.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// 实现对要素类的坐标的仿射变换
        /// </summary>
        /// <param name="inFC">要素类</param>
        /// <param name="inTransformation">转换类</param>
        private void coordTransfermation(IFeatureClass inFC, ITransformation inTransformation)
        {
            IFeatureCursor pFCursor = inFC.Update(null, false);
            IFeature       pFeature = pFCursor.NextFeature();

            while (pFeature != null)
            {
                IGeometry    shpTransformed = pFeature.ShapeCopy;
                ITransform2D pTransform2D   = shpTransformed as ITransform2D;
                pTransform2D.Transform(esriTransformDirection.esriTransformForward, inTransformation);
                pFeature.Shape = shpTransformed;
                //int id = inFC.FindField("LAYER_OID");
                //if((inFC as IDataset).Name=="宗地_Project54_1")
                //pFeature.set_Value(id,"1");

                pFCursor.UpdateFeature(pFeature);
                //cursor后移
                pFeature = pFCursor.NextFeature();
            }
            Marshal.ReleaseComObject(pFCursor);//释放cursor
            ISpatialReference     unKnownSR = new UnknownCoordinateSystemClass();
            IGeoDatasetSchemaEdit pGDSE     = inFC as IGeoDatasetSchemaEdit;

            if (pGDSE.CanAlterSpatialReference)
            {
                pGDSE.AlterSpatialReference(unKnownSR);//更新要素类的投影
            }
            IFeatureClassManage pFCM = inFC as IFeatureClassManage;

            pFCM.UpdateExtent();//更新要素类的最值范围
            IGeoDataset pGD = inFC as IGeoDataset;
            IEnvelope   ppp = pGD.Extent;
        }
コード例 #2
0
ファイル: helpers.cs プロジェクト: BGCX261/ziggis-svn-to-git
        static public ISpatialReference setEsriSpatiaReferenceFromSrid(int srid)
        {
            //there is not always a perfect corrispondence between PostGIS srid and Esri Factory code: so we have to catch the possible error in CreateSpatialReference, and in that case set it to Unknow (it won't be possible to project layers, but at least it will be displayed)
            ISpatialReference sr;

            try
            {
                //Paolo : set Spatial Reference
                ISpatialReferenceFactory2 srf = new SpatialReferenceEnvironmentClass();
                if (srid == -1)
                {
                    sr = new UnknownCoordinateSystemClass();
                }
                else
                {
                    sr = srf.CreateSpatialReference(srid);
                }
                return(sr);
            }
            catch
            {
                //PostGis srid is not implemented as an Esri Factory Code
                sr = new UnknownCoordinateSystemClass();
                return(sr);
            }
        }
コード例 #3
0
ファイル: SpatialRefOpt.cs プロジェクト: jonhzy163/WLib
        /// <summary>
        /// 创建空坐标系
        /// </summary>
        /// <returns></returns>
        public static ISpatialReference CreateUnKnownSpatialRef()
        {
            ISpatialReference spatialReference = new UnknownCoordinateSystemClass();

            spatialReference.SetDomain(0, 99999999, 0, 99999999);//设置空间范围
            return(spatialReference);
        }
コード例 #4
0
ファイル: DefaultDataImport.cs プロジェクト: zj8487/HyDM
        /// <summary>
        /// 创建Dataset
        /// </summary>
        /// <param name="wsTarget"></param>
        /// <param name="pSpatialRef"></param>
        /// <returns></returns>
        protected virtual IFeatureDataset CreateFeatureDataset(IWorkspace wsTarget, ISpatialReference pSpatialRef)
        {
            if (wsTarget == null)
            {
                return(null);
            }
            try
            {
                if (pSpatialRef == null)
                {
                    pSpatialRef = new UnknownCoordinateSystemClass();

                    ISpatialReferenceTolerance pSpatialTolerance = pSpatialRef as ISpatialReferenceTolerance;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance  = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = pSpatialRef as ISpatialReferenceResolution;

                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;
                }

                return(((IFeatureWorkspace)wsTarget).CreateFeatureDataset(COMMONCONST.Dataset_Name, pSpatialRef));
            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, string.Format("创建Dataset时出错,信息:{0}", ex.Message));

                return(null);
            }
        }
コード例 #5
0
ファイル: FrmCreateRasterDB.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// 创建栅格字段
        /// </summary>
        /// <param name="pRasterFielsName">栅格字段名</param>
        /// <param name="pSpatialRes">栅格空间参考</param>
        /// <param name="eError"></param>
        /// <returns>返回字段</returns>
        private IField2 CreateRasterField(string pRasterFielsName, ISpatialReference pSpatialRes, bool isManaged)
        {
            IField2     pField     = new FieldClass();
            IFieldEdit2 pFieldEdit = pField as IFieldEdit2;

            pFieldEdit.Name_2      = pRasterFielsName;
            pFieldEdit.AliasName_2 = pRasterFielsName;
            pFieldEdit.Type_2      = esriFieldType.esriFieldTypeRaster;

            IRasterDef pRasterDef = new RasterDefClass();

            pRasterDef.Description = "this is Raster catalog";
            if (pSpatialRes == null)
            {
                //如果空间参考为空,则设置为UnknownCoordinateSystemClass
                pSpatialRes = new UnknownCoordinateSystemClass();
            }
            //only for PGDB
            pRasterDef.IsManaged        = isManaged;
            pRasterDef.SpatialReference = pSpatialRes;
            pFieldEdit.RasterDef        = pRasterDef;
            pField = pFieldEdit as IField2;

            return(pField);
        }
コード例 #6
0
ファイル: helpers.cs プロジェクト: BGCX261/ziggis-svn-to-git
        static public ISpatialReference setEsriSpatiaReferenceFromSrText(int srid, Connection conn)
        {
            ISpatialReference sr     = new UnknownCoordinateSystemClass();
            string            srText = "";
            int i = 0;

            try
            {
                //Bill: query srtext associated with srid
                AutoDataReader dr = conn.doQuery("select * from spatial_ref_sys where srid = " + srid.ToString());
                if (dr.Read())
                {
                    srText = dr["srtext"] + "";
                    ISpatialReferenceFactory2 srf = new SpatialReferenceEnvironmentClass();
                    if (srText == "")
                    {
                        sr = new UnknownCoordinateSystemClass();
                    }
                    else
                    {
                        //use srText to construct SR.
                        srf.CreateESRISpatialReference(srText, out sr, out i);
                    }
                }
                return(sr);
            }
            catch
            {
                //PostGis srid is not implemented as an Esri Factory Code
                sr = new UnknownCoordinateSystemClass();
                return(sr);
            }
        }
コード例 #7
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            ISpatialReference SpaReference = new UnknownCoordinateSystemClass();

            pSpaReference          = SpaReference;
            richTextReference.Text = ClsGDBDataCommon.GetReferenceString(SpaReference);
        }
コード例 #8
0
ファイル: FeatureClassUtil.cs プロジェクト: zhongshuiyuan/dme
        /// <summary>
        /// 复制空间参考系
        /// </summary>
        /// <param name="pSrcSpatialReference"></param>
        /// <returns>返回参考系</returns>
        private ISpatialReference CloneSpatialReference(ISpatialReference pSrcSpatialReference)
        {
            pSrcSpatialReference.GetDomain(out double xmin, out double xmax, out double ymin, out double ymax);
            ISpatialReference pSR = new UnknownCoordinateSystemClass();

            pSR.SetDomain(xmin, xmax, ymin, ymax);
            return(pSR);
        }
コード例 #9
0
        public static IFields GetFields(IFeatureClass featureClass)
        {
            IFields     pNewFields     = new FieldsClass();
            IFields     pFields        = featureClass.Fields;
            IFieldsEdit pNewFieldsEdit = pNewFields as IFieldsEdit;
            int         fieldCount     = pFields.FieldCount;

            for (int i = 0; i < fieldCount; i++)
            {
                IField pField = pFields.Field[i];
                if (pField.Name == "OBJECTID_1" || pField.Name == "OBJECTID")
                {
                    continue;
                }
                if (pField.Editable == false)
                {
                    continue;
                }
                IField     pNewField     = new FieldClass();
                IFieldEdit pNewFieldEdit = pNewField as IFieldEdit;
                pNewFieldEdit.Name_2      = pField.Name;
                pNewFieldEdit.AliasName_2 = pField.AliasName;

                if (pField.Type == esriFieldType.esriFieldTypeGeometry)
                {
                    pNewFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
                    IGeometryDef     pGeometryDef     = new GeometryDefClass();
                    IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
                    pGeometryDefEdit.GeometryType_2 = pField.GeometryDef.GeometryType;
                    if (pField.GeometryDef.SpatialReference.Name == "Unknown")
                    {
                        ISpatialReference pSpatialReference = new UnknownCoordinateSystemClass();
                        pSpatialReference.SetDomain(-1000000, 1000000, -1000000, 1000000);
                        pSpatialReference.SetZDomain(0, 0);
                        pSpatialReference.SetMDomain(0, 0);
                        pGeometryDefEdit.SpatialReference_2 = pSpatialReference;
                    }
                    else
                    {
                        pGeometryDefEdit.SpatialReference_2 = pField.GeometryDef.SpatialReference;
                    }
                    pNewFieldEdit.GeometryDef_2 = pGeometryDefEdit;
                }
                else
                {
                    pNewFieldEdit.DefaultValue_2 = pField.DefaultValue;
                    pNewFieldEdit.DomainFixed_2  = pField.DomainFixed;
                    pNewFieldEdit.Domain_2       = pField.Domain;
                    pNewFieldEdit.Precision_2    = pField.Precision;
                    pNewFieldEdit.Required_2     = pField.Required;
                    pNewFieldEdit.Scale_2        = pField.Scale;
                    pNewFieldEdit.Type_2         = pField.Type;
                }
                pNewFieldsEdit.AddField(pNewField);
            }
            return(pNewFieldsEdit);
        }
コード例 #10
0
ファイル: frmTYDataUpload.cs プロジェクト: siszoey/geosufan
        /// <summary>
        ///  创建要素集 20110919 xisheng
        /// </summary>
        /// <param name="feaworkspace">指定工作空间</param>
        /// <param name="datasetname">指定要素集名称</param>
        /// <param name="PrjPath">空间参考</param>
        /// <returns></returns>
        private static IFeatureDataset CreateFeatureDataset(IFeatureWorkspace feaworkspace, string datasetname, string PrjPath)
        {
            try
            {
                string spatialPath = PrjPath;
                ISpatialReferenceFactory pSpaReferenceFac  = new SpatialReferenceEnvironmentClass(); //空间参考工厂
                ISpatialReference        pSpatialReference = null;                                   //用来获得空间参考
                if (File.Exists(spatialPath))
                {
                    pSpatialReference = pSpaReferenceFac.CreateESRISpatialReferenceFromPRJFile(spatialPath);
                }
                if (pSpatialReference == null)
                {
                    pSpatialReference = new UnknownCoordinateSystemClass();
                }

                //设置默认的Resolution
                ISpatialReferenceResolution pSpatiaprefRes = pSpatialReference as ISpatialReferenceResolution;
                pSpatiaprefRes.ConstructFromHorizon();//Defines the XY resolution and domain extent of this spatial reference based on the extent of its horizon
                pSpatiaprefRes.SetDefaultXYResolution();
                pSpatiaprefRes.SetDefaultZResolution();
                pSpatiaprefRes.SetDefaultMResolution();
                //设置默认的Tolerence
                ISpatialReferenceTolerance pSpatialrefTole = pSpatiaprefRes as ISpatialReferenceTolerance;
                pSpatialrefTole.SetDefaultXYTolerance();
                pSpatialrefTole.SetDefaultZTolerance();
                pSpatialrefTole.SetDefaultMTolerance();

                //创建数据集

                IFeatureDataset pFeatureDataset = null;//定义数据集用来装载要素类
                pFeatureDataset = feaworkspace.CreateFeatureDataset(datasetname, pSpatialReference);


                return(pFeatureDataset);
            }
            catch (Exception e)
            {
                //*******************************************************************
                //guozheng added
                if (ModData.SysLog != null)
                {
                    ModData.SysLog.Write(e, null, DateTime.Now);
                }
                else
                {
                    ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                    ModData.SysLog.Write(e, null, DateTime.Now);
                }
                //********************************************************************
                return(null);
            }
        }
コード例 #11
0
ファイル: FrmCreateRasterDB.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// 设置空间参考定义
        /// </summary>
        /// <param name="pSR"></param>
        /// <returns></returns>
        private IRasterDef CreateRasterDef(ISpatialReference pSR)
        {
            IRasterDef pRasterDef = new RasterDefClass();

            pRasterDef.Description = "rasterDataset";
            if (pSR == null)
            {
                pSR = new UnknownCoordinateSystemClass();
            }
            pRasterDef.SpatialReference = pSR;
            return(pRasterDef);
        }
コード例 #12
0
ファイル: FeatClsOperAPI.cs プロジェクト: zj8487/HyDM
        /// <summary>
        /// 根据某一图层的范围,创建mdb文件中的featuredataset及其空间范围
        /// </summary>
        /// <param name="motherWs">要创建featuredataset的工作空间</param>
        /// <param name="pGeoDataset">featuredataset所要依据的空间参考和空间范围</param>
        /// 这个函数要改!!
        public static void CreateDatasetInWs(IWorkspace motherWs, IGeoDataset pGeoDataset, string datasetName)
        {
            try
            {
                ISpatialReference pSpatialRef = null;
                IFeatureDataset   pFtDs       = null;


                if (pGeoDataset != null)
                {
                    pSpatialRef = pGeoDataset.SpatialReference;

                    IControlPrecision2 controlPrecision2 = pSpatialRef as IControlPrecision2;
                    if (!controlPrecision2.IsHighPrecision)
                    {
                        controlPrecision2.IsHighPrecision = true;
                    }

                    IEnvelope pEnv = pGeoDataset.Extent;
                    pEnv.Expand(1.5, 1.5, true);
                    pSpatialRef.SetDomain(pEnv.XMin, pEnv.XMax, pEnv.YMin, pEnv.YMax);

                    ISpatialReferenceTolerance pSpatialTolerance = (ISpatialReferenceTolerance)pSpatialRef;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance  = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = (ISpatialReferenceResolution)pSpatialRef;
                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;

                    pFtDs = ((IFeatureWorkspace)motherWs).CreateFeatureDataset(datasetName, pSpatialRef);
                }
                else
                {
                    pSpatialRef = new UnknownCoordinateSystemClass();

                    ISpatialReferenceTolerance pSpatialTolerance = (ISpatialReferenceTolerance)pSpatialRef;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance  = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = (ISpatialReferenceResolution)pSpatialRef;
                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;

                    pFtDs = ((IFeatureWorkspace)motherWs).CreateFeatureDataset(datasetName, pSpatialRef);
                }
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
            }
        }
コード例 #13
0
        private ISpatialReference method_0(bool bool_5)
        {
            ISpatialReference  reference = new UnknownCoordinateSystemClass();
            IControlPrecision2 precision = reference as IControlPrecision2;

            precision.IsHighPrecision = bool_5;
            ISpatialReferenceResolution resolution = reference as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (reference as ISpatialReferenceTolerance).SetDefaultXYTolerance();
            return(reference);
        }
コード例 #14
0
ファイル: LoadRasterToSDE.cs プロジェクト: chinasio/minegis
        //������ţ�RasterCreate-05
        //������:	createRasterDef
        //�������ܣ�����raster����
        //������
        public IRasterDef createRasterDef(bool isManaged, ISpatialReference spatialReference)
        {
            // Create rasterdef
            IRasterDef rasterDef = new RasterDefClass();

            rasterDef.Description = "Raster Dataset";
            if (spatialReference == null)
                spatialReference = new UnknownCoordinateSystemClass();

            rasterDef.SpatialReference = spatialReference;
            rasterDef.IsManaged = isManaged;

            return rasterDef;
        }
コード例 #15
0
ファイル: SpatialReferenceHelper.cs プロジェクト: zj8487/HyDM
        public static string ToPrjString(ISpatialReference spatialRef)
        {
            if (spatialRef == null)
            {
                spatialRef = new UnknownCoordinateSystemClass();
            }

            int    strCount  = -1;
            string prjString = null;

            (spatialRef as IESRISpatialReferenceGEN).ExportToESRISpatialReference(out prjString, out strCount);

            return(prjString);
        }
コード例 #16
0
        private ISpatialReference method_0(bool bool_1)
        {
            new SpatialReferenceEnvironmentClass();
            ISpatialReference   reference = new UnknownCoordinateSystemClass();
            IGeodatabaseRelease release   = this.ifeatureWorkspace_0 as IGeodatabaseRelease;
            IControlPrecision2  precision = reference as IControlPrecision2;

            bool_1 = GeodatabaseTools.GetGeoDatasetPrecision(release);
            precision.IsHighPrecision = bool_1;
            ISpatialReferenceResolution resolution = reference as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (reference as ISpatialReferenceTolerance).SetDefaultXYTolerance();
            return(reference);
        }
コード例 #17
0
        //函数编号:RasterCreate-05
        //函数名:	createRasterDef
        //函数功能:设置raster定义
        //参数:
        public IRasterDef createRasterDef(bool isManaged, ISpatialReference spatialReference)
        {
            // Create rasterdef
            IRasterDef rasterDef = new RasterDefClass();

            rasterDef.Description = "Raster Dataset";
            if (spatialReference == null)
            {
                spatialReference = new UnknownCoordinateSystemClass();
            }

            rasterDef.SpatialReference = spatialReference;
            rasterDef.IsManaged        = isManaged;

            return(rasterDef);
        }
コード例 #18
0
        private IFields CloneFeatureClassFields(IFeatureClass pFeatureClass, IEnvelope pDomainEnv)
        {
            IFields     pFields     = new FieldsClass();
            IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;
            //根据传入的要素类,将除了shape字段之外的字段复制
            long nOldFieldsCount = pFeatureClass.Fields.FieldCount;
            long nOldGeoIndex    = pFeatureClass.Fields.FindField(pFeatureClass.ShapeFieldName);

            for (int i = 0; i < nOldFieldsCount; i++)
            {
                if (i != nOldGeoIndex)
                {
                    pFieldsEdit.AddField(pFeatureClass.Fields.get_Field(i));
                }
                else
                {
                    IGeometryDef      pGeomDef     = new GeometryDefClass();
                    IGeometryDefEdit  pGeomDefEdit = (IGeometryDefEdit)pGeomDef;
                    ISpatialReference pSR          = null;
                    if (pDomainEnv != null)
                    {
                        pSR = new UnknownCoordinateSystemClass();
                        pSR.SetDomain(pDomainEnv.XMin, pDomainEnv.XMax, pDomainEnv.YMin, pDomainEnv.YMax);
                    }
                    else
                    {
                        IGeoDataset pGeoDataset = pFeatureClass as IGeoDataset;
                        pSR = CloneSpatialReference(pGeoDataset.SpatialReference);
                    }
                    //设置新要素类Geometry的参数
                    pGeomDefEdit.GeometryType_2 = pFeatureClass.ShapeType;
                    pGeomDefEdit.GridCount_2    = 1;
                    pGeomDefEdit.set_GridSize(0, 10);
                    pGeomDefEdit.AvgNumPoints_2     = 2;
                    pGeomDefEdit.SpatialReference_2 = pSR;
                    //产生新的shape字段
                    IField     pField     = new FieldClass();
                    IFieldEdit pFieldEdit = (IFieldEdit)pField;
                    pFieldEdit.Name_2        = "shape";
                    pFieldEdit.AliasName_2   = "shape";
                    pFieldEdit.Type_2        = esriFieldType.esriFieldTypeGeometry;
                    pFieldEdit.GeometryDef_2 = pGeomDef;
                    pFieldsEdit.AddField(pField);
                }
            }
            return(pFields);
        }
コード例 #19
0
ファイル: GDBData.cs プロジェクト: VB6Hobbyst7/minegis
        public void CreateFeaInSDE(string name)
        {
            IFields     pFields     = new FieldsClass();
            IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
            IField      pField      = new FieldClass();
            IFieldEdit  pFieldEdit;

            pField            = new FieldClass();
            pFieldEdit        = pField as IFieldEdit;
            pFieldEdit.Name_2 = "OBJECTID";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
            pFieldsEdit.AddField(pField);

            pField            = new FieldClass();
            pFieldEdit        = pField as IFieldEdit;
            pFieldEdit.Name_2 = "SHAPE";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            IGeometryDef     pGeometryDef     = new GeometryDefClass();
            IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;

            pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
            ISpatialReference spatialRef = new UnknownCoordinateSystemClass();

            spatialRef.SetDomain(21151314, 21416785, 3497200, 3895222);
            //spatialRef.SetFalseOriginAndUnits(0, 0, 100000);
            pGeometryDefEdit.SpatialReference_2 = spatialRef;
            pFieldEdit.GeometryDef_2            = pGeometryDef;
            pFieldsEdit.AddField(pField);

            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "PlanID", "围填方案号");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "V_Change_Rate", "水道全潮平均流速最大变化率");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "V_Area", "流速变化范围");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Change_Rate", "相邻水道流量变化率");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Silting_Strength", "水道淤积强度");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Ecological_Service_Lost", "生态服务价值损失");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Sewage_Discharge", "污水排放量");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Cultivation_Area", "影像养殖区面积");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Distance", "缩短岸线与深水区的距离");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "V_Variation", "缩短岸线与深水区的距离");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Land_Area", "围填海后形成的陆域面积");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Benifit", "围填海的效益");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Economic_Output", "围填区的经济产出");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Increased_Imployment", "围填区可增加的就业人口");

            ((IFeatureWorkspace)m_workSpace).CreateFeatureClass(name, pFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
        }
コード例 #20
0
        private IRaster createRasterWithoutData(Point2D ptLeftTop, double dbResolution, int[] nSize, string pRasterFile)
        {
            IRaster pRaster = null;

            try
            {
                if (File.Exists(pRasterFile))
                {
                    File.Delete(pRasterFile);
                }

                string            Path     = System.IO.Path.GetDirectoryName(pRasterFile);
                string            FileName = System.IO.Path.GetFileName(pRasterFile);
                IRasterWorkspace2 rasterWs = OpenRasterWorkspace(Path);
                //Define the spatial reference of the raster dataset.
                ISpatialReference sr = new UnknownCoordinateSystemClass();
                //Define the origin for the raster dataset, which is the lower left corner of the raster.
                IPoint origin = new PointClass();
                origin.PutCoords(ptLeftTop.X, ptLeftTop.Y);
                //Define the dimensions of the raster dataset.
                int    width   = nSize[0];     //This is the width of the raster dataset.
                int    height  = nSize[1];     //This is the height of the raster dataset.
                double xCell   = dbResolution; //This is the cell size in x direction.
                double yCell   = dbResolution; //This is the cell size in y direction.
                int    NumBand = 1;            // This is the number of bands the raster dataset contains.
                //Create a raster dataset in TIFF format.
                IRasterDataset rasterDataset = rasterWs.CreateRasterDataset(FileName, "TIFF",
                                                                            origin, width, height, xCell, yCell, NumBand, rstPixelType.PT_UCHAR, sr,
                                                                            true);

                //Set NoData if necessary. For a multiband image, a NoData value needs to be set for each band.
                //rasterProps.NoDataValue = -9999;
                //Create a raster from the dataset.
                pRaster = rasterDataset.CreateDefaultRaster();

                return(pRaster);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error: " + ex.Message);
                return(null);
            }

            return(pRaster);
        }
コード例 #21
0
ファイル: FrmCreateRasterDB.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// 设置几何空间参考定义
        /// </summary>
        /// <param name="pSpatialRes"></param>
        /// <returns></returns>
        private IGeometryDef CreateGeoDef(ISpatialReference pSpatialRes)
        {
            IGeometryDef     pGeoDef     = new GeometryDefClass();
            IGeometryDefEdit pGeoDefEdit = pGeoDef as IGeometryDefEdit;

            pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            pGeoDefEdit.AvgNumPoints_2 = 4;
            pGeoDefEdit.GridCount_2    = 1;
            pGeoDefEdit.set_GridSize(0, 1000);

            if (pSpatialRes == null)
            {
                pSpatialRes = new UnknownCoordinateSystemClass();
            }
            pGeoDefEdit.SpatialReference_2 = pSpatialRes;
            pGeoDef = pGeoDefEdit as IGeometryDef;
            return(pGeoDef);
        }
コード例 #22
0
ファイル: ProjectClass.cs プロジェクト: lzhm216/coordtrans
        public void Run()
        {
            IWorkspaceFactory shapefileworkspaceF = new ShapefileWorkspaceFactoryClass();

            IWorkspace workspace = shapefileworkspaceF.OpenFromFile(workspaceName, 0);

            IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;

            IFeatureClass pFeatureClass = featureWorkspace.OpenFeatureClass(shapefileName) as IFeatureClass;

            ISpatialReference pSpatialref = new UnknownCoordinateSystemClass();

            for (int i = 0; i < pFeatureClass.FeatureCount(null); i++)
            {
                IFeature pFeature = (IFeature)pFeatureClass.GetFeature(i);
                pFeature.Shape.SpatialReference = pSpatialref;
                pFeature.Store();
            }
        }
コード例 #23
0
        private void btnSelectCoordinate_Click(object sender, EventArgs e)
        {
            ISpatialReference tag = this.btnSelectCoordinate.Tag as ISpatialReference;

            if (tag == null)
            {
                tag = new UnknownCoordinateSystemClass();
            }
            frmSpatialReference reference2 = new frmSpatialReference
            {
                SpatialRefrence = tag
            };

            if (reference2.ShowDialog() == DialogResult.OK)
            {
                this.btnSelectCoordinate.Tag  = tag;
                this.btnSelectCoordinate.Text = tag.Name;
            }
        }
コード例 #24
0
ファイル: frmImportxy.cs プロジェクト: secondii/Yutai
        private IFeatureClass method_2(IDataset idataset_1, string string_2)
        {
            IFields     fields = new FieldsClass();
            IFieldsEdit edit   = (IFieldsEdit)fields;

            for (int i = 0; i < this.arrayList_0.Count; i++)
            {
                edit.AddField(this.arrayList_0[i] as IField);
            }
            IGeometryDef     def   = new GeometryDefClass();
            IGeometryDefEdit edit2 = (IGeometryDefEdit)def;

            edit2.GeometryType_2 = esriGeometryType.esriGeometryPoint;
            edit2.GridCount_2    = 1;
            edit2.set_GridSize(0, 200.0);
            edit2.AvgNumPoints_2 = 1;
            edit2.HasM_2         = false;
            edit2.HasZ_2         = false;
            ISpatialReference           reference  = new UnknownCoordinateSystemClass();
            ISpatialReferenceResolution resolution = reference as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (reference as ISpatialReferenceTolerance).SetDefaultXYTolerance();
            edit2.SpatialReference_2 = reference;
            IField     field = new FieldClass();
            IFieldEdit edit3 = (IFieldEdit)field;

            edit3.Name_2      = "OBJECTID";
            edit3.AliasName_2 = "OBJECTID";
            edit3.Type_2      = esriFieldType.esriFieldTypeOID;
            edit.AddField(field);
            IField     field2 = new FieldClass();
            IFieldEdit edit4  = (IFieldEdit)field2;

            edit4.Name_2        = "SHAPE";
            edit4.AliasName_2   = "SHAPE";
            edit4.Type_2        = esriFieldType.esriFieldTypeGeometry;
            edit4.GeometryDef_2 = def;
            edit.AddField(field2);
            return(this.CreateFeatureClass(idataset_1, string_2, new UnknownCoordinateSystemClass(),
                                           esriFeatureType.esriFTSimple, esriGeometryType.esriGeometryPoint, fields, null, null, null));
        }
コード例 #25
0
ファイル: LoadRasterToSDE.cs プロジェクト: chinasio/minegis
        //������ţ�RasterCreate-04
        //��������createGeometryDef
        //���ܣ��������ζ���
        //������spatialReference���ռ�ο�
        //
        public IGeometryDef createGeometryDef(ISpatialReference spatialReference)
        {
            // Create GeometryDef
            IGeometryDefEdit geometryDefEdit = new GeometryDefClass();

            geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            geometryDefEdit.AvgNumPoints_2 = 4;
            //���ÿռ������IJ���
            geometryDefEdit.GridCount_2 = 1;
            geometryDefEdit.set_GridSize(0, 1000);

            // Set unknown spatial reference is not set
            if (spatialReference == null)
                spatialReference = new UnknownCoordinateSystemClass();

            //���ÿռ�ο�
            geometryDefEdit.SpatialReference_2 = spatialReference;

            return (IGeometryDef)geometryDefEdit;
        }
コード例 #26
0
ファイル: GeometryFun.cs プロジェクト: 605258778/GISData
 public ISpatialReference CreateSpatialReferenceUCS(string sSRString)
 {
     try
     {
         if (string.IsNullOrEmpty(sSRString))
         {
             return(null);
         }
         IESRISpatialReference reference = null;
         reference = new UnknownCoordinateSystemClass();
         int cBytesRead = 0;
         reference.ImportFromESRISpatialReference(sSRString, out cBytesRead);
         return(reference as ISpatialReference);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.GeometryFun", "CreateSpatialReferenceUCS", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
コード例 #27
0
        private IProjectedCoordinateSystem GetProjectedCoordinateSystem()
        {
            //以下结果均不加带号
            //if(北京54and三度带)2397+带号   4
            //if(北京54and六度带)21400+带号
            //if(西安80and三度带)2345+带号  4
            //if(西安80and六度带)2325+带号  4
            //创建投影坐标系
            try
            {
                SpatialReferenceEnvironment spatialReferenceEnvironment = new SpatialReferenceEnvironment();
                IProjectedCoordinateSystem  projectedCoordinateSystem   = new UnknownCoordinateSystemClass() as IProjectedCoordinateSystem;

                if (cbbCoordinateSystem.Text == "北京54坐标系" && cbbfendai.Text == "三度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(2397 + Convert.ToInt32(cbbnumber.Text));
                }
                else if (cbbCoordinateSystem.Text == "北京54坐标系" && cbbfendai.Text == "六度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(21400 + Convert.ToInt32(cbbnumber.Text));
                }
                else if (cbbCoordinateSystem.Text == "西安80坐标系" && cbbfendai.Text == "三度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(2345 + Convert.ToInt32(cbbnumber.Text));
                }
                else if (cbbCoordinateSystem.Text == "西安80坐标系" && cbbfendai.Text == "六度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(2325 + Convert.ToInt32(cbbnumber.Text));
                }

                return(projectedCoordinateSystem);
            }
            catch (Exception ex)
            {
                string exception = ex.Message;
                MessageBox.Show(exception);
                return(null);
            }
        }
コード例 #28
0
        //函数编号:RasterCreate-04
        //函数名:createGeometryDef
        //功能:创建几何定义
        //参数:spatialReference:空间参考
        //
        public IGeometryDef createGeometryDef(ISpatialReference spatialReference)
        {
            // Create GeometryDef
            IGeometryDefEdit geometryDefEdit = new GeometryDefClass();

            geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            geometryDefEdit.AvgNumPoints_2 = 4;
            //设置空间索引的层数
            geometryDefEdit.GridCount_2 = 1;
            geometryDefEdit.set_GridSize(0, 1000);

            // Set unknown spatial reference is not set
            if (spatialReference == null)
            {
                spatialReference = new UnknownCoordinateSystemClass();
            }

            //设置空间参考
            geometryDefEdit.SpatialReference_2 = spatialReference;

            return((IGeometryDef)geometryDefEdit);
        }
コード例 #29
0
ファイル: GDBInput.cs プロジェクト: xmter/learning_summary
        /// <summary>
        /// 创建栅格数据集
        /// </summary>
        /// <param name="pGDBType"></param>
        /// <param name="pPath"></param>
        /// <param name="pFileName"></param>
        /// <param name="pWidth"></param>
        /// <param name="pHeight"></param>
        /// <param name="pXCell"></param>
        /// <param name="pYCell"></param>
        /// <param name="pNumBand"></param>
        /// <returns></returns>
        public IRasterDataset CreateRasterDataset(GDBType pGDBType, string pPath, string pFileName, int pWidth, int pHeight, double pXCell, double pYCell, int pNumBand)
        {
            try
            {
                IRasterWorkspace2 pRWs = GetWorkspace(pPath, pGDBType) as IRasterWorkspace2;

                ISpatialReference sr = new UnknownCoordinateSystemClass();

                IPoint origin = new PointClass();
                origin.PutCoords(0.0, 0.0);
                IRasterDataset rasterDataset = pRWs.CreateRasterDataset(pFileName, "TIFF",
                                                                        origin, pWidth, pHeight, pXCell, pYCell, pNumBand, rstPixelType.PT_UCHAR, sr,
                                                                        true);


                return(rasterDataset);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #30
0
        public static IField createShapeField(ISpatialReference spatRef, esriGeometryType geometryType)
        {
            try
            {
                IField     pShpField     = new FieldClass();
                IFieldEdit pShpFieldEdit = (IFieldEdit)pShpField;
                pShpFieldEdit.Name_2      = "Shape";
                pShpFieldEdit.AliasName_2 = "Shape";
                pShpFieldEdit.Type_2      = esriFieldType.esriFieldTypeGeometry;

                if (spatRef == null)
                {
                    spatRef = new UnknownCoordinateSystemClass();
                    spatRef.SetDomain(-10000, 10000, -10000, 10000);
                }
                pShpFieldEdit.GeometryDef_2 = createGeoDef(spatRef, geometryType);
                return(pShpField);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "ASA_ThreddsCatalog:clsNC2Arc:CreateNC_Raster");
                return(null);
            }
        }
コード例 #31
0
        // From ArcObjects Help: How to Create a Raster dataset
        // http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/How_to_create_a_raster_dataset/000100000464000000/
        public static IRasterDataset CreateRasterDataset(string Path, string FileName)
        {
            try
            {
                IRasterWorkspace2 rasterWs = OpenRasterWorkspace(Path); // This is a custom method that's at the bottom of this code.
                //Define the spatial reference of the raster dataset.
                ISpatialReference sr = new UnknownCoordinateSystemClass();
                //Define the origin for the raster dataset, which is the lower left corner of the raster.
                IPoint origin = new PointClass();
                origin.PutCoords(15.0, 15.0);
                //Define the dimensions of the raster dataset.
                int    width   = 100; //This is the width of the raster dataset.
                int    height  = 100; //This is the height of the raster dataset.
                double xCell   = 30;  //This is the cell size in x direction.
                double yCell   = 30;  //This is the cell size in y direction.
                int    NumBand = 1;   // This is the number of bands the raster dataset contains.
                //Create a raster dataset in TIFF format.
                IRasterDataset rasterDataset = rasterWs.CreateRasterDataset(FileName, "TIFF",
                                                                            origin, width, height, xCell, yCell, NumBand, rstPixelType.PT_UCHAR, sr,
                                                                            true);

                //If you need to set NoData for some of the pixels, you need to set it on band
                //to get the raster band.
                IRasterBandCollection rasterBands = (IRasterBandCollection)rasterDataset;
                IRasterBand           rasterBand;
                IRasterProps          rasterProps;
                rasterBand  = rasterBands.Item(0);
                rasterProps = (IRasterProps)rasterBand;
                //Set NoData if necessary. For a multiband image, a NoData value needs to be set for each band.
                rasterProps.NoDataValue = 255;
                //Create a raster from the dataset.
                IRaster raster = ((IRasterDataset2)rasterDataset).CreateFullRaster();

                //Create a pixel block using the weight and height of the raster dataset.
                //If the raster dataset is large, a smaller pixel block should be used.
                //Refer to the topic "How to access pixel data using a raster cursor".
                IPnt blocksize = new PntClass();
                blocksize.SetCoords(width, height);
                IPixelBlock3 pixelblock = raster.CreatePixelBlock(blocksize) as IPixelBlock3;

                //Populate some pixel values to the pixel block.
                System.Array pixels;
                pixels = (System.Array)pixelblock.get_PixelData(0);
                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        if (i == j)
                        {
                            pixels.SetValue(Convert.ToByte(255), i, j);
                        }
                        else
                        {
                            pixels.SetValue(Convert.ToByte((i * j) / 255), i, j);
                        }
                    }
                }

                pixelblock.set_PixelData(0, (System.Array)pixels);

                //Define the location that the upper left corner of the pixel block is to write.
                IPnt upperLeft = new PntClass();
                upperLeft.SetCoords(0, 0);

                //Write the pixel block.
                IRasterEdit rasterEdit = (IRasterEdit)raster;
                rasterEdit.Write(upperLeft, (IPixelBlock)pixelblock);

                //Release rasterEdit explicitly.
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rasterEdit);

                return(rasterDataset);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #32
0
ファイル: helpers.cs プロジェクト: BGCX261/ziggis-svn-to-git
 public static ISpatialReference setEsriSpatiaReferenceFromSrText(int srid, Connection conn)
 {
     ISpatialReference sr = new UnknownCoordinateSystemClass();
     string srText = "";
     int i = 0;
     try
     {
         //Bill: query srtext associated with srid
         AutoDataReader dr = conn.doQuery("select * from spatial_ref_sys where srid = " + srid.ToString());
         if (dr.Read())
         {
             srText = dr["srtext"] + "";
             ISpatialReferenceFactory2 srf = new SpatialReferenceEnvironmentClass();
             if (srText == "")
             {
                 sr = new UnknownCoordinateSystemClass();
             }
             else
             {
                 //use srText to construct SR.
                 srf.CreateESRISpatialReference(srText, out sr, out i);
             }
         }
         return sr;
     }
     catch
     {
         //PostGis srid is not implemented as an Esri Factory Code
         sr = new UnknownCoordinateSystemClass();
         return sr;
     }
 }
コード例 #33
0
ファイル: helpers.cs プロジェクト: BGCX261/ziggis-svn-to-git
 public static ISpatialReference setEsriSpatiaReferenceFromSrid(int srid)
 {
     //there is not always a perfect corrispondence between PostGIS srid and Esri Factory code: so we have to catch the possible error in CreateSpatialReference, and in that case set it to Unknow (it won't be possible to project layers, but at least it will be displayed)
     ISpatialReference sr;
     try
     {
         //Paolo : set Spatial Reference
         ISpatialReferenceFactory2 srf = new SpatialReferenceEnvironmentClass();
         if (srid == -1)
         {
             sr = new UnknownCoordinateSystemClass();
         }
         else
         {
             sr = srf.CreateSpatialReference(srid);
         }
         return sr;
     }
     catch
     {
         //PostGis srid is not implemented as an Esri Factory Code
         sr = new UnknownCoordinateSystemClass();
         return sr;
     }
 }
コード例 #34
0
        // From ArcObjects Help: How to Create a Raster dataset
        // http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/How_to_create_a_raster_dataset/000100000464000000/
        public static IRasterDataset CreateRasterDataset(string Path, string FileName)
        {
            try
            {
                IRasterWorkspace2 rasterWs = OpenRasterWorkspace(Path); // This is a custom method that's at the bottom of this code.
                //Define the spatial reference of the raster dataset.
                ISpatialReference sr = new UnknownCoordinateSystemClass();
                //Define the origin for the raster dataset, which is the lower left corner of the raster.
                IPoint origin = new PointClass();
                origin.PutCoords(15.0, 15.0);
                //Define the dimensions of the raster dataset.
                int width = 100; //This is the width of the raster dataset.
                int height = 100; //This is the height of the raster dataset.
                double xCell = 30; //This is the cell size in x direction.
                double yCell = 30; //This is the cell size in y direction.
                int NumBand = 1; // This is the number of bands the raster dataset contains.
                //Create a raster dataset in TIFF format.
                IRasterDataset rasterDataset = rasterWs.CreateRasterDataset(FileName, "TIFF",
                    origin, width, height, xCell, yCell, NumBand, rstPixelType.PT_UCHAR, sr,
                    true);

                //If you need to set NoData for some of the pixels, you need to set it on band 
                //to get the raster band.
                IRasterBandCollection rasterBands = (IRasterBandCollection)rasterDataset;
                IRasterBand rasterBand;
                IRasterProps rasterProps;
                rasterBand = rasterBands.Item(0);
                rasterProps = (IRasterProps)rasterBand;
                //Set NoData if necessary. For a multiband image, a NoData value needs to be set for each band.
                rasterProps.NoDataValue = 255;
                //Create a raster from the dataset.
                IRaster raster = ((IRasterDataset2)rasterDataset).CreateFullRaster();

                //Create a pixel block using the weight and height of the raster dataset. 
                //If the raster dataset is large, a smaller pixel block should be used. 
                //Refer to the topic "How to access pixel data using a raster cursor".
                IPnt blocksize = new PntClass();
                blocksize.SetCoords(width, height);
                IPixelBlock3 pixelblock = raster.CreatePixelBlock(blocksize) as IPixelBlock3;

                //Populate some pixel values to the pixel block.
                System.Array pixels;
                pixels = (System.Array)pixelblock.get_PixelData(0);
                for (int i = 0; i < width; i++)
                    for (int j = 0; j < height; j++)
                        if (i == j)
                            pixels.SetValue(Convert.ToByte(255), i, j);
                        else
                            pixels.SetValue(Convert.ToByte((i * j) / 255), i, j);

                pixelblock.set_PixelData(0, (System.Array)pixels);

                //Define the location that the upper left corner of the pixel block is to write.
                IPnt upperLeft = new PntClass();
                upperLeft.SetCoords(0, 0);

                //Write the pixel block.
                IRasterEdit rasterEdit = (IRasterEdit)raster;
                rasterEdit.Write(upperLeft, (IPixelBlock)pixelblock);

                //Release rasterEdit explicitly.
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rasterEdit);

                return rasterDataset;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return null;
            }
        }
コード例 #35
0
ファイル: GDBData.cs プロジェクト: chinasio/minegis
        public void CreateFeaInSDE(string name)
        {
            IFields pFields = new FieldsClass();
            IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
            IField pField = new FieldClass();
            IFieldEdit pFieldEdit ;

            pField = new FieldClass();
            pFieldEdit=pField as IFieldEdit;
            pFieldEdit.Name_2 = "OBJECTID";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
            pFieldsEdit.AddField(pField);

            pField = new FieldClass();
            pFieldEdit=pField as IFieldEdit;
            pFieldEdit.Name_2 = "SHAPE";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            IGeometryDef pGeometryDef = new GeometryDefClass();
            IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;
            pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
            ISpatialReference spatialRef = new UnknownCoordinateSystemClass();
            spatialRef.SetDomain(21151314, 21416785, 3497200, 3895222);
            //spatialRef.SetFalseOriginAndUnits(0, 0, 100000);
            pGeometryDefEdit.SpatialReference_2 = spatialRef;
            pFieldEdit.GeometryDef_2 = pGeometryDef;
            pFieldsEdit.AddField(pField);

            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "PlanID", "围填方案号");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "V_Change_Rate", "水道全潮平均流速最大变化率");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "V_Area", "流速变化范围");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Change_Rate", "相邻水道流量变化率");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Silting_Strength", "水道淤积强度");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Ecological_Service_Lost", "生态服务价值损失");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Sewage_Discharge", "污水排放量");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Cultivation_Area", "影像养殖区面积");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Distance", "缩短岸线与深水区的距离");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "V_Variation", "缩短岸线与深水区的距离");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Land_Area", "围填海后形成的陆域面积");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Benifit", "围填海的效益");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Economic_Output", "围填区的经济产出");
            AddSimpleField(pFieldsEdit, esriFieldType.esriFieldTypeString, "Increased_Imployment", "围填区可增加的就业人口");

            ((IFeatureWorkspace)m_workSpace).CreateFeatureClass(name, pFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
        }
コード例 #36
0
        private IProjectedCoordinateSystem GetProjectedCoordinateSystem()
        {
            //以下结果均不加带号
            //if(北京54and三度带)2397+带号   4
            //if(北京54and六度带)21400+带号
            //if(西安80and三度带)2345+带号  4
            //if(西安80and六度带)2325+带号  4
            //创建投影坐标系
            try
            {
                SpatialReferenceEnvironment spatialReferenceEnvironment = new SpatialReferenceEnvironment();
                IProjectedCoordinateSystem projectedCoordinateSystem = new UnknownCoordinateSystemClass() as IProjectedCoordinateSystem;

                if (cbbCoordinateSystem.Text == "北京54坐标系" && cbbfendai.Text == "三度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(2397 + Convert.ToInt32(cbbnumber.Text));
                }
                else if (cbbCoordinateSystem.Text == "北京54坐标系" && cbbfendai.Text == "六度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(21400 + Convert.ToInt32(cbbnumber.Text));
                }
                else if (cbbCoordinateSystem.Text == "西安80坐标系" && cbbfendai.Text == "三度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(2345 + Convert.ToInt32(cbbnumber.Text));
                }
                else if (cbbCoordinateSystem.Text == "西安80坐标系" && cbbfendai.Text == "六度带")
                {
                    projectedCoordinateSystem = spatialReferenceEnvironment.CreateProjectedCoordinateSystem(2325 + Convert.ToInt32(cbbnumber.Text));
                }

                return projectedCoordinateSystem;
            }
            catch (Exception ex)
            {
                string exception = ex.Message;
                MessageBox.Show(exception);
                return null;
            }
        }
コード例 #37
0
ファイル: GDBInput.cs プロジェクト: Krystal001025/temp
        /// <summary>
        /// 创建栅格数据集
        /// </summary>
        /// <param name="pGDBType"></param>
        /// <param name="pPath"></param>
        /// <param name="pFileName"></param>
        /// <param name="pWidth"></param>
        /// <param name="pHeight"></param>
        /// <param name="pXCell"></param>
        /// <param name="pYCell"></param>
        /// <param name="pNumBand"></param>
        /// <returns></returns>
        public IRasterDataset CreateRasterDataset(GDBType pGDBType, string pPath, string pFileName, int pWidth, int pHeight, double pXCell, double pYCell, int pNumBand)
        {
            try
            {
                IRasterWorkspace2 pRWs = GetWorkspace(pPath, pGDBType) as IRasterWorkspace2;

                ISpatialReference sr = new UnknownCoordinateSystemClass();

                IPoint origin = new PointClass();
                origin.PutCoords(0.0, 0.0);
                IRasterDataset rasterDataset = pRWs.CreateRasterDataset(pFileName, "TIFF",
                    origin, pWidth, pHeight, pXCell, pYCell, pNumBand, rstPixelType.PT_UCHAR, sr,
                    true);

                return rasterDataset;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return null;
            }
        }
コード例 #38
0
ファイル: DataBaseCopier.cs プロジェクト: hy1314200/HyDM
        protected virtual IFeatureDataset CreateFeatureDataset(IWorkspace wsTarget, ISpatialReference pSpatialRef)
        {
            if (wsTarget == null)
            {
                return null;
            }
            try
            {
                if (pSpatialRef == null)
                {
                    pSpatialRef = new UnknownCoordinateSystemClass();

                    ISpatialReferenceTolerance pSpatialTolerance = pSpatialRef as ISpatialReferenceTolerance;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = pSpatialRef as ISpatialReferenceResolution;

                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;
                }

                return ((IFeatureWorkspace)wsTarget).CreateFeatureDataset(COMMONCONST.Dataset_Name, pSpatialRef);

            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, string.Format("创建Dataset时出错,信息:{0}", ex.Message));

                return null;
            }
        }
コード例 #39
0
        public static string ToPrjString(ISpatialReference spatialRef)
        {
            if (spatialRef == null)
                spatialRef = new UnknownCoordinateSystemClass();

            int strCount = -1;
            string prjString = null;
            (spatialRef as IESRISpatialReferenceGEN).ExportToESRISpatialReference(out prjString, out strCount);

            return prjString;
        }
コード例 #40
0
ファイル: FeatClsOperAPI.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// 根据某一图层的范围,创建mdb文件中的featuredataset及其空间范围
        /// </summary>
        /// <param name="motherWs">要创建featuredataset的工作空间</param>
        /// <param name="pGeoDataset">featuredataset所要依据的空间参考和空间范围</param>
        /// 这个函数要改!!
        public static void CreateDatasetInWs(IWorkspace motherWs, IGeoDataset pGeoDataset,string datasetName)
        {
            try
            {
                ISpatialReference pSpatialRef = null;
                IFeatureDataset pFtDs = null;

                if (pGeoDataset != null)
                {
                    pSpatialRef = pGeoDataset.SpatialReference;

                    IControlPrecision2 controlPrecision2 = pSpatialRef as IControlPrecision2;
                    if (!controlPrecision2.IsHighPrecision)
                        controlPrecision2.IsHighPrecision = true;

                    IEnvelope pEnv = pGeoDataset.Extent;
                    pEnv.Expand(1.5, 1.5, true);
                    pSpatialRef.SetDomain(pEnv.XMin, pEnv.XMax, pEnv.YMin, pEnv.YMax);

                    ISpatialReferenceTolerance pSpatialTolerance = (ISpatialReferenceTolerance)pSpatialRef;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = (ISpatialReferenceResolution)pSpatialRef;
                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;

                    pFtDs = ((IFeatureWorkspace)motherWs).CreateFeatureDataset(datasetName, pSpatialRef);
                }
                else
                {
                    pSpatialRef = new UnknownCoordinateSystemClass();

                    ISpatialReferenceTolerance pSpatialTolerance = (ISpatialReferenceTolerance)pSpatialRef;
                    double dXYTolerance = pSpatialTolerance.XYTolerance;
                    double dZTolerance = pSpatialTolerance.ZTolerance;
                    ISpatialReferenceResolution pSpatialRefResolution = (ISpatialReferenceResolution)pSpatialRef;
                    pSpatialRefResolution.set_XYResolution(true, dXYTolerance * 0.1);
                    pSpatialRefResolution.set_ZResolution(true, dZTolerance * 0.1);
                    pSpatialRefResolution.MResolution = pSpatialTolerance.MTolerance * 0.1;

                    pFtDs = ((IFeatureWorkspace)motherWs).CreateFeatureDataset(datasetName, pSpatialRef);
                }
            }
            catch(Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

            }
        }
コード例 #41
0
ファイル: Dataset.cs プロジェクト: hy1314200/HyDM
        /// <summary>
        /// �����ռ�ο�
        /// </summary>
        /// <param name="headNode">VCTͷ�ڵ�</param>
        private ISpatialReference CreateProjection(HeadNode headNode)
        {
            try
            {
                string sPrjInfo = "";
                //����ͶӰ�����еij�����ֵ�����ж���ʲô����ϵͳ������54������80��WGS��84�������ط�����ϵ��
                //����54
                double dMajorAxis = headNode.MajorMax.Y;

                //��ȡ�ο���������� �����ƣ������ᣬ���ʵĵ�����
                string sProjection = headNode.Spheroid.Split(',')[0];
                dMajorAxis = Math.Abs(dMajorAxis - 6378245);
                //if (fabs( m_dSemiMajorAxis - 6378245) < 0.0001)
                if (dMajorAxis < 0.0001)
                {
                    sPrjInfo = string.Format("PROJCS[\"{0}\",GEOGCS[\"GCS_Beijing_1954\",DATUM[\"D_Beijing_1954\""
                        + ",SPHEROID[\"{1}\",6378140.0,298.257]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],"
                    + "PROJECTION[\"Gauss_Kruger\"],PARAMETER[\"False_Easting\",{2}],PARAMETER[\"False_Northing\",0.0],"
                    + "PARAMETER[\"Central_Meridian\",{3}],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],"
                    + "UNIT[\"Meter\",1.0]]", sProjection, "Gauss-Krueger", headNode.Excursion, headNode.Parametetor.OriginLongtitude);

                }
                //����80
                else
                {
                    // sPrjInfo = string.Format("PROJCS["%s\",GEOGCS[\"GCS_Xian_1980\",DATUM[\"D_Xian_1980\",SPHEROID[\"%s\",6378140.0,298.257]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Gauss_Kruger\"],PARAMETER[\"False_Easting\",%s],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",%f],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]", m_strProjection, m_strSpheroid, sPianYi, m_lMeridian);
                    sPrjInfo = string.Format("PROJCS[\"{0}\",GEOGCS[\"GCS_Xian_1980\",DATUM[\"D_Xian_1980\","
                    + "SPHEROID[\"{1}\",6378140.0,298.257]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],"
                    + "PROJECTION[\"Gauss_Kruger\"],PARAMETER[\"False_Easting\",{2}],PARAMETER[\"False_Northing\",0.0],"
                    + "PARAMETER[\"Central_Meridian\",{3}],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],"
                    + "UNIT[\"Meter\",1.0]]", sProjection, "Gauss-Krueger", headNode.Parametetor.EastOffset, headNode.Parametetor.OriginLongtitude);
                }
                //��������Ϣд�뵽Prj�ļ�
                string sPrjFilename = Application.StartupPath + "tempPrj.prj";
                FileStream fs = File.Create(sPrjFilename);
                StreamWriter sw = new StreamWriter(fs);
                sw.Write(sPrjInfo);
                sw.Close();
                fs.Close();

                //����Prj�ļ����ɿռ�ο�
                ISpatialReferenceFactory ipSpatialFactory = new SpatialReferenceEnvironmentClass();
                ISpatialReference pSpatialReference = ipSpatialFactory.CreateESRISpatialReferenceFromPRJFile(sPrjFilename);
                pSpatialReference.SetDomain(headNode.MajorMin.X,headNode.MajorMax.X,headNode.MajorMin.Y,headNode.MajorMax.Y);//
                //���þ���,��ֹcutʧ��
                //������λС�����ȡ��Ա�֤����ʱҲ����λ
                ISpatialReferenceTolerance ipSrTolerance = pSpatialReference as ISpatialReferenceTolerance;

                ipSrTolerance.XYTolerance = 0.000001;
                ipSrTolerance.MTolerance = 0.001;
                ipSrTolerance.ZTolerance = 0.001;

                ISpatialReferenceResolution ipSrResolution = pSpatialReference as ISpatialReferenceResolution;
                ipSrResolution.MResolution = 0.001;
                ipSrResolution.set_XYResolution(true, 0.000001);
                ipSrResolution.set_ZResolution(true, 0.001);

                //ɾ�����ɵ�Prj�ļ�
                File.Delete(sPrjFilename);

                //ISpatialReference pSpatialReference;
                //ISpatialReferenceFactory pSpatialreferenceFactory;
                //pSpatialreferenceFactory = new SpatialReferenceEnvironmentClass();
                //IGeographicCoordinateSystem pGeographicCoordinateSystem;
                //pGeographicCoordinateSystem = pSpatialreferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCS3Type.esriSRGeoCS_Xian1980);
                //pSpatialReference = pGeographicCoordinateSystem as ISpatialReference;
                //pSpatialReference.SetFalseOriginAndUnits(-180, -90, 1000000);//

                return pSpatialReference;
            }
            catch (Exception ex)
            {
                LogAPI.WriteLog("�����ռ�ο�ʧ�ܣ�ϵͳĬ�ϴ����յĿռ�ο���\r\n");
                LogAPI.WriteErrorLog(ex);
                ISpatialReference pSpatialReference = new UnknownCoordinateSystemClass();
                pSpatialReference.SetDomain(headNode.MajorMin.X, headNode.MajorMax.X, headNode.MajorMin.Y, headNode.MajorMax.Y);//
                return pSpatialReference;
            }
        }
コード例 #42
0
        private void buttonX_ok_Click(object sender, EventArgs e)
        {
            //add all point
            List <IPoint> pointList = new List <IPoint>();
            //add point type
            List <string> typeList = new List <string>();
            //read excel file to creat Field
            string          strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + this.textBoxX1.Text + ";Extended Properties=Excel 8.0";
            OleDbConnection conn   = new OleDbConnection(strCon);
            string          sql1   = "select * from [Sheet1$]";

            conn.Open();
            OleDbDataAdapter myCommand = new OleDbDataAdapter(sql1, strCon);
            DataSet          ds        = new DataSet();

            myCommand.Fill(ds);
            conn.Close();

            ISpatialReference pSpaReference = new UnknownCoordinateSystemClass();

            pSpaReference.SetDomain(-8000000, 8000000, -800000, 8000000);
            IFeatureClass pFt = CreateShapeFile(ds, this.textBoxX2.Text, pSpaReference);

            int xindex = 18;
            int yindex = 19;
            int zindex = 20;

            if (ds.Tables[0].Columns[19].ColumnName.ToString().Contains("东坐标"))
            {
                xindex++;
                yindex++;
                zindex++;
            }

            if (pFt == null)
            {
                return;
            }
            else
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    //get type
                    string typeTemp = ds.Tables[0].Rows[i][3].ToString();
                    typeTemp = typeTemp.Split(new char[1] {
                        ' '
                    })[0];
                    //根据XY坐标添加点,edit attribute
                    IsNumberic isNum  = new IsNumberic();
                    IPoint     pPoint = new PointClass();
                    if (isNum.IsNumber(ds.Tables[0].Rows[i][xindex].ToString()) && isNum.IsNumber(ds.Tables[0].Rows[i][yindex].ToString()))
                    {
                        pPoint.X = System.Convert.ToDouble(ds.Tables[0].Rows[i][xindex].ToString());
                        pPoint.Y = System.Convert.ToDouble(ds.Tables[0].Rows[i][yindex].ToString());
                        pPoint.Z = System.Convert.ToDouble(ds.Tables[0].Rows[i][zindex].ToString());
                        IFeature pFeature = pFt.CreateFeature();
                        pFeature.Shape = pPoint;

                        pFeature.Store();
                        for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
                        {
                            //pFeature.set_Value(pFeature.Fields.FindField(ds.Tables[0].Columns[j].ColumnName), ds.Tables[0].Rows[i][j]);
                            pFeature.set_Value(j + 2, ds.Tables[0].Rows[i][j].ToString());
                        }
                        pFeature.set_Value(pFeature.Fields.FindField("Type"), typeTemp);
                        pFeature.Store();

                        pointList.Add(pPoint);
                    }
                    else
                    {
                        MessageBox.Show("the" + i + "rows x and y value is unvalid!");
                    }
                }
            }

            ClsGDBDataCommon processDataCommon = new ClsGDBDataCommon();
            string           strInputPath      = System.IO.Path.GetDirectoryName(textBoxX2.Text);
            string           strInputName      = System.IO.Path.GetFileName(textBoxX2.Text);

            IFeatureLayer pFeatureLayer = new FeatureLayerClass();

            pFeatureLayer.FeatureClass = pFt;
            pFeatureLayer.Name         = System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetFileNameWithoutExtension(strInputName)) + "_point";

            //create line shape file
            IPointCollection PointCollection = ReadPoint(pFeatureLayer);
            string           lineName        = strInputPath + "\\" + System.IO.Path.GetFileNameWithoutExtension(strInputName) + "_line.shp";

            CreateLineShpFile(lineName, pSpaReference);
            //将所有的点连接成线
            List <IPolyline> Polyline       = CreatePolyline(PointCollection);
            List <double>    lineLengthList = new List <double>();
            //将连接成的线添加到线图层中
            string pLineFile = lineName;
            string pFilePath = System.IO.Path.GetDirectoryName(pLineFile);
            string pFileName = System.IO.Path.GetFileName(pLineFile);
            //打开工作空间
            IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace pWS  = (IFeatureWorkspace)pWSF.OpenFromFile(pFilePath, 0);
            //写入实体对象
            IFeatureLayer plineLayer = new FeatureLayerClass();

            plineLayer.FeatureClass = pWS.OpenFeatureClass(pFileName);
            AddFeature(plineLayer, Polyline, pointList, lineLengthList);
            plineLayer.Name = pFeatureLayer.Name + "_line";

            m_pMapCtl.AddLayer(plineLayer as ILayer, 0);
            m_pMapCtl.AddLayer(pFeatureLayer as ILayer, 0);
            m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

            ImpSymbolFromFile(textBoxX3.Text, pFeatureLayer, plineLayer);

            //export doc file
            string TemplateFileName = ClsGDBDataCommon.GetParentPathofExe() + @"Resource\WordTemplate\内检测报告.doc";

            exportDocFile(TemplateFileName, textBoxX4.Text, lineLengthList);

            //#region 读取SHP文件
            //IWorkspace pWorkspace = processDataCommon.OpenFromShapefile(strInputPath);
            //IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            //IFeatureClass pInputFC = pFeatureWorkspace.OpenFeatureClass(strInputName);
            //#endregion

            //IFeatureLayer pFeatureLayer = new FeatureLayerClass();
            //pFeatureLayer.FeatureClass = pInputFC;
            //pFeatureLayer.Name = strInputName;
            //m_pMapCtl.AddLayer(pFeatureLayer as ILayer, 0);
            //m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

            this.Close();
        }
コード例 #43
0
        /// <summary>
        /// 以原工作空间为模板创建新的工作空间
        /// </summary>
        private void CreatWorkspaceFromOrig()
        {
            WaitForm.SetCaption("正在创建新的工作空间...请稍后");
            IFeatureClassContainer pFcContainer = null;
            IFeatureClass          pFcTemp      = null;
            IFeatureClass          pNewFc       = null;
            ISpatialReference      pSr          = null;
            ISpatialReference      pSrTemp      = null;
            IFields pflds = null;
            double  dblXmin, dblXmax, dblYmin, dblYmax;
            double  dblZmin, dblZmax, dblMmin, dblMmax;

            CreateWorkspaceDomains(m_pOrigWorkspace, m_pDestWorkspace);
            IFeatureWorkspace pFeaWorkspace = m_pDestWorkspace as IFeatureWorkspace;
            IEnumDataset      enumDs        = m_pOrigWorkspace.get_Datasets(esriDatasetType.esriDTAny);
            IDataset          pDs           = enumDs.Next();

            while (pDs != null)
            {
                if (pDs.Type == esriDatasetType.esriDTFeatureDataset)
                {
                    pSr     = new UnknownCoordinateSystemClass();
                    pSrTemp = (pDs as IGeoDataset).SpatialReference;
                    if (pSrTemp.HasXYPrecision())
                    {
                        pSrTemp.GetDomain(out dblXmin, out dblXmax, out dblYmin, out dblYmax);
                        pSr.SetDomain(dblXmin, dblXmax, dblYmin, dblYmax);
                    }
                    if (pSrTemp.HasZPrecision())
                    {
                        pSrTemp.GetZDomain(out dblZmin, out dblZmax);
                        pSr.SetZDomain(dblZmin, dblZmax);
                    }
                    if (pSrTemp.HasMPrecision())
                    {
                        pSrTemp.GetMDomain(out dblMmin, out dblMmax);
                        pSr.SetMDomain(dblMmin, dblMmax);
                    }
                    IFeatureDataset pFeaDs = pFeaWorkspace.CreateFeatureDataset(pDs.Name, pSr);
                    pFcContainer = (IFeatureClassContainer)pDs;
                    if (pFcContainer.ClassCount > 0)
                    {
                        for (int i = 0; i < pFcContainer.ClassCount; i++)
                        {
                            try
                            {
                                pFcTemp = pFcContainer.get_Class(i);
                                pflds   = CommonFunction.GetFieldsFormFeatureClass(pFcTemp);

                                //若为注记
                                if (pFcTemp.FeatureType == esriFeatureType.esriFTAnnotation)
                                {
                                    IFeatureWorkspaceAnno pFWSAno    = pFeaWorkspace as IFeatureWorkspaceAnno;
                                    IAnnoClass            pAnnoClass = pFcTemp.Extension as IAnnoClass;
                                    IGraphicsLayerScale   pGLS       = new GraphicsLayerScaleClass();
                                    pGLS.ReferenceScale = pAnnoClass.ReferenceScale;
                                    pGLS.Units          = pAnnoClass.ReferenceScaleUnits;


                                    pNewFc = pFWSAno.CreateAnnotationClass((pFcTemp as IDataset).Name,
                                                                           pflds, pFcTemp.CLSID, pFcTemp.EXTCLSID, pFcTemp.ShapeFieldName,
                                                                           "", pFeaDs, null, pAnnoClass.AnnoProperties, pGLS, pAnnoClass.SymbolCollection, true);
                                    (pNewFc as IClassSchemaEdit).AlterAliasName(pFcTemp.AliasName);
                                }
                                else//若为地理要素
                                {
                                    try
                                    {
                                        pNewFc = pFeaDs.CreateFeatureClass((pFcTemp as IDataset).Name,
                                                                           pflds, pFcTemp.CLSID, pFcTemp.EXTCLSID, pFcTemp.FeatureType, pFcTemp.ShapeFieldName, null);
                                        if (pFcTemp.AliasName == "图廓线")
                                        {
                                            int n = 0;
                                        }
                                        (pNewFc as IClassSchemaEdit).AlterAliasName(pFcTemp.AliasName);
                                    }
                                    catch (System.Exception ex)
                                    {
                                        System.Console.WriteLine(ex.Message);
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                System.Console.WriteLine(ex.Message);
                            }
                        }
                    }
                }
                else if (pDs.Type == esriDatasetType.esriDTFeatureClass)
                {
                    pFcTemp = (IFeatureClass)pDs;
                    pflds   = CommonFunction.GetFieldsFormFeatureClass(pFcTemp, pSr);
                    try
                    {
                        pNewFc = pFeaWorkspace.CreateFeatureClass(pDs.Name,
                                                                  pflds,
                                                                  pFcTemp.CLSID,
                                                                  pFcTemp.EXTCLSID,
                                                                  pFcTemp.FeatureType,
                                                                  pFcTemp.ShapeFieldName,
                                                                  null);
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine(ex.Message);
                    }
                }
                else if (pDs.Type == esriDatasetType.esriDTTable)
                {
                    ITable pTable = (ITable)pDs;
                    try
                    {
                        ITable pNewTable = pFeaWorkspace.CreateTable(pDs.Name,
                                                                     pTable.Fields,
                                                                     pTable.CLSID,
                                                                     pTable.EXTCLSID,
                                                                     null);
                    }
                    catch (Exception ex)
                    {
                        System.Console.WriteLine(ex.Message);
                    }
                }
                pDs = enumDs.Next();
            }
        }
コード例 #44
0
        private void 创建栅格数据集ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ISpatialReference pSr = new UnknownCoordinateSystemClass();

              IRasterDataset  pRasterDataset= CreateRasterDataset(@".\data\IDW数据", "RTest","TIFF", pSr);

              IRasterLayer pRasterLayer = new RasterLayerClass();

              pRasterLayer.CreateFromDataset(pRasterDataset);

              axMapControl1.Map.AddLayer(pRasterLayer);
        }