Пример #1
0
        /// <summary>
        /// 为要素类添加拓扑规则,针对针对特殊的要素类检查
        /// </summary>
        /// <param name="pTopo">拓扑</param>
        /// <param name="pTopoRuleType">拓扑规则</param>
        /// <param name="outError">异常</param>
        public void AddRuletoTopology(ITopology pTopo, esriTopologyRuleType pTopoRuleType, out Exception outError)
        {
            outError = null;

            try
            {
                ITopologyRuleContainer pRuleContainer   = pTopo as ITopologyRuleContainer;
                IFeatureClassContainer pFeaClsContainer = pTopo as IFeatureClassContainer;
                IEnumFeatureClass      pEnumFeaCls      = pFeaClsContainer.Classes;
                pEnumFeaCls.Reset();
                IFeatureClass pFeaCls = pEnumFeaCls.Next();

                //设置拓扑规则
                while (pFeaCls != null)
                {
                    ITopologyRule pTopoRule = new TopologyRuleClass();
                    pTopoRule.TopologyRuleType  = pTopoRuleType;
                    pTopoRule.Name              = (pFeaCls as IDataset).Name;
                    pTopoRule.OriginClassID     = pFeaCls.FeatureClassID;
                    pTopoRule.AllOriginSubtypes = true;
                    pRuleContainer.AddRule(pTopoRule);
                    pFeaCls = pEnumFeaCls.Next();
                }
            }
            catch (Exception ex)
            {
                ////*********************************************
                ////guozheng 2010-12-24 平安夜  added 系统异常日志
                //if (ModData.SysLog == null) ModData.SysLog = new clsWriteSystemFunctionLog();
                //ModData.SysLog.Write(ex);
                ////**********************************************
                outError = ex;
            }
        }
Пример #2
0
        /// <summary>
        ///  获取IFeatureDataset所有的要素类,返回IDataset列表
        /// </summary>
        /// <param name="ipDataset"></param>
        /// <param name="arrayDs"></param>
        public static void GetFcNameInDs(IFeatureDataset ipDataset, ref Hashtable arrayDs)
        {
            try
            {
                if (ipDataset == null)
                {
                    return;
                }

                IFeatureClassContainer ipFcContain = (IFeatureClassContainer)ipDataset;

                IEnumFeatureClass ipFcEnum = ipFcContain.Classes;

                IFeatureClass ipFtClass = ipFcEnum.Next();

                while (ipFtClass != null)
                {
                    arrayDs.Add(((IDataset)ipFtClass).Name, (IDataset)ipFtClass);

                    ipFtClass = ipFcEnum.Next();
                }
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return;
            }
        }
Пример #3
0
        //通过IWokspace和图层名称获取图层
        public static List <IFeatureClass> GetFeatureClass(IWorkspace pWorkspace, string DatasetName)
        {
            List <IFeatureClass> newlist = new List <IFeatureClass>();

            if (pWorkspace == null || DatasetName == "")
            {
                return(newlist);
            }
            IEnumDataset pEnumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);

            pEnumDataset.Reset();
            IFeatureDataset pFeaDataset = pEnumDataset.Next() as IFeatureDataset;

            while (pFeaDataset != null)
            {
                if (pFeaDataset.Name == DatasetName)
                {
                    IFeatureClassContainer pFeatureClassContainer = pFeaDataset as IFeatureClassContainer;
                    IEnumFeatureClass      pEnumFeatureClass      = pFeatureClassContainer.Classes;
                    IFeatureClass          pFeatureClass          = pEnumFeatureClass.Next();
                    while (pFeatureClass != null)
                    {
                        newlist.Add(pFeatureClass);
                        pFeatureClass = pEnumFeatureClass.Next();
                    }
                }
                pFeaDataset = pEnumDataset.Next() as IFeatureDataset;
            }
            return(newlist);
        }
Пример #4
0
        /// <summary>
        /// 以迭代形式返回工作空间下的所有要素类,包括数据集中的要素类
        /// </summary>
        /// <param name="workspace">工作空间</param>
        /// <returns>要素类枚举数(要素类集合)</returns>
        private static IEnumerable GetDataset(this IWorkspace workspace)
        {
            //工作空间下的要素类
            IEnumDataset  enumDataset  = workspace.Datasets[esriDatasetType.esriDTFeatureClass];
            IFeatureClass featureClass = enumDataset.Next() as IFeatureClass;

            while (featureClass != null)
            {
                yield return(featureClass);

                featureClass = enumDataset.Next() as IFeatureClass;
            }

            //工作空间下的要素集
            IEnumDataset dsEnumDataset = workspace.Datasets[esriDatasetType.esriDTFeatureDataset];
            IDataset     dataset       = dsEnumDataset.Next();

            while (dataset != null)//遍历要数集
            {
                IFeatureDataset        featureDataset        = (IFeatureDataset)dataset;
                IFeatureClassContainer featureclassContainer = (IFeatureClassContainer)featureDataset;
                IEnumFeatureClass      enumFeatureClass      = featureclassContainer.Classes;
                IFeatureClass          dsFeatureClass        = enumFeatureClass.Next();
                while (dsFeatureClass != null)//在每一个数据集中遍历数据层IFeatureClass
                {
                    yield return(dsFeatureClass);

                    dsFeatureClass = enumFeatureClass.Next();
                }
                dataset = dsEnumDataset.Next();
            }
        }
Пример #5
0
            //注册要素类
            /// <summary>
            /// 返回true说明FeatureClass存在,返回false说明不存在,重新创建
            /// </summary>
            /// <param name="IN_ShapePath"></param>
            /// <returns></returns>
            private bool PRV_AddFeatureClass(string IN_ShapePath)
            {
                string            Temp_Direction         = System.IO.Path.GetDirectoryName(IN_ShapePath);            //该Shp文件的目录
                string            Temp_Name              = System.IO.Path.GetFileNameWithoutExtension(IN_ShapePath); //该Shp文件的名称
                IWorkspaceFactory Temp_ShapeWorkFactory  = new ShapefileWorkspaceFactory();
                IFeatureWorkspace Temp_ShapeWorkspace    = Temp_ShapeWorkFactory.OpenFromFile(Temp_Direction, 0) as IFeatureWorkspace;
                IWorkspaceFactory Temp_AccessWorkFactory = new AccessWorkspaceFactory();
                IFeatureWorkspace Temp_Workspace         = Temp_AccessWorkFactory.OpenFromFile(S_MDBFile, 0) as IFeatureWorkspace;

                IFeatureClassContainer tem_FeatureClassContainer = (IFeatureClassContainer)FDS_Featuredataset;
                IEnumFeatureClass      pEnumFeatureClass         = (IEnumFeatureClass)tem_FeatureClassContainer.Classes;
                IFeatureClass          tem_FeatureClass          = pEnumFeatureClass.Next();

                while (null != tem_FeatureClass)
                {
                    if (Temp_Name == tem_FeatureClass.AliasName)
                    {// return true;
                    }
                    tem_FeatureClass = pEnumFeatureClass.Next();
                }

                IFeatureClass Temp_FeatureClass        = Temp_ShapeWorkspace.OpenFeatureClass(Temp_Name);
                FeatureClassToFeatureClass Temp_FCToFC = new FeatureClassToFeatureClass(IN_ShapePath, S_MDBFile + "\\" + FDS_Featuredataset.Name, Temp_Name);//将Shp文件导入要素数据集

                GP_Progress = GP_Tool.ExecuteAsync(Temp_FCToFC);
                TH_TimeSpan = new Thread(PRV_GetStatus);//开辟线程计时
                TH_TimeSpan.Start();
                TH_TimeSpan.Join();

                return(false);
                // IFeatureClassContainer ss = (FDS_Featuredataset.Workspace as IFeatureWorkspace).OpenFeatureDataset(FDS_Featuredataset.Name) as IFeatureClassContainer;
                //  Console.WriteLine("完成");
            }
Пример #6
0
        //通过IWorkspace获取图层
        public static IFeatureClass GetFeatureClass(IWorkspace pWorkspace, string LayerName, string DatasetName)
        {
            if (pWorkspace == null)
            {
                return(null);
            }
            IEnumDataset pEnumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTFeatureClass);

            pEnumDataset.Reset();
            IDataset pDataset = pEnumDataset.Next();

            while (pDataset != null)
            {
                if (pDataset.Name == LayerName)
                {
                    return(pDataset as IFeatureClass);
                }
                pDataset = pEnumDataset.Next();
            }
            pEnumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);
            pDataset     = pEnumDataset.Next();
            //  IFeatureDataset pFeaDataset = pEnumDataset.Next() as IFeatureDataset;
            while (pDataset != null)
            {
                if (DatasetName == "")
                {
                    IFeatureClassContainer pFeatureClassContainer = pDataset as IFeatureClassContainer;
                    IEnumFeatureClass      pEnumFeatureClass      = pFeatureClassContainer.Classes;
                    IFeatureClass          pFeatureClass          = pEnumFeatureClass.Next();
                    while (pFeatureClass != null)
                    {
                        if (pFeatureClass.AliasName.Contains(LayerName))
                        {
                            return(pFeatureClass);
                        }
                        pFeatureClass = pEnumFeatureClass.Next();
                    }
                }
                else
                {
                    if (pDataset.Name == DatasetName)
                    {
                        IFeatureClassContainer pFeatureClassContainer = pDataset as IFeatureClassContainer;
                        IEnumFeatureClass      pEnumFeatureClass      = pFeatureClassContainer.Classes;
                        IFeatureClass          pFeatureClass          = pEnumFeatureClass.Next();
                        while (pFeatureClass != null)
                        {
                            if (pFeatureClass.AliasName.Contains(LayerName))
                            {
                                return(pFeatureClass);
                            }
                            pFeatureClass = pEnumFeatureClass.Next();
                        }
                    }
                }
                pDataset = pEnumDataset.Next() as IFeatureDataset;
            }
            return(null);
        }
        /// <summary>
        /// Find Nearest Distance
        /// </summary>
        /// <param name="enumFeatureClass">object enumFeatureClass</param>
        /// <param name="point">point source</param>
        /// <param name="searchTolerance">search tolerance</param>
        /// <param name="distance">distance found</param>
        /// <param name="featureClassID">featureClassID found</param>
        /// <param name="featureGeometry">featureGeometry found</param>
        internal static void FindNearestDistance(IEnumFeatureClass enumFeatureClass, IPoint point, double searchTolerance, ref double distance, ref int featureClassID, ref IGeometry featureGeometry)
        {
            enumFeatureClass.Reset();
            IFeatureClass featureClass = enumFeatureClass.Next();

            while (featureClass != null)
            {
                string shapeFieldName = featureClass.ShapeFieldName;
                ITopologicalOperator topologicalOperator = point as ITopologicalOperator;
                ISpatialFilter       spatialFilter       = new SpatialFilterClass();
                spatialFilter.Geometry      = topologicalOperator.Buffer(searchTolerance);
                spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                spatialFilter.GeometryField = shapeFieldName;
                IFeatureCursor featureCursor = null;
                try
                {
                    ////using (ComReleaser comReleaser = new ComReleaser())
                    ////{
                    featureCursor = featureClass.Search(spatialFilter, true);
                    ////comReleaser.ManageLifetime(featureCursor);
                    IFeature feature = featureCursor.NextFeature();
                    while (feature != null)
                    {
                        IProximityOperator proximityOperator = feature.ShapeCopy as IProximityOperator;
                        double             distanceCurrent   = proximityOperator.ReturnDistance(point);
                        if (distance > distanceCurrent)
                        {
                            distance        = distanceCurrent;
                            featureClassID  = featureClass.FeatureClassID;
                            featureGeometry = feature.ShapeCopy;
                        }

                        feature = featureCursor.NextFeature();
                    }
                    ////}
                }
                catch
                {
                    throw;
                }
                finally
                {
                    if (featureCursor != null)
                    {
                        Marshal.ReleaseComObject(featureCursor);
                    }
                }

                featureClass = enumFeatureClass.Next();
            }
        }
