Example #1
0
        public static void UpdateDomains(IWorkspace theWorkspace)
        {
            // Domains to update:
            // DataSources: d_DataSources
            // Station IDs: d_StationIDs

            // Every ncgmp database has a datasources table, right?!
            UpdateCodedValueDomain(theWorkspace, "d_DataSources", "DataSources", "DataSources_ID", "Source");

            // Update StationIDs if the database has that capability
            //if (ncgmpChecks.IsAzgsStationAddinPresent(theWorkspace) == true) {
            UpdateCodedValueDomain(theWorkspace, "d_StationIDs", "Stations", "Stations_ID", "FieldID"); //}

            IWorkspace2 theWorkspace2 = (IWorkspace2)theWorkspace;

            if (theWorkspace2.get_NameExists(esriDatasetType.esriDTTable, commonFunctions.QualifyClassName(theWorkspace, "Landslides")) == true)
            {
                UpdateCodedValueDomain(theWorkspace, "d_LandslideIDs", "Landslides", "LandslideID", "LandslideID");
            }


            if (theWorkspace2.get_NameExists(esriDatasetType.esriDTTable, commonFunctions.QualifyClassName(theWorkspace, "Costs")) == true)
            {
                UpdateCodedValueDomain(theWorkspace, "d_CostIDs", "Costs", "CostID", "Damage");
            }
        }
Example #2
0
        public override bool Verify()
        {
            try
            {
                IWorkspace2 ws2 = m_TopoWorkspace as IWorkspace2;
                m_LayerName = this.m_psRuleParas.arraySeledLayers[0];
                m_LayerName = this.GetLayerName(m_LayerName);

                if (!ws2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_LayerName))
                {
                    Hy.Common.Utility.Esri.GPTool gpTool = new Hy.Common.Utility.Esri.GPTool();
                    gpTool.CopyFeatureClass(m_BaseWorkspace.PathName + "\\" + m_LayerName, m_TopoWorkspace.PathName + "\\" + this.m_Topology.FeatureDataset.Name + "\\" + m_LayerName);
                }

                if (this.m_psRuleParas.arraySeledLayers.Count > 1)
                {
                    m_ReferLayerName = this.m_psRuleParas.arraySeledLayers[1];
                    m_ReferLayerName = this.GetLayerName(m_ReferLayerName);

                    if (!ws2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_ReferLayerName))
                    {
                        Hy.Common.Utility.Esri.GPTool gpTool = new Hy.Common.Utility.Esri.GPTool();
                        gpTool.CopyFeatureClass(m_BaseWorkspace.PathName + "\\" + m_ReferLayerName, m_TopoWorkspace.PathName + "\\" + this.m_Topology.FeatureDataset.Name + "\\" + m_ReferLayerName);
                    }
                }
            }
            catch
            {
                SendMessage(enumMessageType.VerifyError, string.Format("图层“{0}”不存在", this.m_psRuleParas.arraySeledLayers[0]));
                return(false);
            }

            return(true);
        }