Пример #8
0
        private void GeometryNewConnectivityPropertyPage_Load(object sender, EventArgs e)
        {
            IFeatureClass     class3;
            IEnumFeatureClass class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);

            class2.Reset();
            for (class3 = class2.Next(); class3 != null; class3 = class2.Next())
            {
                this.cboConnectivityRule.Properties.Items.Add(new FeatureClassWrap(class3));
            }
            class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
            class2.Reset();
            for (class3 = class2.Next(); class3 != null; class3 = class2.Next())
            {
                this.cboConnectivityRule.Properties.Items.Add(new FeatureClassWrap(class3));
            }
            class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
            class2.Reset();
            for (class3 = class2.Next(); class3 != null; class3 = class2.Next())
            {
                this.cboConnectivityRule.Properties.Items.Add(new FeatureClassWrap(class3));
            }
            class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
            class2.Reset();
            for (class3 = class2.Next(); class3 != null; class3 = class2.Next())
            {
                this.cboConnectivityRule.Properties.Items.Add(new FeatureClassWrap(class3));
            }
            this.method_0(this.igeometricNetwork_0);
        }
Пример #9
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IEnumFeatureClass" />
        /// </summary>
        /// <param name="source">An <see cref="IEnumFeatureClass" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>An <see cref="IEnumerable{T}" /> that contains the feature classes from the input source.</returns>
        public static IEnumerable <IFeatureClass> AsEnumerable(this IEnumFeatureClass source)
        {
            if (source != null)
            {
                source.Reset();
                IFeatureClass featureclass = source.Next();
                while (featureclass != null)
                {
                    yield return(featureclass);

                    featureclass = source.Next();
                }
            }
        }
Пример #10
0
        /// <summary>
        ///     Determines whether the specified network element corresponds to the required generic junction feature class.
        /// </summary>
        /// <param name="junctionEID">The junction EID.</param>
        /// <returns>
        ///     <c>true</c> if the specified network element corresponds to the required generic junction feature class; otherwise,
        ///     <c>false</c>.
        /// </returns>
        protected bool IsGenericJunction(int junctionEID)
        {
            if (_JunctionsClassID < 0)
            {
                // Determine the generic junction class ID.
                IFeatureClassContainer container   = (IFeatureClassContainer)this.GeometricNetwork;
                IEnumFeatureClass      enumClasses = container.Classes;
                enumClasses.Reset();

                // Iterate through all of the classes that participate in the network.
                IFeatureClass networkClass;
                while ((networkClass = enumClasses.Next()) != null)
                {
                    if (this.IsGenericJunction(networkClass))
                    {
                        _JunctionsClassID = networkClass.ObjectClassID;
                        break;
                    }
                }
            }

            // Determine the class identifier for the element.
            IEIDInfo eidInfo = this.GetEIDInfo(junctionEID, esriElementType.esriETJunction);

            // When the class ID equals the generic junction.
            return(eidInfo.Feature.Class.ObjectClassID == _JunctionsClassID);
        }
Пример #11
0
        /// <summary>
        /// 获取要素数据集中所有的要素类的名称和别名的键值对
        /// </summary>
        /// <param name="featureDataset">要素数据集</param>
        /// <returns>返回数据集中所有包含的要素类的名称和别名键值对</returns>
        public static Dictionary <string, string> GetFeatureClassNames(this IFeatureDataset featureDataset)
        {
            Dictionary <string, string> result = new Dictionary <string, string>();
            IFeatureClassContainer      featureClassContainer = (IFeatureClassContainer)featureDataset;
            IEnumFeatureClass           enumFeatureClass      = featureClassContainer.Classes;
            IFeatureClass featureClass = enumFeatureClass.Next();

            while (featureClass != null)
            {
                result.Add(((IDataset)featureClass).Name, featureClass.AliasName);
                featureClass = enumFeatureClass.Next();
            }
            Marshal.ReleaseComObject(enumFeatureClass);
            Marshal.ReleaseComObject(featureClassContainer);
            return(result);
        }
Пример #12
0
        /// <summary>
        /// 获取要素数据集中所有的要素类
        /// </summary>
        /// <param name="featureDataset">要素数据集</param>
        /// <returns>返回数据集中所有包含的要素类</returns>
        public static List <IFeatureClass> GetFeatureClasses(this IFeatureDataset featureDataset)
        {
            List <IFeatureClass>   result = new List <IFeatureClass>();
            IFeatureClassContainer featureClassContainer = (IFeatureClassContainer)featureDataset;
            IEnumFeatureClass      enumFeatureClass      = featureClassContainer.Classes;
            IFeatureClass          featureClass          = enumFeatureClass.Next();

            while (featureClass != null)
            {
                result.Add(featureClass);
                featureClass = enumFeatureClass.Next();
            }
            Marshal.ReleaseComObject(enumFeatureClass);
            Marshal.ReleaseComObject(featureClassContainer);
            return(result);
        }
Пример #13
0
 private void TopologyClassesPropertyPage_Load(object sender, EventArgs e)
 {
     try
     {
         int num2;
         TopologyEditHelper.m_pList.RemoveAll();
         this.vertXtraGrid_0.EditorName  = "要素类";
         this.vertXtraGrid_0.EditorValue = "优先级";
         int num = 1;
         IEnumFeatureClass classes = (this.itopology_0 as IFeatureClassContainer).Classes;
         classes.Reset();
         ITopologyClass class3 = classes.Next() as ITopologyClass;
         IList          list   = new ArrayList();
         for (num2 = 1; num2 <= num; num2++)
         {
             list.Add(num2);
         }
         while (class3 != null)
         {
             if (class3.IsInTopology)
             {
                 num = (num < class3.XYRank) ? class3.XYRank : num;
                 this.vertXtraGrid_0.AddComBoBox((class3 as IDataset).Name, class3.XYRank, list, false,
                                                 new Class6(class3, false));
                 TopologyEditHelper.m_pList.Add(class3);
             }
             class3 = classes.Next() as ITopologyClass;
         }
         this.txtValue.Value = num;
         list.Clear();
         for (num2 = 1; num2 <= num; num2++)
         {
             list.Add(num2);
         }
         for (num2 = 0; num2 < this.gridView1.RowCount; num2++)
         {
             this.vertXtraGrid_0.ChangeItem(num2, ColumnAttribute.CA_COMBOBOX, list, 0.0, 0.0);
         }
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
     }
     this.bool_0 = true;
 }
Пример #14
0
        public static bool isAllowedDatasetFC(string sLayer)
        {
            bool bRetVal = false;

            ESRI.ArcGIS.Geodatabase.IWorkspace pWorkSpace;
            using (CSpatialSubs oSpatialSubs = new CSpatialSubs())
            {
                pWorkSpace = oSpatialSubs.returnEditableSDEWorkspace();
            }

            if (pWorkSpace != null)
            {
                // get the feature classes from each dataset
                IEnumDataset enumFeatureDatasets = pWorkSpace.get_Datasets(esriDatasetType.esriDTFeatureDataset);
                enumFeatureDatasets.Reset();

                IFeatureDataset featureDataset = (IFeatureDataset)enumFeatureDatasets.Next();

                while (featureDataset != null)
                {
                    ISQLPrivilege oDSPriv = (ISQLPrivilege)featureDataset.FullName;
                    int           iDSPriv = oDSPriv.SQLPrivileges;

                    if (iDSPriv > 1)
                    {
                        IFeatureClassContainer fcContainer        = (IFeatureClassContainer)featureDataset;
                        IEnumFeatureClass      enumFeatureClasses = fcContainer.Classes;
                        enumFeatureClasses.Reset();
                        IFeatureClass fc = (IFeatureClass)enumFeatureClasses.Next();
                        while (fc != null)
                        {
                            if (sLayer == fc.AliasName.ToString())
                            {
                                bRetVal = true;
                                break;
                            }

                            fc = (IFeatureClass)enumFeatureClasses.Next();
                        }
                    }
                    featureDataset = (IFeatureDataset)enumFeatureDatasets.Next();
                }
            }
            return(bRetVal);
        }
Пример #15
0
        /// <summary>
        /// 获取要素数据集中指定名称或别名的要素类
        /// </summary>
        /// <param name="featureDataset">要素数据集</param>
        /// <returns></returns>
        public static IFeatureClass GetFirstFeatureClass(this IFeatureDataset featureDataset)
        {
            IFeatureClassContainer featureClassContainer = (IFeatureClassContainer)featureDataset;
            IEnumFeatureClass      enumFeatureClass      = featureClassContainer.Classes;

            Marshal.ReleaseComObject(enumFeatureClass);
            Marshal.ReleaseComObject(featureClassContainer);
            return(enumFeatureClass.Next());
        }
Пример #16
0
        private void DeleteFeature(string FeatureName)
        {
            IFeatureClassContainer pFeatureclassContainer = (IFeatureClassContainer)FeatureDataset_Main;
            IEnumFeatureClass      pEnumFeatureClass      = (IEnumFeatureClass)pFeatureclassContainer.Classes;
            IFeatureClass          pFeatureClass          = (IFeatureClass)pEnumFeatureClass.Next();

            while (pFeatureClass != null)//在每一个数据集中遍历数据层IFeatureClass
            {
                if (pFeatureClass.AliasName.Equals(FeatureName))
                {
                    //CommonClass common = new CommonClass();
                    //common.DeleteTopolgyFromGISDB(Topology);
                    IDataset pds = pFeatureClass as IDataset;
                    LI_FeatureClass.Remove(pFeatureClass);
                    pds.Delete();
                    break;
                }
                pFeatureClass = (IFeatureClass)pEnumFeatureClass.Next();
            }
        }
Пример #17
0
        /// <summary>
        /// 获取数据集中所有包含的要素类
        /// </summary>
        /// <returns>返回数据集中所有包含的要素类 List<IFeatureClass></returns>
        public List <IFeatureClass> PUB_GetAllFeatureClass()
        {
            if (LI_FeatureClass.Count == 0)
            {
                IFeatureClassContainer Temp_FeatureClassContainer = (IFeatureClassContainer)FeatureDataset_Main;
                IEnumFeatureClass      Temp_EnumFeatureClass      = Temp_FeatureClassContainer.Classes;
                IFeatureClass          Temp_FeatureClass          = Temp_EnumFeatureClass.Next();

                while (Temp_FeatureClass != null)
                {
                    LI_FeatureClass.Add(Temp_FeatureClass);
                    Temp_FeatureClass = Temp_EnumFeatureClass.Next();
                }
                if (LI_FeatureClass.Count == 0)
                {
                    MessageBox.Show("空数据集!");
                }
            }
            return(LI_FeatureClass);
        }
Пример #18
0
        public static List <IFeatureClass> GetFeatureClasses(IDataset pDataset)
        {
            List <IFeatureClass>   pList       = new List <IFeatureClass>();
            IFeatureClassContainer ipFcContain = (IFeatureClassContainer)pDataset;
            IEnumFeatureClass      ipFcEnum    = ipFcContain.Classes;
            IFeatureClass          ipFtClass;

            while ((ipFtClass = ipFcEnum.Next()) != null)
            {
                pList.Add(ipFtClass);
            }
            return(pList);
        }
Пример #19
0
        public static IFeature FindFeature(IEnumFeatureClass pEnumFC, int userClassID, int userID)
        {
            IFeatureClass pFC = pEnumFC.Next();

            while (pFC != null)
            {
                if (pFC.ObjectClassID == userClassID)
                {
                    return(pFC.GetFeature(userID));
                }
            }
            return(null);
        }
Пример #20
0
        private Dictionary <string, esriGeometryType> GetFeatureClassType(IWorkspace pWorkspace)
        {
            Dictionary <string, esriGeometryType> dicFeatureClassType = new Dictionary <string, esriGeometryType>();

            if (pWorkspace == null)
            {
                return(null);
            }
            IEnumDataset pEnumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTFeatureClass);

            pEnumDataset.Reset();
            IDataset pDataset = pEnumDataset.Next();

            while (pDataset != null)
            {
                IFeatureClass pFeatureClass = pDataset as IFeatureClass;
                dicFeatureClassType.Add(pDataset.Name, pFeatureClass.ShapeType);
                pDataset = pEnumDataset.Next();
            }
            pEnumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTFeatureDataset);
            pEnumDataset.Reset();
            IFeatureDataset pFeaDataset = pEnumDataset.Next() as IFeatureDataset;

            while (pFeaDataset != null)
            {
                IFeatureClassContainer pFeatureClassContainer = pFeaDataset as IFeatureClassContainer;
                IEnumFeatureClass      pEnumFeatureClass      = pFeatureClassContainer.Classes;
                IFeatureClass          pFeatureClass          = pEnumFeatureClass.Next();
                while (pFeatureClass != null)
                {
                    IDataset pTmpDataset = pFeatureClass as IDataset;
                    dicFeatureClassType.Add(pTmpDataset.Name, pFeatureClass.ShapeType);
                    pFeatureClass = pEnumFeatureClass.Next();
                }
                pFeaDataset = pEnumDataset.Next() as IFeatureDataset;
            }
            return(dicFeatureClassType);
        }
Пример #21
0
        /// <summary>
        /// 获取IFeatureDataset所有的要素类,返回IFeatureClass列表
        /// </summary>
        /// <param name="ipDataset"></param>
        /// <param name="arrayFeatLayer"></param>
        public static void GetFeatLayerInDs(IFeatureDataset ipDataset, ref List <IFeatureLayer> arrayFeatLayer)
        {
            try
            {
                if (ipDataset == null)
                {
                    return;
                }

                IFeatureClassContainer ipFcContain = (IFeatureClassContainer)ipDataset;

                IEnumFeatureClass ipFcEnum = ipFcContain.Classes;

                IFeatureClass ipFtClass = ipFcEnum.Next();


                arrayFeatLayer = new List <IFeatureLayer>();

                while (ipFtClass != null)
                {
                    IFeatureLayer pFLayer = new FeatureLayer();
                    pFLayer.FeatureClass = ipFtClass;
                    pFLayer.Name         = ipFtClass.AliasName;

                    arrayFeatLayer.Add(pFLayer);

                    Marshal.ReleaseComObject(ipFtClass);

                    ipFtClass = ipFcEnum.Next();
                }
            }
            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                return;
            }
        }
Пример #22
0
        private void GeometryNetGeneralPropertyPage_Load(object sender, EventArgs e)
        {
            ListViewItem item;

            this.textEdit1.Text = (this.igeometricNetwork_0 as IDataset).Name;
            IEnumFeatureClass class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);

            class2.Reset();
            IFeatureClass class3 = class2.Next();

            string[] items = new string[2];
            while (class3 != null)
            {
                items[0] = class3.AliasName;
                items[1] = "简单连接点";
                item     = new ListViewItem(items);
                this.listView1.Items.Add(item);
                class3 = class2.Next();
            }
            class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
            class2.Reset();
            for (class3 = class2.Next(); class3 != null; class3 = class2.Next())
            {
                items[0] = class3.AliasName;
                items[1] = "复杂连接点";
                item     = new ListViewItem(items);
                this.listView1.Items.Add(item);
            }
            class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
            class2.Reset();
            for (class3 = class2.Next(); class3 != null; class3 = class2.Next())
            {
                items[0] = class3.AliasName;
                items[1] = "简单边";
                item     = new ListViewItem(items);
                this.listView1.Items.Add(item);
            }
            class2 = this.igeometricNetwork_0.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
            class2.Reset();
            for (class3 = class2.Next(); class3 != null; class3 = class2.Next())
            {
                items[0] = class3.AliasName;
                items[1] = "复杂边";
                item     = new ListViewItem(items);
                this.listView1.Items.Add(item);
            }
        }
Пример #23
0
        public static IFeatureClass GetFeatureClass(string axfPath, string name)
        {
            FileInfo fileInfo = new FileInfo(axfPath);

            if (!fileInfo.Exists)
            {
                return(null);
            }
            if (fileInfo.Directory == null)
            {
                return(null);
            }
            IWorkspaceFactory factory = new FMEWorkspaceFactoryClass() as IWorkspaceFactory;

            if (factory == null)
            {
                return(null);
            }
            IFeatureWorkspace pFeatureWorkspace = factory.OpenFromFile(fileInfo.Directory.FullName, 0) as IFeatureWorkspace;

            if (pFeatureWorkspace == null)
            {
                return(null);
            }
            IFeatureDataset        pFeatureDataset        = pFeatureWorkspace.OpenFeatureDataset(fileInfo.Name);
            IFeatureClassContainer pFeatureClassContainer = pFeatureDataset as IFeatureClassContainer;

            if (pFeatureClassContainer == null)
            {
                return(null);
            }
            IEnumFeatureClass pEnumFeatureClass = pFeatureClassContainer.Classes;
            IFeatureClass     pFeatureClass;

            while ((pFeatureClass = pEnumFeatureClass.Next()) != null)
            {
                if (pFeatureClass.AliasName == name)
                {
                    return(pFeatureClass);
                }
            }
            return(null);
        }
Пример #24
0
        /// <summary>
        /// 获取要素数据集中指定名称或别名的要素类
        /// </summary>
        /// <param name="featureDataset">要素数据集</param>
        /// <param name="featureClassName">要素类名称或别名</param>
        /// <returns></returns>
        public static IFeatureClass GetFeatureClassByName(this IFeatureDataset featureDataset, string featureClassName)
        {
            featureClassName = featureClassName.ToLower();
            IFeatureClassContainer featureClassContainer = (IFeatureClassContainer)featureDataset;
            IEnumFeatureClass      enumFeatureClass      = featureClassContainer.Classes;
            IFeatureClass          featureClass;

            while ((featureClass = enumFeatureClass.Next()) != null)
            {
                if (featureClass.AliasName.ToLower() == featureClassName || (featureClass as IDataset)?.Name.ToLower() == featureClassName)
                {
                    break;
                }
            }

            Marshal.ReleaseComObject(enumFeatureClass);
            Marshal.ReleaseComObject(featureClassContainer);
            return(featureClass);
        }