Example #3
0
        //修改
        private void datagwSource_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex != 1)
            {
                return;
            }
            //IWorkspaceFactory Pwf = new FileGDBWorkspaceFactoryClass();
            //pWorkspace = (IWorkspace)(Pwf.OpenFromFile(GetSourcePath(comboBoxSource.Text), 0));
            pWorkspace = GetWorkspace(comboBoxSource.Text);
            if (pWorkspace != null)
            {
                pWorkspace2 = (IWorkspace2)pWorkspace;
                m_endstr    = datagwSource.Rows[e.RowIndex].Cells[1].Value.ToString();
                if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_endstr))
                {
                    MessageBox.Show("命名名称已存在,请修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    datagwSource.Rows[e.RowIndex].Cells[1].Value = m_startstr;
                    return;
                }
                if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_startstr))
                {
                    IFeatureClass     tmpfeatureclass;
                    IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;
                    tmpfeatureclass = pFeatureWorkspace.OpenFeatureClass(m_startstr);
                    IDataset set = tmpfeatureclass as IDataset;
                    set.Rename(m_endstr);
                    EditSql(m_startstr, m_endstr);

                    //更改代码 实时更新图层描述
                    GetDataTreeInitIndex dIndex   = new GetDataTreeInitIndex();
                    string             mypath     = dIndex.GetDbInfo();
                    string             strCon     = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
                    string             player     = m_endstr.Substring(15);                                                                                                   //图层组成
                    string             strExp     = "select 描述 from 标准图层信息表 where 代码='" + player + "'";
                    GeoDataCenterDbFun db         = new GeoDataCenterDbFun();
                    string             playername = db.GetInfoFromMdbByExp(strCon, strExp);
                    if (playername != "")
                    {
                        datagwSource.Rows[e.RowIndex].Cells[2].Value = playername;
                    }

                    //listBoxDetail.Items.Add("将" + m_startstr);
                    //listBoxDetail.Items.Add("改为" + m_endstr);
                    //listBoxDetail.Items.Add(" ");
                    MessageBox.Show("修改数据成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Opens the FeatureClass with the specified name from the specified workspace.
        /// </summary>
        /// <param name="Workspace">The workspace.</param>
        /// <param name="featureclassName">Fully qualified name of the featureclass.</param>
        /// <returns>Reference to FeatureClass if found else NULL</returns>
        public static IFeatureClass OpenFeatureClass(IFeatureWorkspace Workspace, string featureclassName)
        {
            // Check for invalid parameters.
            if (Workspace == null)
            {
                throw (new Exception("[Workspace] cannot be null"));
            }

            if (featureclassName == "")
            {
                throw (new Exception("[featureclassName] cannot be empty"));
            }

            // If Workspace is a IWorkspace2 then do the following
            if (!(Workspace is IWorkspace2))
            {
                throw new Exception("[Workspace] must implement IWorksapce2");
            }
            else
            {
                IWorkspace2 ws = Workspace as IWorkspace2;
                //If featureclass exists open it and return it else return null
                if (ws.get_NameExists(esriDatasetType.esriDTFeatureClass, featureclassName))
                {
                    return(Workspace.OpenFeatureClass(featureclassName));
                }
                else
                {
                    return(null);;
                }
            }
        }
        /// <summary>
        /// 创建表
        /// </summary>
        /// <param name="workspace"></param>
        /// <param name="tableName"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public ITable CreateTable(IWorkspace2 workspace, string tableName, IFields fields)
        {
            UID uid = new UIDClass();

            if (workspace == null)
            {
                return(null);
            }
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
            ITable            table;

            if (workspace.get_NameExists(esriDatasetType.esriDTTable, tableName))
            {
                table = featureWorkspace.OpenTable(tableName);
                return(table);
            }
            uid.Value = "esriGeoDatabase.Object";

            if (fields == null)
            {
                return(null);
            }
            IFieldChecker   fieldChecker    = new FieldCheckerClass();
            IEnumFieldError enumFieldError  = null;
            IFields         validatedFields = null;

            fieldChecker.ValidateWorkspace = (IWorkspace)workspace;
            fieldChecker.Validate(fields, out enumFieldError, out validatedFields);

            table = featureWorkspace.CreateTable(tableName, validatedFields, uid, null, "");

            return(table);
        }
        private string method_0(IWorkspace iworkspace_0, string string_0)
        {
            string str2;
            int    num;
            string str = string_0;

            if ((iworkspace_0.Type == esriWorkspaceType.esriLocalDatabaseWorkspace) ||
                (iworkspace_0.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace))
            {
                IWorkspace2 o = iworkspace_0 as IWorkspace2;
                str2 = str;
                for (num = 1; o.get_NameExists(esriDatasetType.esriDTFeatureClass, str2); num++)
                {
                    str2 = str + "_" + num.ToString();
                }
                Marshal.ReleaseComObject(o);
                o = null;
                return(str2);
            }
            string str3 = System.IO.Path.Combine(iworkspace_0.PathName, str);

            str2 = str3 + ".shp";
            for (num = 1; File.Exists(str2); num++)
            {
                str2 = str3 + "_" + num.ToString() + ".shp";
            }
            return(str2);
        }
Example #7
0
        //检查数据集名称是否存在
        private void btn_CheckExist_Click(object sender, EventArgs e)
        {
            if (pTargetworkspace == null)
            {
                MessageBox.Show("请先设置数据源!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (textBox.Text.Trim() == "")
            {
                MessageBox.Show("数据集名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            IWorkspace2 pWorkspace2 = pTargetworkspace as IWorkspace2;

            if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureDataset, textBox.Text))
            {
                MessageBox.Show("数据集名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                MessageBox.Show("数据集名称设置成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btn_CheckExist.Enabled = false;
            }
        }
Example #8
0
        /// <summary>
        /// 判断数据库和镶嵌数据集是否存在的,存在就读取,不存在,就创建
        /// </summary>
        /// <param name="filegdb"></param>
        /// <param name="mosaicDatasetName"></param>
        /// <returns></returns>
        public IMosaicDataset CreateMD(string filegdb, string mosaicDatasetName)
        {
            ISpatialReference mosaicSrs     = null;
            int          mosaicDatasetBands = 0;
            rstPixelType mosaicDatasetBits  = rstPixelType.PT_UNKNOWN;
            string       configKeyword      = "";
            IWorkspace   wk = null;

            if (System.IO.Directory.Exists(filegdb))
            {
                wk = OpenFileGDB(filegdb);
            }
            else
            {
                wk = CreateFileGDB(filegdb);
            }

            IMosaicDataset theMosaicDataset = null;
            IWorkspace2    wk2 = wk as IWorkspace2;

            if (wk2.get_NameExists(esriDatasetType.esriDTMosaicDataset, mosaicDatasetName))
            {
                theMosaicDataset = OpenMosaicDataset(ref wk, mosaicDatasetName);
            }
            else
            {
                theMosaicDataset = CreateMosaicDataset(ref wk, mosaicDatasetName, mosaicSrs, mosaicDatasetBands, mosaicDatasetBits, configKeyword);
            }

            return(theMosaicDataset);
        }
Example #9
0
        private void cbsheng_SelectedIndexChanged(object sender, EventArgs e)
        {
            m_listCity = new List <string>();
            cbShi.Items.Clear();
            cbShi.Text = "";
            cbXian.Items.Clear();
            cbXian.Text = "";
            cbXiang.Items.Clear();
            cbXiang.Text = "";
            cbcun.Items.Clear();
            cbcun.Text = "";
            int ProvinceIndex = cbsheng.SelectedIndex;

            m_Province = m_listProvince[ProvinceIndex];

            IFeatureWorkspace pFW = Plugin.ModuleCommon.TmpWorkSpace as IFeatureWorkspace;
            IWorkspace2       pW2 = Plugin.ModuleCommon.TmpWorkSpace as IWorkspace2;

            if (pFW == null)
            {
                return;
            }
            if (!pW2.get_NameExists(esriDatasetType.esriDTTable, "行政区字典表"))
            {
                return;
            }
            ITable pTable = pFW.OpenTable("行政区字典表");

            int ndx = pTable.FindField("NAME"),
                cdx = pTable.FindField("CODE");

            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = "XZJB='" + 2 + "'and substr(code,1,2)= '" + m_Province + "' and substr(code,1,3)<>'149'";

            ICursor pCursor = pTable.Search(pQueryFilter, false);

            if (pCursor == null)
            {
                return;
            }

            IRow pRow = pCursor.NextRow();


            while (pRow != null)
            {
                cbShi.Items.Add(pRow.get_Value(ndx).ToString());
                m_listCity.Add(pRow.get_Value(cdx).ToString());
                pRow = pCursor.NextRow();
            }
            if (m_listCity.Count <= 0)
            {
                MessageBox.Show("无市级行政区数据!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
        }
        public static bool AreRepresentationsUsed(IWorkspace Workspace)
        {
            IWorkspace2 theWorkspace = (IWorkspace2)Workspace;

            if (theWorkspace.get_NameExists(esriDatasetType.esriDTRepresentationClass, commonFunctions.QualifyClassName(Workspace, "ContactsAndFaults_Rep")) == false)
            {
                return(false);
            }
            if (theWorkspace.get_NameExists(esriDatasetType.esriDTRepresentationClass, commonFunctions.QualifyClassName(Workspace, "GeologicLines_Rep")) == false)
            {
                return(false);
            }
            if (theWorkspace.get_NameExists(esriDatasetType.esriDTRepresentationClass, commonFunctions.QualifyClassName(Workspace, "OrientationPoints_Rep")) == false)
            {
                return(false);
            }
            return(true);
        }
Example #11
0
        /// <summary>
        /// 为数据集创建拓扑
        /// </summary>
        /// <param name="pFeatureDataset">数据集</param>
        /// <param name="topoName">拓扑名称</param>
        /// <param name="outError">异常</param>
        /// <returns>拓扑</returns>
        public ITopology CreateTopo(IFeatureDataset pFeatureDataset, string topoName, double mTolerence, out Exception outError)
        {
            outError = null;

            //topoName =topoName + "_Topology";

            ITopology pTopo = null;

            try
            {
                ITopologyContainer2 pTopoContainer = pFeatureDataset as ITopologyContainer2;

                IWorkspace2 pWS2 = pFeatureDataset.Workspace as IWorkspace2;
                if (pWS2 == null)
                {
                    return(null);
                }
                if (pWS2.get_NameExists(esriDatasetType.esriDTTopology, topoName))
                {
                    //若已经存在拓扑,则删除该拓扑
                    RemoveTopo(pFeatureDataset, topoName, out outError);

                    //ITopologyContainer pTopoCon = pFeatureDataset as ITopologyContainer;
                    //pTopo = pTopoCon.get_TopologyByName(topoName);
                }
                //else
                //{
                //try
                //{
                //    ITopology tempTopo = pTopoContainer.get_TopologyByName(topoName);
                //    if (tempTopo != null)
                //    {
                //        RemoveTopo(pFeatureDataset, topoName, out outError);
                //    }
                //}
                //catch
                //{ }
                if (mTolerence == 0)
                {
                    mTolerence = pTopoContainer.DefaultClusterTolerance;
                }
                pTopo = pTopoContainer.CreateTopology(topoName, mTolerence, -1, "");
                //}
            }
            catch (Exception ex)
            {
                ////*********************************************
                ////guozheng 2010-12-24 平安夜  added 系统异常日志
                //if (ModData.SysLog == null) ModData.SysLog = new clsWriteSystemFunctionLog();
                //ModData.SysLog.Write(ex);
                ////**********************************************
                outError = ex;
            }
            return(pTopo);
        }
Example #12
0
        /// <summary>
        /// Creates a unique name for an Esri object like a feature class or table by adding numbers
        /// on the end of the name.
        /// </summary>
        /// <param name="ws">workspace the object will go in</param>
        /// <param name="dataType">type of object</param>
        /// <param name="baseName">basename</param>
        /// <returns>new name</returns>
        public static string MakeUniqueName(IWorkspace2 ws, esriDatasetType dataType, string baseName)
        {
            string name = baseName;
            int    n    = 1;

            while (ws.get_NameExists(dataType, name))
            {
                name = baseName + (n++).ToString();
            }
            return(name);
        }
Example #13
0
        private void  除选中行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool flag = false;

            foreach (DataGridViewRow row in datagwSource.Rows)
            {
                if ((bool)row.Cells[0].EditedFormattedValue == true)
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                MessageBox.Show("没有选中行,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DialogResult result = MessageBox.Show("是否确定删除!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                foreach (DataGridViewRow row in datagwSource.Rows)
                {
                    if ((bool)row.Cells[0].EditedFormattedValue == true)
                    {
                        //IWorkspaceFactory Pwf = new FileGDBWorkspaceFactoryClass();
                        //pWorkspace = (IWorkspace)(Pwf.OpenFromFile(GetSourcePath(comboBoxSource.Text), 0));
                        pWorkspace = GetWorkspace(comboBoxSource.Text);
                        if (pWorkspace != null)
                        {
                            pWorkspace2 = (IWorkspace2)pWorkspace;
                            if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, row.Cells[1].Value.ToString().Trim()))
                            {
                                IFeatureClass     tmpfeatureclass;
                                IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;
                                tmpfeatureclass = pFeatureWorkspace.OpenFeatureClass(row.Cells[1].Value.ToString().Trim());
                                IDataset set = tmpfeatureclass as IDataset;
                                set.CanDelete();
                                set.Delete();

                                //listBoxDetail.Items.Add("删除了" + row.Cells[1].Value + "数据");
                                //listBoxDetail.Items.Add(" ");
                                //listBoxDetail.Refresh();
                            }
                        }
                        DeleteSql(row.Cells[1].Value.ToString());
                    }
                }
                datagwSource.Rows.Clear();
                ChangeGridView();//重新加载数据
                MessageBox.Show("删除数据成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// 对表MatchedPolygonFCSettingDif进行判断处理
        /// </summary>
        /// <param name="workspace"></param>
        /// <param name="table"></param>
        /// <param name="featureWorkspace"></param>
        /// <returns></returns>
        private ITable TableExist(IWorkspace2 workspace, ITable table, IFeatureWorkspace featureWorkspace)
        {
            IFields fields;

            //匹配参数表是否存在,存在则打开表并删除相关记录
            if (workspace.get_NameExists(esriDatasetType.esriDTTable, ClsConstant.polygonSettingTable))
            {
                table = featureWorkspace.OpenTable(ClsConstant.polygonSettingTable);
                IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();

                ICursor cursor = table.Search(null, false);
                IRow    r      = cursor.NextRow();
                while (r != null)
                {
                    r.Delete();
                    r = cursor.NextRow();
                }
                workspaceEdit.StopEditOperation();
                workspaceEdit.StopEditing(true);

                //ClsDeleteTables.DeleteFeatureClass(gdbPath, ClsConstant.lineSettingTable);
                //fields = CreateMatchedPolylineFCSettingFields(workspace);
                //UID uid = new UIDClass();
                //uid.Value = "esriGeoDatabase.Object";
                //IFieldChecker fieldChecker = new FieldCheckerClass();
                //IEnumFieldError enumFieldError = null;
                //IFields validatedFields = null;
                //fieldChecker.ValidateWorkspace = (IWorkspace)workspace;
                //fieldChecker.Validate(fields, out enumFieldError, out validatedFields);

                //table = featureWorkspace.CreateTable(ClsConstant.lineSettingTable, validatedFields, uid, null, "");
            }
            //匹配参数表是否存在,不存在则创建表
            else
            {
                //返回MatchedPolygonFCSettingDif的所有字段集
                fields = CreateMatchedPolygonFCSettingFields(workspace);
                UID uid = new UIDClass();
                uid.Value = "esriGeoDatabase.Object";
                IFieldChecker   fieldChecker    = new FieldCheckerClass();
                IEnumFieldError enumFieldError  = null;
                IFields         validatedFields = null;
                fieldChecker.ValidateWorkspace = (IWorkspace)workspace;
                fieldChecker.Validate(fields, out enumFieldError, out validatedFields);

                //创建表MatchedPolygonFCSettingDif
                table = featureWorkspace.CreateTable(ClsConstant.polygonSettingTable, validatedFields, uid, null, "");
            }
            return(table);
        }
Example #15
0
        /// <summary>Checks to see if everything is ready for network dataset creation</summary>
        /// <remarks>
        /// - Checks that OSM Dataset is valid
        /// - Assumes that Network Analyst license check is already done (currently done by the GP tool)
        /// </remarks>
        public bool CanCreateNetworkDataset()
        {
            // Check OSM Dataset
            if (_osmDataset == null)
            {
                throw new ArgumentNullException("OSM Dataset");
            }

            IWorkspace2 ws2 = _osmDataset.Workspace as IWorkspace2;

            if (!ws2.get_NameExists(esriDatasetType.esriDTFeatureClass, _osmLineName))
            {
                throw new ApplicationException(string.Format(RESMGR.GetString("GPTools_OSMGPCreateNetworkDataset_invalidOsmDataset"), _osmLineName));
            }

            if (!ws2.get_NameExists(esriDatasetType.esriDTFeatureClass, _osmPointName))
            {
                throw new ApplicationException(string.Format(RESMGR.GetString("GPTools_OSMGPCreateNetworkDataset_invalidOsmDataset"), _osmPointName));
            }

            return(true);
        }
Example #16
0
        /// <summary>
        /// 打开实体表
        /// </summary>
        /// <param name="name">实体表名称</param>
        /// <param name="path">实体表路径</param>
        /// <returns></returns>
        private ITable OpenEntityTable(string name, string path)
        {
            ITable             result            = null;
            IWorkspaceFactory2 pWorkspaceFactory = new FileGDBWorkspaceFactoryClass() as IWorkspaceFactory2;
            IWorkspace2        pWorkspace        = pWorkspaceFactory.OpenFromFile(path, 0) as IWorkspace2;
            IFeatureWorkspace  featureWorkspace  = pWorkspace as IFeatureWorkspace;

            if (pWorkspace.get_NameExists(esriDatasetType.esriDTTable, name))
            {
                result = featureWorkspace.OpenTable(name);
            }
            return(result);
        }
Example #17
0
        /// <summary>
        /// 判断是否存在同名的要素类 xisheng 20110920
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private bool GetExists(string name)
        {
            IWorkspace2 pworkspace = pTargetworkspace as IWorkspace2;

            if (pworkspace.get_NameExists(esriDatasetType.esriDTFeatureClass, name))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #18
0
        public IFeatureClass GetCalcProfileFeatureClass(string currentFeatureClass)
        {
            IWorkspace2       wsp2             = (IWorkspace2)calcWorkspace;
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)calcWorkspace;

            if (!wsp2.get_NameExists(esriDatasetType.esriDTFeatureClass, currentFeatureClass))
            {
                //TODO: Create the feature class
                throw new MilSpaceDataException(currentFeatureClass, Core.DataAccess.DataOperationsEnum.Access);
            }

            return(featureWorkspace.OpenFeatureClass(currentFeatureClass));
        }
Example #19
0
        public ITable GetProfileTable(string resultTable)
        {
            IWorkspace2       wsp2             = (IWorkspace2)calcWorkspace;
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)calcWorkspace;

            if (!wsp2.get_NameExists(esriDatasetType.esriDTTable, resultTable))
            {
                //TODO: Create the feature class
                throw new FileNotFoundException(resultTable);
            }

            return(featureWorkspace.OpenTable(resultTable));
        }
Example #20
0
        public bool CreateOrOpenDatasetFeatureClass(IFeatureWorkspace targetWorkSpace, string DatasetName, string FcName, string FcAlias = "")
        {
            IWorkspace2 space2 = (targetWorkSpace as IWorkspace2);

            if (space2.get_NameExists(esriDatasetType.esriDTFeatureDataset, DatasetName) && space2.get_NameExists(esriDatasetType.esriDTFeatureClass, FcName))
            {
                ResultFeatureClass = (targetWorkSpace.OpenFeatureDataset(DatasetName) as IFeatureClassContainer).get_ClassByName(FcName);
                return(true);
            }
            else
            {
                return(CreateDatasetFeatureClass(targetWorkSpace, DatasetName, FcName, FcAlias));
            }
        }
Example #21
0
        /// <summary>
        /// 获得不同名称的名字 20110920 xisheng
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private string GetNotExistNames(string name)
        {
            if (pTargetworkspace == null)
            {
                return(name);
            }
            IWorkspace2 pw = pTargetworkspace as IWorkspace2;

            name += "_";
            if (pw.get_NameExists(esriDatasetType.esriDTFeatureClass, name))
            {
                name = GetNotExistNames(name);
            }
            return(name);
        }
Example #22
0
        //初始化市级行政区列表
        //ygc 2012-8-21
        private void InitializecbCity()
        {
            listCity = new List <string>();
            IFeatureWorkspace pFW = Plugin.ModuleCommon.TmpWorkSpace as IFeatureWorkspace;
            IWorkspace2       pW2 = Plugin.ModuleCommon.TmpWorkSpace as IWorkspace2;

            if (pFW == null)
            {
                return;
            }
            if (!pW2.get_NameExists(esriDatasetType.esriDTTable, "行政区字典表"))
            {
                return;
            }
            ITable pTable = pFW.OpenTable("行政区字典表");

            int ndx = pTable.FindField("NAME"),
                cdx = pTable.FindField("CODE");

            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = "XZJB='" + 2 + "' and substr(code,1,3)<>'149'";

            ICursor pCursor = pTable.Search(pQueryFilter, false);

            if (pCursor == null)
            {
                return;
            }

            IRow pRow = pCursor.NextRow();

            listCity.Clear();
            while (pRow != null)
            {
                cbShiName.Items.Add(pRow.get_Value(ndx).ToString());
                listCity.Add(pRow.get_Value(cdx).ToString());
                pRow = pCursor.NextRow();
            }
            if (listCity.Count <= 0)
            {
                MessageBox.Show("无市级行政区数据!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            cbShiName.SelectedIndex = 0;
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
        }
Example #23
0
        public string GenerateTempProfileLinesStorage()
        {
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)calcWorkspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            string newFeatureClassName = $"{calcFeatureClass}{MilSpace.DataAccess.Helper.GetTemporaryNameSuffix()}";

            IWorkspace2       wsp2             = (IWorkspace2)calcWorkspace;
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)calcWorkspace;

            if (!wsp2.get_NameExists(esriDatasetType.esriDTFeatureClass, newFeatureClassName))
            {
                IFeatureClassDescription fcDescription = new FeatureClassDescriptionClass();
                IObjectClassDescription  ocDescription = (IObjectClassDescription)fcDescription;
                IFields fields = ocDescription.RequiredFields;


                // Find the shape field in the required fields and modify its GeometryDef to
                // use point geometry and to set the spatial reference.

                int shapeFieldIndex = fields.FindField(fcDescription.ShapeFieldName);

                IField           field           = fields.get_Field(shapeFieldIndex);
                IGeometryDef     geometryDef     = field.GeometryDef;
                IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                geometryDefEdit.GeometryType_2     = esriGeometryType.esriGeometryPolyline;
                geometryDefEdit.SpatialReference_2 = ArcMapInstance.Document.FocusMap.SpatialReference;;

                IFieldsEdit fieldsEdit    = (IFieldsEdit)fields;
                IField      nameField     = new FieldClass();
                IFieldEdit  nameFieldEdit = (IFieldEdit)nameField;
                nameFieldEdit.Name_2 = "ID";
                nameFieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger;
                fieldsEdit.AddField(nameField);

                IFeatureClass featureClass = featureWorkspace.CreateFeatureClass(newFeatureClassName, fields,
                                                                                 ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, "shape", "");
            }

            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            return(newFeatureClassName);
        }
        private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
        {
            int    iMonth = e.Start.Month;
            string sMonth = (iMonth.ToString().Length == 1 ? "0" + iMonth.ToString() : iMonth.ToString());

            int    iYear          = e.Start.Year;
            string sNombreFileGDB = iYear.ToString() + "-" + sMonth + "-Modelos.gdb";
            string sRutaFileGDB   = Sigpi.Parametros.RutaSIGPI + "\\" + Sigpi.Parametros.Resultado + "\\" + sNombreFileGDB;

            if (!System.IO.Directory.Exists(sRutaFileGDB))
            {
                lblCapaAsociada.Text      = "No existe Geodatabase de resultados: \n" + sRutaFileGDB;
                lblCapaAsociada.ForeColor = Color.Red;
                btnExportarAExcel.Enabled = false;
                btnExp2Map.Enabled        = false;
                return;
            }
            try
            {
                IWorkspaceFactory pWF            = new FileGDBWorkspaceFactoryClass();
                IWorkspace2       pWS            = (IWorkspace2)pWF.OpenFromFile(sRutaFileGDB, 0);
                string            sCapaResultado = "Amenaza_" + e.Start.ToString("yyyy_MM_dd");
                if (!pWS.get_NameExists(esriDatasetType.esriDTRasterDataset, sCapaResultado))
                {
                    lblCapaAsociada.Text      = "No existe Modelo: " + sCapaResultado;
                    lblCapaAsociada.ForeColor = Color.Red;
                    btnExportarAExcel.Enabled = false;
                    btnExp2Map.Enabled        = false;
                }
                else
                {
                    lblCapaAsociada.Text      = sCapaResultado;
                    lblCapaAsociada.ForeColor = Color.Green;
                    btnExportarAExcel.Enabled = true;
                    btnExp2Map.Enabled        = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        protected bool InWorkspace(IWorkspace2 wksp2, esriDatasetType type, String name)
        {
            ISQLSyntax sqlSyntax = (ISQLSyntax)wksp2;
            String     fqname    = sqlSyntax.QualifyTableName(_dbName, _ownerName, name);

            bool       result    = true;
            IWorkspace workspace = wksp2 as IWorkspace;

            if (wksp2.get_NameExists(type, fqname))
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Exists check: " + fqname, "PASS");
            }
            else
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Exists check: " + fqname, "FAIL");
                return(false);
            }

            return(result);
        }
Example #26
0
        /// <summary>
        /// 判断MapMain中的图层是否为注册后的归档数据,否则没有历史
        /// </summary>
        /// <param name="pWorkspace"></param>
        /// <param name="strName"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private bool HasArch(IWorkspace pWorkspace, string strName)
        {
            IVersionedObject3 pVersionedObject  = default(IVersionedObject3);
            IArchivableObject pArchivableObject = default(IArchivableObject);
            IFeatureClass     pFeatClass        = default(IFeatureClass);

            IFeatureWorkspace pFeatWorkspace = default(IFeatureWorkspace);
            IWorkspace2       pWorkspace2    = default(IWorkspace2);

            try
            {
                //只对SDE的数据执行历史数据的操作
                if (pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    pWorkspace2 = pWorkspace as IWorkspace2;
                    if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, strName))
                    {
                        pFeatWorkspace   = pWorkspace as IFeatureWorkspace;
                        pFeatClass       = pFeatWorkspace.OpenFeatureClass(strName);
                        pVersionedObject = pFeatClass as IVersionedObject3;
                        if (pVersionedObject == null)
                        {
                            return(false);
                        }
                        pArchivableObject = pVersionedObject as IArchivableObject;
                        if (pArchivableObject.IsArchiving == false)
                        {
                            return(false);
                        }
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #27
0
        public IFeatureClass GetCalcProfileFeatureClass(string currentFeatureClass)
        {
            IWorkspace2       wsp2             = (IWorkspace2)calcWorkspace;
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)calcWorkspace;

            if (!wsp2.get_NameExists(esriDatasetType.esriDTFeatureClass, currentFeatureClass))
            {
                //TODO: Create the feature class
                throw new MilSpaceDataException(currentFeatureClass, Core.DataAccess.DataOperationsEnum.Access);
            }

            var f = featureWorkspace.OpenFeatureClass(currentFeatureClass);

            IQueryFilter queryFilter = new QueryFilter()
            {
                WhereClause = "OBJECTID > 0"
            };

            var allrecords = f.Search(queryFilter, true);

            return(f);
        }
Example #28
0
        private void GenerateTempStorage(string featureClassName, IFields fields, esriGeometryType type)
        {
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)calcWorkspace;

            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IWorkspace2       wsp2             = (IWorkspace2)calcWorkspace;
            IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)calcWorkspace;

            if (!wsp2.get_NameExists(esriDatasetType.esriDTFeatureClass, featureClassName))
            {
                IFeatureClassDescription fcDescription = new FeatureClassDescriptionClass();
                IObjectClassDescription  ocDescription = (IObjectClassDescription)fcDescription;

                if (fields == null)
                {
                    fields = ocDescription.RequiredFields;

                    int shapeFieldIndex = fields.FindField(fcDescription.ShapeFieldName);

                    IField           field           = fields.get_Field(shapeFieldIndex);
                    IGeometryDef     geometryDef     = field.GeometryDef;
                    IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                    geometryDefEdit.HasZ_2             = true;
                    geometryDefEdit.GeometryType_2     = type;
                    geometryDefEdit.SpatialReference_2 = ArcMapInstance.Document.FocusMap.SpatialReference;
                }

                IFeatureClass featureClass = featureWorkspace.CreateFeatureClass(featureClassName, fields,
                                                                                 ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, "shape", "");
            }

            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
        }
Example #29
0
        public static IDatasetContainer3 GetDatasetContainer(IFeatureWorkspace featureWorkspace, string fdName)
        {
            IDatasetContainer3 datasetContainer = null;

            if (featureWorkspace is IWorkspace2)
            {
                IWorkspace2 workspace = featureWorkspace as IWorkspace2;
                bool        fdExists  = workspace.get_NameExists(esriDatasetType.esriDTFeatureDataset, fdName);
                if (!fdExists)
                {
                    throw new Exception("Feature Dataset does not exist.");
                }
            }

            IFeatureDatasetExtensionContainer fdExtensionContainer = (IFeatureDatasetExtensionContainer)featureWorkspace.OpenFeatureDataset(fdName);

            datasetContainer = (IDatasetContainer3)fdExtensionContainer.FindExtension(esriDatasetType.esriDTNetworkDataset);
            if (datasetContainer == null)
            {
                throw new Exception("NATestNetworkDataset: dataset container should not be null");
            }

            return(datasetContainer);
        }
 public static string GetUniqueFeatureClassName(string name, IWorkspace2 workspace)
 {
     //ToDo: This works to get a unique name but it's goobery, need to implement recursion here...
     try
     {
     IFieldChecker fieldChecker = new FieldChecker();
     string fcName;
     fieldChecker.ValidateTableName(name, out fcName);
     int i = 1;
     while(workspace.get_NameExists(esriDatasetType.esriDTFeatureClass, fcName))
     {
         fcName = fcName + i;
         i++;
     }
     return fcName;
     }
     catch
     {
         return "";
     }
 }
        protected bool InWorkspace(IWorkspace2 wksp2, esriDatasetType type, String name)
        {
            bool result = true;
            IWorkspace workspace = wksp2 as IWorkspace;

            if (wksp2.get_NameExists(type, name))
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Exists check: " + name, "PASS");
            }
            else
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Exists check: " + name, "FAIL");
                return false;
            }

            return result;
        }
Example #32
0
        /// <summary>
        /// 将GDB的数据入到SDE中 xisheng 20110919
        /// </summary>
        private void ImportGDBToSDE(string file, string outfilename, out int featurecount)
        {
            m_success = false;//初始化
            try
            {
                string filepath = file.Substring(0, file.LastIndexOf("---"));
                string filename = file.Substring(file.LastIndexOf("-") + 1);

                //打开mdb文件所在的工作空间
                ESRI.ArcGIS.Geodatabase.IWorkspaceFactory wf = new FileGDBWorkspaceFactory();
                IFeatureWorkspace pFeatureWorkspaceGDB       = wf.OpenFromFile(@filepath, 0) as IFeatureWorkspace;
                IWorkspace        pWorkspaceGDB = pFeatureWorkspaceGDB as IWorkspace;
                // 创建源工作空间名称
                IDataset       sourceWorkspaceDataset = (IDataset)pFeatureWorkspaceGDB;
                IWorkspaceName sourceWorkspaceName    = (IWorkspaceName)sourceWorkspaceDataset.FullName;

                //创建源数据集名称
                //IFeatureClassName sourceFeatureClassName = serverContext.CreateObject("esriGeoDatabase.FeatureClassName") as IFeatureClassName;
                IFeatureClassName sourceFeatureClassName = new FeatureClassNameClass();
                IDatasetName      sourceDatasetName      = (IDatasetName)sourceFeatureClassName;
                sourceDatasetName.WorkspaceName = sourceWorkspaceName;
                sourceDatasetName.Name          = filename;

                //打开存在的工作空间,作为导入的空间;
                IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pTargetworkspace;

                //创建目标工作空间名称
                IDataset        targetWorkspaceDataset = (IDataset)pTargetworkspace;
                IWorkspaceName  targetWorkspaceName    = (IWorkspaceName)targetWorkspaceDataset.FullName;
                IWorkspace2     pWorkspace2            = pTargetworkspace as IWorkspace2;
                IFeatureDataset tmpfeaturedataset;
                //创建目标数据集名称
                // IFeatureClassName targetFeatureClassName = serverContext.CreateObject("esriGeoDatabase.FeatureClassName") as IFeatureClassName;
                //判断要素是否存在,若存在将删除源文件
                if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureDataset, textBox.Text))
                {
                    tmpfeaturedataset = pFeatureWorkspace.OpenFeatureDataset(textBox.Text);
                    if (text_prj.Text != "")
                    {
                        IGeoDatasetSchemaEdit pgeodataset = tmpfeaturedataset as IGeoDatasetSchemaEdit;
                        if (pgeodataset.CanAlterSpatialReference)
                        {
                            pgeodataset.AlterSpatialReference(GetSpatialReferenceformFile(text_prj.Text));
                        }
                    }
                }
                else
                {
                    tmpfeaturedataset = CreateFeatureDataset(pTargetworkspace as IFeatureWorkspace, textBox.Text, text_prj.Text);
                }
                if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, outfilename))
                {
                    IFeatureClass tmpfeatureclass;
                    tmpfeatureclass = pFeatureWorkspace.OpenFeatureClass(outfilename);
                    IDataset tempset = tmpfeatureclass as IDataset;
                    tempset.Delete();
                }

                IFeatureClassName targetFeatureClassName = new FeatureClassNameClass();
                IDatasetName      targetDatasetName      = (IDatasetName)targetFeatureClassName;
                targetDatasetName.WorkspaceName = targetWorkspaceName;
                targetDatasetName.Name          = outfilename;
                //目标数据集
                IFeatureDatasetName outfeaturedatasetname = tmpfeaturedataset.FullName as IFeatureDatasetName;


                //打开输入的要素类以得到字段定义
                ESRI.ArcGIS.esriSystem.IName sourceName = (ESRI.ArcGIS.esriSystem.IName)sourceFeatureClassName;
                IFeatureClass sourceFeatureClass        = (IFeatureClass)sourceName.Open();//打开源要素类

                //验证字段名称,因为你正在不同类型的工作空间之间进行数据转换
                //IFieldChecker fieldChecker = serverContext.CreateObject("esriGeoDatabase.FieldChecker") as IFieldChecker;
                IFieldChecker   fieldChecker             = new FieldCheckerClass();
                IFields         sourceFeatureClassFields = sourceFeatureClass.Fields;
                IFields         targetFeatureClassFields;
                IEnumFieldError enumFieldError;

                //最重要的设置输入和验证工作空间
                fieldChecker.InputWorkspace    = pWorkspaceGDB;
                fieldChecker.ValidateWorkspace = pTargetworkspace;
                fieldChecker.Validate(sourceFeatureClassFields, out enumFieldError, out targetFeatureClassFields);

                //遍历所有输出字段找到几何字段
                IField geometryField;
                for (int i = 0; i < targetFeatureClassFields.FieldCount; i++)
                {
                    if (targetFeatureClassFields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry)
                    {
                        geometryField = targetFeatureClassFields.get_Field(i);
                        //得到几何字段的几何定义
                        IGeometryDef geometryDef = geometryField.GeometryDef;
                        //赋予几何定义一个空间索引格网数目和格网大小值
                        IGeometryDefEdit targetFCGeoDefEdit = (IGeometryDefEdit)geometryDef;
                        targetFCGeoDefEdit.GridCount_2 = 1;
                        targetFCGeoDefEdit.set_GridSize(0, 0);
                        //允许ArcGIS为数据加载确定一个有效的格网大小
                        targetFCGeoDefEdit.SpatialReference_2 = geometryField.GeometryDef.SpatialReference;
                        //转换要素类中所有的要素
                        //IQueryFilter queryFilter = serverContext.CreateObject("esriGeoDatabase.QueryFilter") as IQueryFilter; ;
                        QueryFilter queryFilter = new QueryFilterClass();
                        queryFilter.WhereClause = "";
                        //加载要素类
                        //IFeatureDataConverter fctofc = serverContext.CreateObject("esriGeoDatabase.FeatureDataConverter") as IFeatureDataConverter;

                        IFeatureDataConverter fctofc     = new FeatureDataConverterClass();
                        IEnumInvalidObject    enumErrors = fctofc.ConvertFeatureClass(sourceFeatureClassName, queryFilter, outfeaturedatasetname, targetFeatureClassName, geometryDef, targetFeatureClassFields, "", 1000, 0);
                    }
                }
                featurecount = sourceFeatureClass.FeatureCount(null);
                m_success    = true;
            }
            catch (Exception ee) { m_success = false; m_strErr = ee.Message; featurecount = 0; }
        }
        protected bool InWorkspace(IWorkspace2 wksp2, esriDatasetType type, String name)
        {
            ISQLSyntax sqlSyntax = (ISQLSyntax)wksp2;
            String fqname = sqlSyntax.QualifyTableName(_dbName, _ownerName, name);

            bool result = true;
            IWorkspace workspace = wksp2 as IWorkspace;

            if (wksp2.get_NameExists(type, fqname))
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Exists check: " + fqname, "PASS");
            }
            else
            {
                _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Exists check: " + fqname, "FAIL");
                return false;
            }

            return result;
        }