Пример #25
0
        public void LoadData(IList ilist_0)
        {
            try
            {
                List <ILayer> list = new List <ILayer>();
                for (int i = 0; i < ilist_0.Count; i++)
                {
                    if (ilist_0[i] is IGxLayer)
                    {
                        list.Add((ilist_0[i] as IGxLayer).Layer);
                    }
                    else
                    {
                        IGxDataset gxDataset = ilist_0[i] as IGxDataset;
                        if (gxDataset != null)
                        {
                            IDataset dataset = gxDataset.Dataset;
                            if (dataset != null)
                            {
                                if (dataset.Type == esriDatasetType.esriDTFeatureClass)
                                {
                                    IFeatureClass featureClass = (IFeatureClass)dataset;
                                    IFeatureLayer featureLayer;
                                    if ((gxDataset as IGxObject).Category.IndexOf("CAD") != -1)
                                    {
                                        if (featureClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                                        {
                                            featureLayer = new CadAnnotationLayer() as IFeatureLayer;
                                        }
                                        else
                                        {
                                            featureLayer = new CadFeatureLayer() as IFeatureLayer;
                                        }
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                    {
                                        featureLayer = new FDOGraphicsLayer() as IFeatureLayer;
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else if (featureClass.FeatureType == esriFeatureType.esriFTDimension)
                                    {
                                        featureLayer = new DimensionLayer() as IFeatureLayer;
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else
                                    {
                                        featureLayer = new FeatureLayer();
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    list.Add(featureLayer);
                                }
                                else if (dataset.Type == esriDatasetType.esriDTCadDrawing)
                                {
                                    if ((gxDataset as IGxObject).Category == "CAD绘图")
                                    {
                                        ICadLayer item = new CadLayer() as ICadLayer;
                                        item.CadDrawingDataset = gxDataset.Dataset as ICadDrawingDataset;
                                        item.Name = gxDataset.Dataset.Name;
                                        list.Add(item);
                                    }
                                    else
                                    {
                                        IEnumGxObject children = (gxDataset as IGxObjectContainer).Children;
                                        children.Reset();
                                        for (IGxDataset gxDataset2 = children.Next() as IGxDataset; gxDataset2 != null; gxDataset2 = (children.Next() as IGxDataset))
                                        {
                                            IFeatureClass featureClass = gxDataset2.Dataset as IFeatureClass;
                                            if (featureClass != null)
                                            {
                                                IFeatureLayer featureLayer;
                                                if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                                {
                                                    featureLayer = new FDOGraphicsLayer() as IFeatureLayer;
                                                    featureLayer.FeatureClass = featureClass;
                                                    featureLayer.Name         = featureClass.AliasName;
                                                }
                                                else
                                                {
                                                    featureLayer = new CadFeatureLayer() as IFeatureLayer;
                                                    featureLayer.FeatureClass = featureClass;
                                                    featureLayer.Name         = featureClass.AliasName;
                                                }
                                                list.Add(featureLayer);
                                            }
                                        }
                                    }
                                }
                                else if (dataset.Type == esriDatasetType.esriDTFeatureDataset)
                                {
                                    IEnumDataset subsets = dataset.Subsets;
                                    subsets.Reset();
                                    for (IDataset dataset2 = subsets.Next(); dataset2 != null; dataset2 = subsets.Next())
                                    {
                                        if (dataset2.Type == esriDatasetType.esriDTFeatureClass)
                                        {
                                            IFeatureClass featureClass = dataset2 as IFeatureClass;
                                            if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                            {
                                                IFeatureLayer item = new FDOGraphicsLayer() as IFeatureLayer;
                                                item.FeatureClass = featureClass;
                                                item.Name         = featureClass.AliasName;
                                                list.Add(item);
                                            }
                                            else
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass,
                                                    Name         = featureClass.AliasName
                                                });
                                            }
                                        }
                                        else if (dataset2.Type == esriDatasetType.esriDTTopology)
                                        {
                                            ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer;
                                            topologyLayer.Topology         = (dataset2 as ITopology);
                                            (topologyLayer as ILayer).Name = dataset2.Name;
                                            list.Add(topologyLayer as ILayer);
                                        }
                                    }
                                }
                                else if (dataset.Type == esriDatasetType.esriDTTopology)
                                {
                                    if (System.Windows.Forms.MessageBox.Show("是否将参加拓扑-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes;
                                        classes.Reset();
                                        for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next())
                                        {
                                            list.Add(new FeatureLayer
                                            {
                                                FeatureClass = featureClass2,
                                                Name         = featureClass2.AliasName
                                            });
                                        }
                                    }
                                    ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer;
                                    topologyLayer.Topology         = (dataset as ITopology);
                                    (topologyLayer as ILayer).Name = dataset.Name;
                                    list.Add(topologyLayer as ILayer);
                                }
                                else if (dataset.Type == esriDatasetType.esriDTTin)
                                {
                                    list.Add(new TinLayer
                                    {
                                        Dataset = (ITin)dataset,
                                        Name    = dataset.Name
                                    });
                                }
                                else if (dataset.Type == esriDatasetType.esriDTRasterDataset || dataset.Type == esriDatasetType.esriDTRasterBand)
                                {
                                    bool flag = true;
                                    if (!((IRasterPyramid)dataset).Present)
                                    {
                                        if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysBuildNoPrompt)
                                        {
                                            ((IRasterPyramid)dataset).Create();
                                        }
                                        else if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysPrompt)
                                        {
                                            System.Windows.Forms.DialogResult dialogResult = BuildPyramidSet.Show();
                                            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                                            {
                                                ((IRasterPyramid)dataset).Create();
                                            }
                                            else if (dialogResult == System.Windows.Forms.DialogResult.Cancel)
                                            {
                                                flag = false;
                                            }
                                        }
                                    }
                                    if (flag)
                                    {
                                        IRasterLayer rasterLayer = new RasterLayer
                                        {
                                            Cached = true
                                        };
                                        rasterLayer.CreateFromDataset((IRasterDataset)dataset);
                                        rasterLayer.Name = dataset.Name;
                                        list.Add(rasterLayer);
                                    }
                                }
                                else
                                {
                                    if (dataset.Type == esriDatasetType.esriDTTable)
                                    {
                                        try
                                        {
                                            IRasterCatalogTable rasterCatalogTable = new RasterCatalogTable();
                                            rasterCatalogTable.Table = (ITable)dataset;
                                            rasterCatalogTable.Update();
                                            IRasterCatalogLayer rasterCatalogLayer = new RasterCatalogLayer() as IRasterCatalogLayer;
                                            rasterCatalogLayer.Create(rasterCatalogTable);
                                            rasterCatalogLayer.Name = dataset.BrowseName;
                                            list.Add(rasterCatalogLayer);
                                            goto IL_8B0;
                                        }
                                        catch (Exception ex)
                                        {
                                            try
                                            {
                                                IStandaloneTableCollection standaloneTableCollection = this.method_0() as IStandaloneTableCollection;
                                                IPropertySet connectionProperties = dataset.Workspace.ConnectionProperties;
                                                bool         flag2 = false;
                                                for (int j = 0; j < standaloneTableCollection.StandaloneTableCount; j++)
                                                {
                                                    ITable table = standaloneTableCollection.get_StandaloneTable(j).Table;
                                                    if (
                                                        connectionProperties.IsEqual(
                                                            (table as IDataset).Workspace.ConnectionProperties) &&
                                                        (table as IDataset).Name == dataset.Name)
                                                    {
                                                        flag2 = true;
                                                    }
                                                    else
                                                    {
                                                        standaloneTableCollection.AddStandaloneTable(new StandaloneTable
                                                        {
                                                            Table = dataset as ITable
                                                        });
                                                    }
                                                }
                                            }
                                            catch (Exception exception_)
                                            {
                                                CErrorLog.writeErrorLog(this, exception_, "");
                                            }

                                            goto IL_8B0;
                                        }
                                    }
                                    if (dataset.Type == esriDatasetType.esriDTGeometricNetwork)
                                    {
                                        IGeometricNetwork geometricNetwork = dataset as IGeometricNetwork;
                                        if (geometricNetwork != null)
                                        {
                                            IEnumFeatureClass enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                        }
                                    }
                                    else if (dataset.Type == esriDatasetType.esriDTNetworkDataset)
                                    {
                                        INetworkDataset networkDataset = dataset as INetworkDataset;
                                        INetworkLayer   item           = new NetworkLayer() as INetworkLayer;
                                        item.NetworkDataset = networkDataset;

                                        list.Add(item as ILayer);
                                        if (System.Windows.Forms.MessageBox.Show("是否将参加网络要素集-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes)
                                        {
                                            IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes;
                                            classes.Reset();
                                            for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass2,
                                                    Name         = featureClass2.AliasName
                                                });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    IL_8B0 :;
                }
                int    num   = list.Count;
                ILayer layer = null;
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IRasterCatalogLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IRasterLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is ITinLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is ICadLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryPolygon || featureClass.ShapeType == esriGeometryType.esriGeometryEnvelope)
                        {
                            this.method_0().AddLayer(layer);
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryLine || featureClass.ShapeType == esriGeometryType.esriGeometryBezier3Curve || featureClass.ShapeType == esriGeometryType.esriGeometryCircularArc || featureClass.ShapeType == esriGeometryType.esriGeometryEllipticArc || featureClass.ShapeType == esriGeometryType.esriGeometryPath || featureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                        {
                            try
                            {
                                this.method_0().AddLayer(layer);
                                goto IL_B56;
                            }
                            catch
                            {
                                goto IL_B56;
                            }
                            goto IL_B4D;
IL_B56:
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                    IL_B4D :;
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryMultipoint || featureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                        {
                            this.method_0().AddLayer(layer);
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    this.method_0().AddLayer(layer);
                    (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                    list.RemoveAt(i);
                    num--;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Пример #26
0
        private List <int> _FindDownstreamPipeEnds()
        {
            List <int> endPointOidList = new List <int>();

            INetwork     network     = _geometricNetwork.Network;
            INetTopology netTopology = network as INetTopology;

            bool inletInNetwork = false;
            IEnumFeatureClass junctionClasses = _geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
            IFeatureClass     junctionClass   = junctionClasses.Next();

            while (junctionClass != null)
            {
                if (junctionClass == _inletClass)
                {
                    inletInNetwork = true;
                    break;
                }
                else
                {
                    UrbanDelineationExtension.ReleaseComObject(junctionClass);
                }
                junctionClass = junctionClasses.Next();
            }

            if (!inletInNetwork)
            {
                throw new Exception("The selected inlet class is not part of the pipe network.");
            }

            IFeatureCursor cursor = null;

            try
            {
                int  edgeId;
                bool towardJunction;

                cursor = _inletClass.Search(null, false);
                IFeature inlet = cursor.NextFeature();
                while (inlet != null)
                {
                    try
                    {
                        ISimpleJunctionFeature junction = inlet as ISimpleJunctionFeature;

                        //Check that inlet is a valid part of network before testing if it is at downstream end
                        if (!inlet.Shape.IsEmpty && junction.EID != 0)
                        {
                            bool isDownstream = junction.EdgeFeatureCount > 0;
                            for (int i = 0; i < junction.EdgeFeatureCount; i++)
                            {
                                netTopology.GetAdjacentEdge(junction.EID, i, out edgeId, out towardJunction);
                                if (!towardJunction)
                                {
                                    isDownstream = false;
                                    break;
                                }
                            }

                            if (isDownstream)
                            {
                                endPointOidList.Add(inlet.OID);
                            }
                        }
                    }
                    finally
                    {
                        UrbanDelineationExtension.ReleaseComObject(inlet);
                    }
                    inlet = cursor.NextFeature();
                }
            }
            finally
            {
                UrbanDelineationExtension.ReleaseComObject(cursor);
            }

            return(endPointOidList);
        }
Пример #27
0
        public override bool Pretreat()
        {
            try
            {
                //SendMessage(enumMessageType.RuleError, "正在准备数据");

                IFeatureWorkspace fws = m_TopoWorkspace as IFeatureWorkspace;
                IWorkspace2       ws2 = m_TopoWorkspace as IWorkspace2;

                IFeatureClassContainer fClassContainer = this.m_Topology as IFeatureClassContainer;
                IEnumFeatureClass      enFeatureClass  = fClassContainer.Classes;
                IFeatureClass          fClass          = enFeatureClass.Next();
                IFeatureClass          fClassRefer     = null;
                bool isAdded = false;
                while (fClass != null)
                {
                    IDataset ds = fClass as IDataset;
                    if (ds.Name == m_LayerName)
                    {
                        isAdded = true;
                        break;
                    }
                    fClass = enFeatureClass.Next();
                }
                if (!isAdded)
                {
                    if (!ws2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_LayerName))
                    {
                        SendMessage(enumMessageType.RuleError, string.Format("图层{0}导入拓扑库失败,无法检查", this.m_psRuleParas.arraySeledLayers[0]));
                        return(false);
                    }
                    fClass = fws.OpenFeatureClass(m_LayerName);
                    this.m_Topology.AddClass(fClass as IClass, 1, m_psRuleParas.arrayRanks[0], 1, false);
                }

                if (this.m_psRuleParas.arraySeledLayers.Count > 1)
                {
                    enFeatureClass.Reset();
                    fClassRefer = enFeatureClass.Next();
                    isAdded     = false;
                    while (fClass != null)
                    {
                        IDataset ds = fClassRefer as IDataset;
                        if (ds.Name == m_ReferLayerName)
                        {
                            isAdded = true;
                            break;
                        }
                        fClassRefer = enFeatureClass.Next();
                    }
                    if (!isAdded)
                    {
                        if (!ws2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_ReferLayerName))
                        {
                            SendMessage(enumMessageType.RuleError, string.Format("图层{0}不存在,无法检查", this.m_psRuleParas.arraySeledLayers[1]));
                            return(false);
                        }
                        fClassRefer = fws.OpenFeatureClass(m_ReferLayerName);
                        this.m_Topology.AddClass(fClass as IClass, 1, m_psRuleParas.arrayRanks[1], 1, false);
                    }
                }

                m_TopologylRule               = new TopologyRuleClass();
                m_TopologylRule.Name          = m_psRuleParas.arrayRules[0].strRuleAliasName;
                m_TopologylRule.OriginClassID = fClass.ObjectClassID;
                if (fClassRefer != null)
                {
                    m_TopologylRule.DestinationClassID = fClassRefer.ObjectClassID;
                }

                m_TopologylRule.AllOriginSubtypes      = true;
                m_TopologylRule.AllDestinationSubtypes = true;
                m_TopologylRule.TopologyRuleType       = GetTopologyTypeByName(m_psRuleParas.arrayRules[0].strTopoRuleName);


                (this.m_Topology as ITopologyRuleContainer).AddRule(m_TopologylRule);

                return(true);
            }
            catch (Exception exp)
            {
                SendMessage(enumMessageType.PretreatmentError, "加入到拓扑时出错,信息:" + exp.Message);
                SendMessage(enumMessageType.Exception, exp.ToString());
                return(false);
            }
        }
Пример #28
0
        public static void AddDataset(IBasicMap pMap, IDataset pDataset, string dsName)
        {
            IFeatureLayer fDOGraphicsLayerClass;
            IFeatureClass j;
            IFeatureLayer featureLayerClass;

            if (dsName == null)
            {
                dsName = "";
            }
            switch (pDataset.Type)
            {
            case esriDatasetType.esriDTFeatureDataset:
            {
                IEnumDataset subsets = pDataset.Subsets;
                subsets.Reset();
                for (IDataset i = subsets.Next(); i != null; i = subsets.Next())
                {
                    MapHelper.AddDataset(pMap, i, dsName);
                }
                return;
            }

            case esriDatasetType.esriDTFeatureClass:
            {
                IFeatureClass idataset0 = (IFeatureClass)pDataset;
                if (idataset0.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    fDOGraphicsLayerClass = new FDOGraphicsLayerClass();
                    try
                    {
                        fDOGraphicsLayerClass.FeatureClass = idataset0;
                        fDOGraphicsLayerClass.Name         = string.Concat(dsName, idataset0.AliasName);
                        pMap.AddLayer(fDOGraphicsLayerClass);
                        return;
                    }
                    catch (Exception exception)
                    {
                        exception.ToString();
                        return;
                    }
                }
                else if (idataset0.FeatureType != esriFeatureType.esriFTDimension)
                {
                    fDOGraphicsLayerClass = new FeatureLayerClass()
                    {
                        FeatureClass = idataset0,
                        Name         = string.Concat(dsName, idataset0.AliasName)
                    };
                    pMap.AddLayer(fDOGraphicsLayerClass);
                    return;
                }
                else
                {
                    fDOGraphicsLayerClass = new DimensionLayerClass()
                    {
                        FeatureClass = idataset0,
                        Name         = string.Concat(dsName, idataset0.AliasName)
                    };
                    pMap.AddLayer(fDOGraphicsLayerClass);
                    return;
                }
                break;
            }

            case esriDatasetType.esriDTPlanarGraph:
            case esriDatasetType.esriDTText:
            case esriDatasetType.esriDTRelationshipClass:
            {
                return;
            }

            case esriDatasetType.esriDTGeometricNetwork:
            {
                IGeometricNetwork geometricNetwork = pDataset as IGeometricNetwork;
                if (geometricNetwork == null)
                {
                    return;
                }
                IEnumFeatureClass classesByType =
                    geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleJunction];
                classesByType.Reset();
                for (j = classesByType.Next(); j != null; j = classesByType.Next())
                {
                    featureLayerClass = new FeatureLayerClass()
                    {
                        FeatureClass = j,
                        Name         = string.Concat(dsName, (j as IDataset).Name)
                    };
                    pMap.AddLayer(featureLayerClass);
                }
                classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexJunction];
                classesByType.Reset();
                for (j = classesByType.Next(); j != null; j = classesByType.Next())
                {
                    featureLayerClass = new FeatureLayerClass()
                    {
                        FeatureClass = j,
                        Name         = string.Concat(dsName, (j as IDataset).Name)
                    };
                    pMap.AddLayer(featureLayerClass);
                }
                classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleEdge];
                classesByType.Reset();
                for (j = classesByType.Next(); j != null; j = classesByType.Next())
                {
                    featureLayerClass = new FeatureLayerClass()
                    {
                        FeatureClass = j,
                        Name         = string.Concat(dsName, (j as IDataset).Name)
                    };
                    pMap.AddLayer(featureLayerClass);
                }
                classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexEdge];
                classesByType.Reset();
                for (j = classesByType.Next(); j != null; j = classesByType.Next())
                {
                    featureLayerClass = new FeatureLayerClass()
                    {
                        FeatureClass = j,
                        Name         = string.Concat(dsName, (j as IDataset).Name)
                    };
                    pMap.AddLayer(featureLayerClass);
                }
                return;
            }

            case esriDatasetType.esriDTTopology:
            {
                ITopologyLayer topologyLayerClass = new TopologyLayerClass()
                {
                    Topology = pDataset as ITopology
                };
                (topologyLayerClass as ILayer).Name = string.Concat(dsName, pDataset.Name);
                pMap.AddLayer(topologyLayerClass as ILayer);
                return;
            }

            case esriDatasetType.esriDTTable:
            {
                try
                {
                    IRasterCatalogTable rasterCatalogTableClass = new RasterCatalogTable()
                    {
                        Table = (ITable)pDataset
                    };
                    rasterCatalogTableClass.Update();
                    IRasterCatalogLayer rasterCatalogLayerClass = new RasterCatalogLayerClass();
                    rasterCatalogLayerClass.Create(rasterCatalogTableClass);
                    rasterCatalogLayerClass.Name = string.Concat(dsName, pDataset.BrowseName);
                    pMap.AddLayer(rasterCatalogLayerClass);
                    return;
                }
                catch
                {
                    try
                    {
                        IStandaloneTableCollection ibasicMap0 = pMap as IStandaloneTableCollection;
                        IPropertySet connectionProperties     = pDataset.Workspace.ConnectionProperties;
                        bool         flag = false;
                        int          num  = 0;
                        while (true)
                        {
                            if (num < ibasicMap0.StandaloneTableCount)
                            {
                                ITable table = ibasicMap0.StandaloneTable[num].Table;
                                if (
                                    !connectionProperties.IsEqual((table as IDataset).Workspace.ConnectionProperties) ||
                                    !((table as IDataset).Name == pDataset.Name))
                                {
                                    num++;
                                }
                                else
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        if (!flag)
                        {
                            ibasicMap0.AddStandaloneTable(new StandaloneTableClass()
                                {
                                    Table = pDataset as ITable
                                });
                        }
                    }
                    catch (Exception exception1)
                    {
                        Logger.Current.Write(exception1.Message, LogLevel.Error, null);
                    }
                    return;
                }
                break;
            }

            case esriDatasetType.esriDTRasterDataset:
            case esriDatasetType.esriDTRasterBand:
            {
                IRasterLayer rasterLayerClass = new RasterLayerClass();
                rasterLayerClass.CreateFromDataset((IRasterDataset)pDataset);
                rasterLayerClass.Name = string.Concat(dsName, pDataset.Name);
                pMap.AddLayer(rasterLayerClass);
                return;
            }

            case esriDatasetType.esriDTTin:
            {
                ITinLayer tinLayerClass = new TinLayerClass()
                {
                    Dataset = (ITin)pDataset,
                    Name    = string.Concat(dsName, pDataset.Name)
                };
                pMap.AddLayer(tinLayerClass);
                return;
            }

            case esriDatasetType.esriDTCadDrawing:
            {
                ICadLayer cadLayerClass = new CadLayerClass()
                {
                    CadDrawingDataset = pDataset as ICadDrawingDataset,
                    Name = pDataset.Name
                };
                pMap.AddLayer(cadLayerClass);
                return;
            }

            default:
            {
                return;
            }
            }
        }
		private Dictionary<string, IFeatureClass> ProcessFCs(IEnumFeatureClass fcComplexEdge, IEnumFeatureClass fcComplexNode, IEnumFeatureClass fcSimpleEdge, IEnumFeatureClass fcSimpleNode)
		{
			Dictionary<string, IFeatureClass> pDictionary = new Dictionary<string, IFeatureClass>();

			//handle complex edge
			IFeatureClass fc = fcComplexEdge.Next();
			if (fc != null)
			{
				do
				{
					try
					{
						pDictionary.Add(fc.AliasName, fc);
					}
					catch
					{
						//do nothing
					}
					fc = fcComplexEdge.Next();
				} while (fc != null);
			}

			//handle complex node
			fc = fcComplexNode.Next();
			if (fc != null)
			{
				do
				{
					try
					{
						pDictionary.Add(fc.AliasName, fc);
					}
					catch
					{
						//do nothing
					}
					fc = fcComplexNode.Next();
				} while (fc != null);
			}

			//handle simple edge
			fc = fcSimpleEdge.Next();
			if (fc != null)
			{
				do
				{
					try
					{
						pDictionary.Add(fc.AliasName, fc);
					}
					catch
					{
						//do nothing
					}
					fc = fcSimpleEdge.Next();
				} while (fc != null);
			}

			//handle simple node
			fc = fcSimpleNode.Next();
			if (fc != null)
			{
				do
				{
					try
					{
						pDictionary.Add(fc.AliasName, fc);
					}
					catch
					{
						//do nothing
					}
					fc = fcSimpleNode.Next();
				} while (fc != null);
			}
			return pDictionary;
		}
Пример #30
0
        public static bool AddDataset(ref IBasicMap pBasicMap, IDatasetName pDatasetName, List <IDataset> m_DatasetCol, bool blnAddData)
        {
            bool functionReturnValue = false;

            functionReturnValue = false;
            ////如果是特征数据集,则添加里边的所有要素类
            IFeatureDataset pFeatDS      = default(IFeatureDataset);
            IEnumDataset    pEnumDataSet = default(IEnumDataset);
            IDataset        pDataset     = default(IDataset);
            IFeatureClass   pFeatCls     = default(IFeatureClass);
            IFeatureLayer   pFeatLayer   = default(IFeatureLayer);
            IName           pName        = default(IName);
            ILayer          pLayer       = default(ILayer);
            ITopologyLayer  pTopoLayer   = default(ITopologyLayer);
            //Dim pEnumLyr As IEnumLayer
            ITinWorkspace              pTinWS            = default(ITinWorkspace);
            IEnumFeatureClass          pEnumFeatCls      = null;
            IRasterCatalogDisplayProps pRasterCatalogPro = default(IRasterCatalogDisplayProps);

            //WHFErrorHandle.clsErrorHandle pfrmError = new WHFErrorHandle.clsErrorHandle();

            if (pDatasetName is IFeatureDatasetName)
            {
                pName   = (IName)pDatasetName;
                pFeatDS = (IFeatureDataset)pName.Open();

                pEnumDataSet = pFeatDS.Subsets;
                pDataset     = pEnumDataSet.Next();

                m_DatasetCol.Add(pDataset);
                if (pDataset == null)
                {
                    return(functionReturnValue);
                }
                ////根据数据集的类型,添加特征数据集中的所有要素类(拓扑,一般的,栅格目录,网络)
                while ((pDataset != null))
                {
                    if (pDataset.Type == esriDatasetType.esriDTFeatureClass)
                    {
                        pFeatLayer = null;
                        if (pFeatLayer == null)
                        {
                            pFeatLayer              = new FeatureLayer();
                            pFeatCls                = (IFeatureClass)pDataset;
                            pFeatLayer.Name         = pFeatCls.AliasName;
                            pFeatLayer.FeatureClass = pFeatCls;
                        }

                        if (pDataset.Type == esriDatasetType.esriDTRasterCatalog)
                        {
                            // Dim pRaster
                        }

                        // pSelectedCln.Add(pFeatLayer)
                    }
                    else if (pDataset.Type == esriDatasetType.esriDTTopology)
                    {
                        pTopoLayer          = new TopologyLayerClass();
                        pTopoLayer.Topology = (ITopology)pDataset;
                        pLayer      = (ILayer)pTopoLayer;
                        pLayer.Name = pDataset.Name;

                        //pSelectedCln.Add(pFeatLayer)
                    }

                    pDataset = pEnumDataSet.Next();
                }
                functionReturnValue = true;


                ////添加拓扑图层
            }
            else if (pDatasetName is ITopologyName)
            {
                ITopology pTopo = null;
                pName               = (IName)pDatasetName;
                pDataset            = (IDataset)pName.Open();
                pTopoLayer          = new TopologyLayerClass();
                pTopoLayer.Topology = (ITopology)pDataset;
                pLayer              = (ILayer)pTopoLayer;
                pLayer.Name         = pDataset.Name;
                m_DatasetCol.Add(pDataset);
                if (blnAddData == true)
                {
                    //pMap.AddLayer pLayer
                    AddLyrToBasicMap(ref pBasicMap, pLayer);
                    //SortLayer(pBasicMap, pLayer)
                }
                //pSelectedCln.Add(pLayer)

                //if (pfrmError.DisplayInformation("要把拓扑里边的所有要素类也添加到当前地图中吗?") == true)
                if (MessageBoxEx.Show("要把拓扑里边的所有要素类也添加到当前地图中吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    IFeatureClassContainer pFeatClsContainer = default(IFeatureClassContainer);
                    pFeatClsContainer = (IFeatureClassContainer)pTopo;
                    pEnumFeatCls      = pFeatClsContainer.Classes;
                    pFeatCls          = pEnumFeatCls.Next();
                    pFeatLayer        = new FeatureLayer();

                    ////循环拓扑中的每个要素类,并添加到当前地图中
                    while ((pFeatCls != null))
                    {
                        pFeatLayer.FeatureClass = pFeatCls;
                        pFeatLayer.Name         = pFeatCls.AliasName;

                        if (blnAddData == true)
                        {
                            //pMap.AddLayer pFeatLayer
                            AddLyrToBasicMap(ref pBasicMap, pFeatLayer);
                            //SortLayer(pBasicMap, pFeatLayer)
                        }
                        //pSelectedCln.Add(pFeatLayer)

                        pFeatCls = pEnumFeatCls.Next();
                    }
                }
                functionReturnValue = true;
                ////添加网络数据
            }
            else if (pDatasetName is IGeometricNetworkName)
            {
                INetworkCollection pNetworkCollection = default(INetworkCollection);
                IGeometricNetwork  pGeometricNetwork  = default(IGeometricNetwork);
                int      i           = 0;
                int      j           = 0;
                IDataset pGeoDataset = default(IDataset);

                pName       = (IName)pDatasetName;
                pGeoDataset = (IDataset)pName.Open();
                m_DatasetCol.Add(pGeoDataset);
                if (pGeoDataset.Type == esriDatasetType.esriDTGeometricNetwork)
                {
                    ////这里对网络数据进行处理
                    IFeatureClassContainer pFeatureClassContainer = default(IFeatureClassContainer);
                    pGeometricNetwork      = (IGeometricNetwork)pGeoDataset;
                    pFeatureClassContainer = (IFeatureClassContainer)pGeometricNetwork;

                    for (i = 0; i <= pFeatureClassContainer.ClassCount - 1; i++)
                    {
                        pFeatCls                = pFeatureClassContainer.get_Class(i);
                        pFeatLayer              = new FeatureLayer();
                        pFeatLayer.Name         = pFeatCls.AliasName;
                        pFeatLayer.FeatureClass = pFeatCls;

                        if (blnAddData == true)
                        {
                            // pMap.AddLayer pFeatLayer
                            AddLyrToBasicMap(ref pBasicMap, pFeatLayer);
                            //SortLayer(pBasicMap, pFeatLayer)
                        }
                        //pSelectedCln.Add(pFeatLayer)
                    }
                }
                else
                {
                    pFeatDS            = (IFeatureDataset)pGeoDataset;
                    pNetworkCollection = (INetworkCollection)pFeatDS;
                    ////如果是用户选择一个网络技术打开的话,肯定只有一个网络在里边,其实
                    ////可以不需要循环,而用GeometricNetwork(0)代替循环
                    for (j = 0; j <= pNetworkCollection.GeometricNetworkCount - 1; j++)
                    {
                        pGeometricNetwork = pNetworkCollection.get_GeometricNetwork(j);
                        for (i = 0; i <= 3; i++)
                        {
                            switch (i)
                            {
                            case 0:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                                break;

                            case 1:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                                break;

                            case 2:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                                break;

                            case 3:
                                pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                                break;
                            }
                            pFeatCls = pEnumFeatCls.Next();
                            while ((pFeatCls != null))
                            {
                                pFeatLayer              = new FeatureLayer();
                                pFeatLayer.Name         = pFeatCls.AliasName;
                                pFeatLayer.FeatureClass = pFeatCls;
                                pFeatCls = pEnumFeatCls.Next();

                                if (blnAddData == true)
                                {
                                    //pMap.AddLayer pFeatLayer
                                    AddLyrToBasicMap(ref pBasicMap, pFeatLayer);
                                    //SortLayer(pBasicMap, pFeatLayer)
                                }
                                // pSelectedCln.Add(pFeatLayer)

                                functionReturnValue = true;
                            }
                        }
                    }
                }

                ////添加栅格目录,并设置为显示最新时相
            }
            else if (pDatasetName is IRasterCatalogName)
            {
                pName    = (IName)pDatasetName;
                pDataset = (IDataset)pName.Open();
                m_DatasetCol.Add(pDataset);
                pFeatLayer = new GdbRasterCatalogLayerClass();

                pFeatLayer.FeatureClass = (IFeatureClass)pDataset;
                pFeatLayer.Name         = pDataset.Name;

                //'//如果是SDE的栅格目录
                //If pFeatLayer.DataSourceType = "SDE Raster Catalog" Then

                //    Dim pFeatLayerDef As IFeatureLayerDefinition
                //    pFeatLayerDef = pFeatLayer

                //    '//设置最初显示地图范围内最近时相的数据
                //    pFeatLayerDef.DefinitionExpression = "objectid in (select objectid from" & vbNewLine & _
                //        "(select a.objectid, b.receive_date,rank()" & vbNewLine & _
                //        "over(partition by a.name,a.resolution order by b.receive_date desc) as cid" & vbNewLine & _
                //        "from " & pFeatLayer.Name & " a, sj_t_tense b" & vbNewLine & _
                //        "where a.tense = b.tense" & vbNewLine & "and b.online_state = 1) t2" & vbNewLine & _
                //        "where " & pFeatLayer.Name & ".objectid=t2.objectid and t2.cid = 1)"

                //End If
                ////设置当栅格目录中的图幅在地图上超过16个的时候,以格网来显示,而不显示栅格本身
                pRasterCatalogPro = (IRasterCatalogDisplayProps)pFeatLayer;
                ////不用数量来控制了,而以比例尺来控制
                pRasterCatalogPro.DisplayRasters = 16;
                pRasterCatalogPro.UseScale       = true;
                ////设置一个比例,在此临界栅格数据将会在框架显示与实际栅格显示之间转换
                pRasterCatalogPro.TransitionScale = 50000;

                if (blnAddData == true)
                {
                    //pMap.AddLayer pFeatLayer
                    AddLyrToBasicMap(ref pBasicMap, pFeatLayer);
                    //'SortLayer(pBasicMap, pFeatLayer)
                }
                //pSelectedCln.Add(pFeatLayer)
                functionReturnValue = true;
                // 陈昉  2009-3-22 添加单一的RasterDataset
            }
            else if (pDatasetName is IRasterDatasetName)
            {
                IRasterLayer pRasterLayer = default(IRasterLayer);
                pName    = (IName)pDatasetName;
                pDataset = (IDataset)pName.Open();
                m_DatasetCol.Add(pDataset);
                pRasterLayer = new RasterLayerClass();
                pRasterLayer.CreateFromDataset(pDataset as IRasterDataset);
                pRasterLayer.Name = pDataset.Name;
                AddLyrToBasicMap(ref pBasicMap, pRasterLayer);
                functionReturnValue = true;

                ////添加TIN图层
            }
            else if (pDatasetName is ITinWorkspace)
            {
                pTinWS = (ITinWorkspace)pDatasetName;
                ITinLayer pTinLyr = default(ITinLayer);
                pTinLyr         = new TinLayer();
                pTinLyr.Dataset = pTinWS.OpenTin(pDatasetName.Name);
                pTinLyr.Name    = pDatasetName.Name;

                if (blnAddData == true)
                {
                    //pMap.AddLayer pTinLyr
                    AddLyrToBasicMap(ref pBasicMap, pTinLyr);
                    //SortLayer(pBasicMap, pTinLyr)
                }
                //pSelectedCln.Add(pTinLyr)
                functionReturnValue = true;

                ////添加一般的要素类,未写完。。。。。。
            }
            else
            {
                pName    = (IName)pDatasetName;
                pDataset = (IDataset)pName.Open();
                pFeatCls = (IFeatureClass)pDataset;
                m_DatasetCol.Add(pDataset);
                if (pFeatCls.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    pFeatLayer = new FDOGraphicsLayerClass();
                }
                else if (pFeatCls.FeatureType == esriFeatureType.esriFTDimension)
                {
                    pFeatLayer = new DimensionLayerClass();
                }
                else
                {
                    pFeatLayer = new FeatureLayer();
                }
                //印骅 20081205 添加"Not"
                if ((pFeatLayer != null))
                {
                    //pFeatLayer.Name = pDataset.Name
                    pFeatLayer.Name         = pFeatCls.AliasName;
                    pFeatLayer.FeatureClass = (IFeatureClass)pDataset;
                }
                if (blnAddData == true)
                {
                    //pMap.AddLayer pFeatLayer

                    AddLyrToBasicMap(ref pBasicMap, pFeatLayer);
                    //SortLayer(pBasicMap, pFeatLayer)
                }
                //pSelectedCln.Add(pFeatLayer)

                functionReturnValue = true;
            }
            return(functionReturnValue);

            //'//添加Coverage图层
            //ElseIf vItem.SmallIcon = "Coverage" Then
            //AddSelectedLayer = ADDCoverageLayer(pMap, pCurrentFilePath.Path, _
            //vItem.Text, pSelectedCln, blnAddData)
        }
Пример #31
0
        public void LoadData(IList ilist_0)
        {
            IEnumDataset      subsets;
            IDataset          j;
            string            str;
            IFeatureClass     dataset;
            IFeatureLayer     cadFeatureLayerClass;
            ITopologyLayer    topologyLayerClass;
            IEnumFeatureClass classes;
            IFeatureClass     m;
            IFeatureClass     n;
            IFeatureLayer     featureLayerClass;
            List <object>     objs = new List <object>();

            foreach (object ilist0 in ilist_0)
            {
                if (ilist0 is IGxDataset)
                {
                    if ((ilist0 as IGxDataset).Type != esriDatasetType.esriDTFeatureDataset)
                    {
                        objs.Add(ilist0);
                    }
                    else
                    {
                        IEnumGxObject children = (ilist0 as IGxObjectContainer).Children;
                        children.Reset();
                        for (IGxObject i = children.Next(); i != null; i = children.Next())
                        {
                            objs.Add(i);
                        }
                    }
                }
                else if (!(ilist0 is IDataset))
                {
                    objs.Add(ilist0);
                }
                else
                {
                    if ((ilist0 as IDataset).Type != esriDatasetType.esriDTFeatureDataset)
                    {
                        continue;
                    }
                    subsets = (ilist0 as IDataset).Subsets;
                    subsets.Reset();
                    for (j = subsets.Next(); j != null; j = subsets.Next())
                    {
                        objs.Add(j);
                    }
                }
            }
            ProcessAssist processAssist = new ProcessAssist();

            processAssist.InitProgress();
            processAssist.SetMaxValue(objs.Count);
            processAssist.SetMessage("正在加载数据,请稍候...");
            processAssist.Start();
            try
            {
                ILayer layer = null;
                IMap   map   = this.GetMap();
                this.list_0 = new List <ILayer>();
                List <string> strs      = new List <string>();
                IEnvelope     envelope  = null;
                IDataset      item      = null;
                IGxDataset    gxDataset = null;
                for (int k = 0; k < objs.Count; k++)
                {
                    string name = "";
                    if (objs[k] is IGxObject)
                    {
                        name = (objs[k] as IGxObject).Name;
                    }
                    else if (objs[k] is IDataset)
                    {
                        name = (objs[k] as IDataset).Name;
                    }
                    bool flag = true;
                    str = string.Format("加载图层[{0}],第{1}/{2}个", name, k + 1, objs.Count);
                    processAssist.Increment(1);
                    processAssist.SetMessage(str);
                    if (objs[k] is IGxLayer)
                    {
                        layer = (objs[k] as IGxLayer).Layer;
                        if (layer is IGeoDataset && !SpatialReferenctOperator.ValideFeatureClass(layer as IGeoDataset))
                        {
                            strs.Add(layer.Name);
                            flag = false;
                        }
                        this.AddLayer(map, layer, ref envelope, flag);
                    }
                    else if (!(objs[k] is IGxAGSObject))
                    {
                        if (objs[k] is IGxDataset)
                        {
                            gxDataset = objs[k] as IGxDataset;
                            item      = gxDataset.Dataset;
                        }
                        else if (ilist_0[k] is IDataset)
                        {
                            item = objs[k] as IDataset;
                        }
                        if (item != null)
                        {
                            if (item is IGeoDataset)
                            {
                                flag = SpatialReferenctOperator.ValideFeatureClass(item as IGeoDataset);
                            }
                            if (item.Type == esriDatasetType.esriDTFeatureClass)
                            {
                                dataset = (IFeatureClass)item;
                                if ((gxDataset as IGxObject).Category.IndexOf("CAD") != -1)
                                {
                                    if (dataset.FeatureType != esriFeatureType.esriFTCoverageAnnotation)
                                    {
                                        cadFeatureLayerClass = new CadFeatureLayerClass();
                                    }
                                    else
                                    {
                                        cadFeatureLayerClass = new CadAnnotationLayerClass();
                                    }
                                    cadFeatureLayerClass.FeatureClass = dataset;
                                    cadFeatureLayerClass.Name         = dataset.AliasName;
                                }
                                else if (dataset.FeatureType == esriFeatureType.esriFTAnnotation)
                                {
                                    cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                else if (dataset.FeatureType != esriFeatureType.esriFTDimension)
                                {
                                    cadFeatureLayerClass = new FeatureLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                else
                                {
                                    cadFeatureLayerClass = new DimensionLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                if (!flag)
                                {
                                    strs.Add(cadFeatureLayerClass.Name);
                                }
                                this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                            }
                            else if (item.Type == esriDatasetType.esriDTCadDrawing)
                            {
                                if ((gxDataset as IGxObject).Category != "CAD绘图")
                                {
                                    IEnumGxObject enumGxObject = (gxDataset as IGxObjectContainer).Children;
                                    enumGxObject.Reset();
                                    for (IGxDataset l = enumGxObject.Next() as IGxDataset; l != null; l = enumGxObject.Next() as IGxDataset)
                                    {
                                        dataset = l.Dataset as IFeatureClass;
                                        if (dataset != null)
                                        {
                                            if (dataset.FeatureType != esriFeatureType.esriFTAnnotation)
                                            {
                                                cadFeatureLayerClass = new CadFeatureLayerClass()
                                                {
                                                    FeatureClass = dataset,
                                                    Name         = dataset.AliasName
                                                };
                                            }
                                            else
                                            {
                                                cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                                {
                                                    FeatureClass = dataset,
                                                    Name         = dataset.AliasName
                                                };
                                            }
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag1 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag1;
                                                if (!flag1)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                    }
                                }
                                else
                                {
                                    ICadLayer cadLayerClass = new CadLayerClass()
                                    {
                                        CadDrawingDataset = gxDataset.Dataset as ICadDrawingDataset,
                                        Name = gxDataset.Dataset.Name
                                    };
                                    if (!flag)
                                    {
                                        strs.Add(cadLayerClass.Name);
                                    }
                                    this.AddLayer(map, cadLayerClass, ref envelope, flag);
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTFeatureDataset)
                            {
                                subsets = item.Subsets;
                                subsets.Reset();
                                for (j = subsets.Next(); j != null; j = subsets.Next())
                                {
                                    if (j.Type == esriDatasetType.esriDTFeatureClass)
                                    {
                                        dataset = j as IFeatureClass;
                                        if (dataset.FeatureType != esriFeatureType.esriFTAnnotation)
                                        {
                                            cadFeatureLayerClass = new FeatureLayerClass()
                                            {
                                                FeatureClass = dataset,
                                                Name         = dataset.AliasName
                                            };
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag2 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag2;
                                                if (!flag2)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                        else
                                        {
                                            cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                            {
                                                FeatureClass = dataset,
                                                Name         = dataset.AliasName
                                            };
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag3 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag3;
                                                if (!flag3)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                    }
                                    else if (j.Type == esriDatasetType.esriDTTopology)
                                    {
                                        topologyLayerClass = new TopologyLayerClass()
                                        {
                                            Topology = j as ITopology
                                        };
                                        (topologyLayerClass as ILayer).Name = j.Name;
                                        this.AddLayer(map, topologyLayerClass as ILayer, ref envelope, true);
                                    }
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTTopology)
                            {
                                if (MessageBox.Show(string.Concat("是否将参加拓扑-", item.Name, "-的所有要素添加到地图中"), "添加拓扑层", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                                {
                                    classes = (item as IFeatureClassContainer).Classes;
                                    classes.Reset();
                                    for (m = classes.Next(); m != null; m = classes.Next())
                                    {
                                        cadFeatureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = m,
                                            Name         = m.AliasName
                                        };
                                        flag = true;
                                        if (cadFeatureLayerClass is IGeoDataset)
                                        {
                                            bool flag4 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                            flag = flag4;
                                            if (!flag4)
                                            {
                                                strs.Add(cadFeatureLayerClass.Name);
                                            }
                                        }
                                        this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                    }
                                }
                                topologyLayerClass = new TopologyLayerClass()
                                {
                                    Topology = item as ITopology
                                };
                                (topologyLayerClass as ILayer).Name = item.Name;
                                this.AddLayer(map, topologyLayerClass as ILayer, ref envelope, true);
                            }
                            else if (item.Type == esriDatasetType.esriDTTin)
                            {
                                ITinLayer tinLayerClass = new TinLayerClass()
                                {
                                    Dataset = (ITin)item,
                                    Name    = item.Name
                                };
                                flag = true;
                                if (tinLayerClass is IGeoDataset)
                                {
                                    bool flag5 = SpatialReferenctOperator.ValideFeatureClass(tinLayerClass as IGeoDataset);
                                    flag = flag5;
                                    if (!flag5)
                                    {
                                        strs.Add(tinLayerClass.Name);
                                    }
                                }
                                this.AddLayer(map, tinLayerClass, ref envelope, flag);
                            }
                            else if (item.Type == esriDatasetType.esriDTRasterCatalog)
                            {
                                IGdbRasterCatalogLayer gdbRasterCatalogLayerClass = null;
                                gdbRasterCatalogLayerClass = new GdbRasterCatalogLayerClass();
                                if (gdbRasterCatalogLayerClass.Setup((ITable)(item as IRasterCatalog)))
                                {
                                    bool flag6 = SpatialReferenctOperator.ValideFeatureClass(gdbRasterCatalogLayerClass as IGeoDataset);
                                    flag = flag6;
                                    if (!flag6)
                                    {
                                        strs.Add((gdbRasterCatalogLayerClass as ILayer).Name);
                                    }
                                    this.AddLayer(map, gdbRasterCatalogLayerClass as ILayer, ref envelope, flag);
                                }
                            }
                            else if (!(item.Type == esriDatasetType.esriDTRasterDataset ? false : item.Type != esriDatasetType.esriDTRasterBand))
                            {
                                bool flag7 = true;
                                if (!((IRasterPyramid)item).Present)
                                {
                                    if (this.m_pApp.PyramidPromptType == PyramidPromptType.AlwaysBuildNoPrompt)
                                    {
                                        ((IRasterPyramid)item).Create();
                                    }
                                    else if (this.m_pApp.PyramidPromptType == PyramidPromptType.AlwaysPrompt)
                                    {
                                        DialogResult dialogResult = BuildPyramidSet.Show();
                                        if (dialogResult == DialogResult.Yes)
                                        {
                                            ((IRasterPyramid)item).Create();
                                        }
                                        else if (dialogResult == DialogResult.Cancel)
                                        {
                                            flag7 = false;
                                        }
                                    }
                                }
                                if (flag7)
                                {
                                    IRasterLayer rasterLayerClass = new RasterLayerClass()
                                    {
                                        Cached = true
                                    };
                                    rasterLayerClass.CreateFromDataset((IRasterDataset)item);
                                    rasterLayerClass.Name = item.Name;
                                    bool flag8 = SpatialReferenctOperator.ValideFeatureClass(rasterLayerClass as IGeoDataset);
                                    flag = flag8;
                                    if (!flag8)
                                    {
                                        strs.Add(rasterLayerClass.Name);
                                    }
                                    this.AddLayer(map, rasterLayerClass, ref envelope, flag);
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTTable)
                            {
                                try
                                {
                                    IStandaloneTableCollection standaloneTableCollection = this.GetMap() as IStandaloneTableCollection;
                                    IPropertySet connectionProperties = item.Workspace.ConnectionProperties;
                                    bool         flag9 = false;
                                    int          num   = 0;
                                    while (true)
                                    {
                                        if (num < standaloneTableCollection.StandaloneTableCount)
                                        {
                                            ITable table = standaloneTableCollection.StandaloneTable[num].Table;
                                            if (!connectionProperties.IsEqual((table as IDataset).Workspace.ConnectionProperties) || !((table as IDataset).Name == item.Name))
                                            {
                                                num++;
                                            }
                                            else
                                            {
                                                flag9 = true;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    if (!flag9)
                                    {
                                        standaloneTableCollection.AddStandaloneTable(new StandaloneTableClass()
                                        {
                                            Table = item as ITable
                                        });
                                    }
                                }
                                catch (Exception exception)
                                {
                                    CErrorLog.writeErrorLog(this, exception, "");
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTGeometricNetwork)
                            {
                                IGeometricNetwork geometricNetwork = item as IGeometricNetwork;
                                if (geometricNetwork != null)
                                {
                                    IEnumFeatureClass classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleJunction];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexJunction];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleEdge];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexEdge];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTNetworkDataset)
                            {
                                INetworkLayer networkLayerClass = new NetworkLayerClass()
                                {
                                    NetworkDataset = item as INetworkDataset
                                };
                                this.AddLayer(map, networkLayerClass as ILayer, ref envelope, true);
                                if (MessageBox.Show(string.Concat("是否将参加网络要素集-", item.Name, "-的所有要素添加到地图中"), "添加拓扑层", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                                {
                                    classes = (item as IFeatureClassContainer).Classes;
                                    classes.Reset();
                                    for (m = classes.Next(); m != null; m = classes.Next())
                                    {
                                        cadFeatureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = m,
                                            Name         = m.AliasName
                                        };
                                        this.AddLayer(map, cadFeatureLayerClass, ref envelope, true);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        IMapServerLayer mapServerLayerClass = new MapServerLayerClass();
                        mapServerLayerClass.ServerConnect((objs[k] as IGxAGSObject).AGSServerObjectName, (objs[k] as IGxAGSObject).DefaultMapName);
                        this.AddLayer(map, mapServerLayerClass as ILayer, ref envelope, false);
                    }
                }
                processAssist.End();
                bool layerCount = this.GetMap().LayerCount > 0;
                if (strs.Count > 0)
                {
                    MessageBox.Show("警告:数据范围不一致。\r\n 一个或多个添加的图层范围与关联的空间坐标系范围不一致。请检查数据问题。存在问题图层信息请查看错误日志!", "管理平台", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (string str1 in strs)
                    {
                        if (stringBuilder.Length > 0)
                        {
                            stringBuilder.Append(",");
                        }
                        stringBuilder.Append(str1);
                    }
                    CErrorLog.writeErrorLog(stringBuilder, null, "图层范围不一致!");
                }
                foreach (ILayer list0 in this.list_0)
                {
                    list0.Visible = true;
                }
                if (layerCount && envelope != null)
                {
                    IMap map1 = this.GetMap();
                    ISpatialReference spatialReference = map1.SpatialReference;
                    if ((spatialReference is IUnknownCoordinateSystem || envelope.SpatialReference is IUnknownCoordinateSystem || envelope.SpatialReference == null ? false : spatialReference != null))
                    {
                        envelope.Project(spatialReference);
                    }
                    (map1 as IActiveView).Extent = envelope;
                    (map1 as IActiveView).Refresh();
                }
                if (this.m_pApp != null)
                {
                    this.m_pApp.MapDocumentChanged();
                }
                else if (ApplicationRef.Application != null)
                {
                    ApplicationRef.Application.MapDocumentChanged();
                }
            }
            catch (Exception exception1)
            {
                str = exception1.ToString();
            }
            if (this.onLoadCompleteHand_0 != null)
            {
                this.onLoadCompleteHand_0();
            }
        }