Example #34
0
 //not used
 static bool ifGDBExist(IWorkspace2 ws2, string gdb)
 {
     return ws2.get_NameExists(esriDatasetType.esriDTFeatureClass, gdb);
 }
Example #35
0
        public static IFeatureClass CreateFeatureClassInPGDB(IWorkspace2 workspace, IFeatureDataset featureDataset, string featureClassName, IFields fields, UID CLSID, UID CLSEXT, string strConfigKeyword, esriGeometryType esriGeometryType)
        {
            if (featureClassName == "") return null; // name was not passed in
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass;
            ESRI.ArcGIS.Geodatabase.IFeatureWorkspace featureWorkspace = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)workspace; // Explicit Cast
            if (workspace.get_NameExists(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass, featureClassName)) //feature class with that name already exists
            {

                featureClass = featureWorkspace.OpenFeatureClass(featureClassName);
                return featureClass;
            }

            // assign the class id value if not assigned

            if (CLSID == null)
            {
                CLSID = new ESRI.ArcGIS.esriSystem.UIDClass();
                CLSID.Value = "esriGeoDatabase.Feature";
            }

            ESRI.ArcGIS.Geodatabase.IObjectClassDescription objectClassDescription = new ESRI.ArcGIS.Geodatabase.FeatureClassDescriptionClass();

            // if a fields collection is not passed in then supply our own

            if (fields == null)
            {

                // create the fields using the required fields method

                fields = objectClassDescription.RequiredFields;

                ESRI.ArcGIS.Geodatabase.IFieldsEdit fieldsEdit = (ESRI.ArcGIS.Geodatabase.IFieldsEdit)fields; // Explicit Cast
                ESRI.ArcGIS.Geodatabase.IField field = new ESRI.ArcGIS.Geodatabase.FieldClass();

                // create a user defined text field
                ESRI.ArcGIS.Geodatabase.IFieldEdit fieldEdit = (ESRI.ArcGIS.Geodatabase.IFieldEdit)field; // Explicit Cast

                // setup field properties
                fieldEdit.Name_2 = "SampleField";
                fieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString;
                fieldEdit.IsNullable_2 = true;
                fieldEdit.AliasName_2 = "Sample Field Column";
                fieldEdit.DefaultValue_2 = "test";
                fieldEdit.Editable_2 = true;
                fieldEdit.Length_2 = 100;

                // add field to field collection
                fieldsEdit.AddField(field);
                fields = (ESRI.ArcGIS.Geodatabase.IFields)fieldsEdit; // Explicit Cast
            }

            System.String strShapeField = "";

            // locate the shape field
            for (int j = 0; j < fields.FieldCount; j++)
            {
                if (fields.get_Field(j).Type == esriFieldType.esriFieldTypeGeometry)
                {
                    strShapeField = fields.get_Field(j).Name;
                    ((IGeometryDefEdit)fields.get_Field(j).GeometryDef).GeometryType_2 = esriGeometryType;
                }
            }

            // Use IFieldChecker to create a validated fields collection.
            ESRI.ArcGIS.Geodatabase.IFieldChecker fieldChecker = new ESRI.ArcGIS.Geodatabase.FieldCheckerClass();
            ESRI.ArcGIS.Geodatabase.IEnumFieldError enumFieldError = null;
            ESRI.ArcGIS.Geodatabase.IFields validatedFields = null;
            fieldChecker.ValidateWorkspace = (ESRI.ArcGIS.Geodatabase.IWorkspace)workspace;
            fieldChecker.Validate(fields, out enumFieldError, out validatedFields);
            // The enumFieldError enumerator can be inspected at this point to determine
            // which fields were modified during validation.

            // finally create and return the feature class

            if (featureDataset == null)// if no feature dataset passed in, create at the workspace level
            {
                featureClass = featureWorkspace.CreateFeatureClass(featureClassName, validatedFields, CLSID, CLSEXT, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
            }
            else
            {
                featureClass = featureDataset.CreateFeatureClass(featureClassName, validatedFields, CLSID, CLSEXT, ESRI.ArcGIS.Geodatabase.esriFeatureType.esriFTSimple, strShapeField, strConfigKeyword);
            }
            return featureClass;
        }