Exemplo n.º 1
0
 private void method_0()
 {
     this.bool_0 = true;
     this.igxObjectArray_0.Empty();
     if (this.idatasetName_0.Type == esriDatasetType.esriDTRasterDataset)
     {
         try
         {
             IEnumDatasetName subsetNames = this.idatasetName_0.SubsetNames;
             subsetNames.Reset();
             for (IDatasetName name2 = subsetNames.Next(); name2 != null; name2 = subsetNames.Next())
             {
                 IGxObject obj2 = new GxRasterDataset();
                 (obj2 as IGxDataset).DatasetName = name2;
                 obj2.Attach(this, this.igxCatalog_0);
             }
         }
         catch
         {
         }
     }
     else if (this.idatasetName_0.Type != esriDatasetType.esriDTRasterCatalog)
     {
     }
 }
 private bool method_1(IWorkspace iworkspace_0, esriDatasetType esriDatasetType_1, string string_0)
 {
     try
     {
         if (esriDatasetType_1 == esriDatasetType.esriDTFeatureDataset)
         {
             IEnumDatasetName name = iworkspace_0.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
             name.Reset();
             for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
             {
                 string[] strArray = name2.Name.Split(new char[] { '.' });
                 string   str      = strArray[strArray.Length - 1].ToLower();
                 if (string_0 == str)
                 {
                     return(true);
                 }
             }
             return(false);
         }
         if ((iworkspace_0 as IWorkspace2).get_NameExists(esriDatasetType_1, string_0))
         {
             return(true);
         }
     }
     catch
     {
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Adds the table to ListBox.
 /// </summary>
 /// <param name="pWorkspace">The p workspace.</param>
 /// <param name="imageListBoxControl1">The image ListBox control1.</param>
 public static void AddTableToListBox(IWorkspace pWorkspace, ImageListBoxControl imageListBoxControl1)
 {
     if (pWorkspace != null)
     {
         IconType         iconType        = IconType.Table;
         IEnumDatasetName enumDatasetName = pWorkspace.get_DatasetNames(esriDatasetType.esriDTTable);
         try
         {
             enumDatasetName.Reset();
             IDatasetName datasetName;
             while ((datasetName = enumDatasetName.Next()) != null)
             {
                 ITableName tableName = datasetName as ITableName;
                 if (tableName != null)
                 {
                     ControlAPI.AddItemToListBox(iconType, datasetName.Name, imageListBoxControl1);
                 }
             }
         }
         finally
         {
             Marshal.ReleaseComObject(enumDatasetName);
         }
     }
 }
        private ITable getSettingsTable(IFeatureWorkspace fwspc)
        {
            ITable tbl = null;

            try
            {
                Workspace        mb_ws = (Workspace)fwspc;
                IEnumDatasetName names = mb_ws.get_DatasetNames(esriDatasetType.esriDTTable);
                names.Reset();

                IDatasetName name = names.Next();
                while (name != null)
                {
                    if (name.Name.Contains("AddressingSettings"))
                    {
                        SettingsTableName = name.Name;
                    }
                    name = names.Next();
                }

                tbl = fwspc.OpenTable(SettingsTableName);
            }
            catch (Exception ex)
            {
                tbl = null;
            }

            return(tbl);
        }
Exemplo n.º 5
0
        public void CheckIWorkspaceMethods()
        {
            IEnumDatasetName edsn = ws.get_DatasetNames(esriDatasetType.esriDTFeatureClass);

            Assert.IsTrue(edsn != null);
            IDatasetName dsn;
            //test IEnumDatasetName.Next
            int layerCount = 0;

            while ((dsn = edsn.Next()) != null)
            {
                Assert.IsNotNull(dsn);
                layerCount += 1;
                System.Diagnostics.Debug.WriteLine(dsn.Name);
                System.Diagnostics.Debug.WriteLine(dsn.Category);
                System.Diagnostics.Debug.WriteLine(dsn.Type);
            }
            //test IEnumDatasetName.Reset
            edsn.Reset();
            for (int i = 0; i < layerCount; i++)
            {
                dsn = edsn.Next();
                Assert.IsNotNull(dsn);
            }
        }
Exemplo n.º 6
0
        private void ListFeatureClasses()
        {
            lstDeatureClasses.Items.Clear();

            if (null == m_workspace)
            {
                return;
            }

            IEnumDatasetName datasetNames = m_workspace.get_DatasetNames(esriDatasetType.esriDTAny);

            datasetNames.Reset();
            IDatasetName dsName;

            while ((dsName = datasetNames.Next()) != null)
            {
                lstDeatureClasses.Items.Add(dsName.Name);
            }

            //select the first dataset on the list
            if (lstDeatureClasses.Items.Count > 0)
            {
                lstDeatureClasses.SelectedIndex = 0;
                lstDeatureClasses.Refresh();
            }
        }
Exemplo n.º 7
0
        private void method_1(IList ilist_0, IWorkspace iworkspace_0)
        {
            IEnumDatasetName name = iworkspace_0.get_DatasetNames(esriDatasetType.esriDTAny);

            name.Reset();
            for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
            {
                if (name2.Type == esriDatasetType.esriDTFeatureClass)
                {
                    if ((name2 as IFeatureClassName).FeatureType == esriFeatureType.esriFTSimple)
                    {
                        ilist_0.Add(new ObjectWrap(name2));
                    }
                }
                else if (name2.Type == esriDatasetType.esriDTFeatureDataset)
                {
                    IEnumDatasetName subsetNames = name2.SubsetNames;
                    subsetNames.Reset();
                    for (IDatasetName name4 = subsetNames.Next(); name4 != null; name4 = subsetNames.Next())
                    {
                        if ((name4.Type == esriDatasetType.esriDTFeatureClass) &&
                            ((name4 as IFeatureClassName).FeatureType == esriFeatureType.esriFTSimple))
                        {
                            ilist_0.Add(new ObjectWrap(name4));
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
 private void NewRelationClassSetClass_Load(object sender, EventArgs e)
 {
     if (NewRelationClassHelper.m_pWorkspace != null)
     {
         IEnumDatasetName name = NewRelationClassHelper.m_pWorkspace.get_DatasetNames(esriDatasetType.esriDTAny);
         name.Reset();
         for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
         {
             if (((name2.Type == esriDatasetType.esriDTFeatureClass) ||
                  (name2.Type == esriDatasetType.esriDTTable)) ||
                 (name2.Type == esriDatasetType.esriDTFeatureDataset))
             {
                 TreeNode node = new TreeNode(name2.Name)
                 {
                     Tag = (name2 as IName).Open()
                 };
                 this.treeViewSource.Nodes.Add(node);
                 if (name2.Type == esriDatasetType.esriDTFeatureDataset)
                 {
                     this.method_0(name2, node);
                 }
                 node = new TreeNode(name2.Name)
                 {
                     Tag = (name2 as IName).Open()
                 };
                 this.treeViewDest.Nodes.Add(node);
                 if (name2.Type == esriDatasetType.esriDTFeatureDataset)
                 {
                     this.method_0(name2, node);
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
        private void CoverageGeneralPropertyPage_Load(object sender, EventArgs e)
        {
            this.txtName.Text = (this.icoverageName_0 as IDatasetName).Name;
            IEnumDatasetName featureClassNames = (this.icoverageName_0 as IFeatureDatasetName2).FeatureClassNames;

            featureClassNames.Reset();
            IDatasetName name2 = featureClassNames.Next();

            string[] items = new string[3];
            while (name2 != null)
            {
                items[0] = name2.Name;
                items[1] = this.string_0[(int)(name2 as ICoverageFeatureClassName).Topology];
                if ((name2 as ICoverageFeatureClassName).HasFAT)
                {
                    items[2] = "True";
                }
                else
                {
                    items[2] = "False";
                }
                ListViewItem item = new ListViewItem(items)
                {
                    Tag = name2
                };
                this.listView1.Items.Add(item);
                name2 = featureClassNames.Next();
            }
        }
Exemplo n.º 10
0
 public static void AddFeatureDatasetToListBox(IWorkspace pWorkspace, ImageListBoxControl imageListBoxControl1, DataType type)
 {
     if (pWorkspace != null)
     {
         List <string>    list            = new List <string>();
         IEnumDatasetName enumDatasetName = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
         try
         {
             enumDatasetName.Reset();
             IDatasetName datasetName;
             while ((datasetName = enumDatasetName.Next()) != null)
             {
                 list.Add(datasetName.Name);
             }
         }
         finally
         {
             if (enumDatasetName != null)
             {
                 Marshal.ReleaseComObject(enumDatasetName);
             }
         }
         list.Sort();
         IconType iconType = IconType.FGDBDataset;
         if (type <= DataType.sde)
         {
             if (type != DataType.mdb)
             {
                 if (type == DataType.sde)
                 {
                     iconType = IconType.SDEDataset;
                 }
             }
             else
             {
                 iconType = IconType.PGDBDataset;
             }
         }
         else if (type != DataType.cad)
         {
             if (type == DataType.coverage)
             {
                 iconType = IconType.Coverage;
             }
         }
         else
         {
             iconType = IconType.Cad;
         }
         foreach (string current in list)
         {
             ControlAPI.AddItemToListBox(iconType, current, imageListBoxControl1);
         }
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// 打开矢量文件
        /// </summary>
        /// <param name="shpFile">文件名</param>
        /// <returns></returns>
        public static IFeatureClass OpenFeatureClass(string shpFile)
        {
            IFeatureClass result;
            FileInfo      fInfo = new FileInfo(shpFile);

            if (!System.IO.Directory.Exists(fInfo.DirectoryName))
            {
                result = null;
            }
            else
            {
                IWorkspace workspace = EngineAPI.OpenWorkspace(fInfo.DirectoryName, DataType.shp);
                if (workspace == null)
                {
                    result = null;
                }
                else
                {
                    IEnumDatasetName enumDatasetName = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
                    try
                    {
                        enumDatasetName.Reset();
                        IDatasetName datasetName;
                        while ((datasetName = enumDatasetName.Next()) != null)
                        {
                            if (fInfo.Name == (datasetName.Name + ".shp"))
                            {
                                break;
                            }
                        }
                        if (datasetName == null)
                        {
                            result = null;
                        }
                        else
                        {
                            IFeatureClass pFeatureClass = (datasetName as IName).Open() as IFeatureClass;
                            result = pFeatureClass;
                        }
                    }
                    finally
                    {
                        if (enumDatasetName != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(enumDatasetName);
                        }
                        if (workspace != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Opens the raster file.
        /// </summary>
        /// <param name="sPath">The s path.</param>
        /// <param name="sName">Name of the s.</param>
        /// <returns>IRasterDataset.</returns>
        public static IRasterDataset OpenRasterFile(string sPath, string sName)
        {
            IRasterDataset result;

            if (!System.IO.Directory.Exists(sPath))
            {
                result = null;
            }
            else
            {
                IWorkspace workspace = EngineAPI.OpenWorkspace(sPath, DataType.raster);
                if (workspace == null)
                {
                    result = null;
                }
                else
                {
                    IEnumDatasetName enumDatasetName = workspace.get_DatasetNames(esriDatasetType.esriDTRasterDataset);
                    try
                    {
                        enumDatasetName.Reset();
                        IDatasetName datasetName;
                        while ((datasetName = enumDatasetName.Next()) != null)
                        {
                            if (string.Equals(datasetName.Name, sName, System.StringComparison.OrdinalIgnoreCase))
                            {
                                break;
                            }
                        }
                        if (datasetName == null)
                        {
                            result = null;
                        }
                        else
                        {
                            IRasterDataset rasterDataset = (datasetName as IName).Open() as IRasterDataset;
                            result = rasterDataset;
                        }
                    }
                    finally
                    {
                        if (enumDatasetName != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(enumDatasetName);
                        }
                        if (workspace != null)
                        {
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 13
0
 /// <summary>
 ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IEnumDatasetName" />
 /// </summary>
 /// <param name="source">An <see cref="IEnumDatasetName" /> to create an <see cref="IEnumerable{T}" /> from.</param>
 /// <returns>An <see cref="IEnumerable{T}" /> that contains the datasets from the input source.</returns>
 public static IEnumerable <IDatasetName> AsEnumerable(this IEnumDatasetName source)
 {
     if (source != null)
     {
         source.Reset();
         IDatasetName datasetName;
         while ((datasetName = source.Next()) != null)
         {
             yield return(datasetName);
         }
     }
 }
Exemplo n.º 14
0
 public void FillTreeViewWithDatasetNames(IWorkspace iworkspace_1, TreeView treeView_0)
 {
     try
     {
         treeView_0.Nodes.Clear();
         if (iworkspace_1 != null)
         {
             TreeNode         node;
             IEnumDatasetName subsetNames;
             IDatasetName     name4;
             IEnumDatasetName name = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
             name.Reset();
             for (IDatasetName name2 = name.Next(); name2 != null; name2 = name.Next())
             {
                 node = new TreeNode(name2.Name)
                 {
                     Tag = name2.Name
                 };
                 treeView_0.Nodes.Add(node);
                 subsetNames = name2.SubsetNames;
                 subsetNames.Reset();
                 name4 = subsetNames.Next();
                 while (name4 != null)
                 {
                     if (name4.Type == esriDatasetType.esriDTFeatureClass)
                     {
                         TreeNode node2 = new TreeNode(name4.Name)
                         {
                             Tag = name4
                         };
                         node.Nodes.Add(node2);
                     }
                     name4 = subsetNames.Next();
                 }
             }
             subsetNames = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
             subsetNames.Reset();
             for (name4 = subsetNames.Next(); name4 != null; name4 = subsetNames.Next())
             {
                 node = new TreeNode(name4.Name)
                 {
                     Tag = name4.Name
                 };
                 treeView_0.Nodes.Add(node);
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 15
0
 private void method_2()
 {
     try
     {
         IEnumDatasetName subsetNames = this.idatasetName_0.SubsetNames;
         subsetNames.Reset();
         IDatasetName name2 = subsetNames.Next();
         IGxObject    obj2  = null;
         while (name2 != null)
         {
             obj2 = null;
             if (this.bool_0)
             {
                 if (AppConfigInfo.UserID == "admin")
                 {
                     obj2 = new GxDataset();
                 }
                 else if (AppConfigInfo.UserID.Length > 0)
                 {
                     if (this.sysGrants_0.GetStaffAndRolesLayerPri(AppConfigInfo.UserID, 1, name2.Name))
                     {
                         obj2 = new GxDataset();
                     }
                 }
                 else
                 {
                     obj2 = new GxDataset();
                 }
             }
             else
             {
                 obj2 = new GxDataset();
             }
             if (obj2 != null)
             {
                 (obj2 as IGxDataset).DatasetName = name2;
                 obj2.Attach(this, this.igxCatalog_0);
             }
             name2 = subsetNames.Next();
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "错误");
     }
 }
Exemplo n.º 16
0
        internal IFeatureClass RasterToPolygon(IRaster inputRaster, string outputName, string outputDir, bool smoothShapes)
        {
            IWorkspace    workspace    = SetupOp.OpenShapeFileWorkspace(outputDir);
            IConversionOp conversionOp = new RasterConversionOpClass();

            try
            {
                IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;

                //Delete any existing
                IEnumDatasetName datasets = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
                datasets.Reset();
                IDataset     existing    = null;
                IDatasetName datasetName = datasets.Next();
                while (datasetName != null)
                {
                    if (string.Compare(outputName, datasetName.Name, true) == 0)
                    {
                        existing = (IDataset)((IName)datasetName).Open();
                        break;
                    }
                    datasetName = datasets.Next();
                }
                if (existing != null)
                {
                    try
                    {
                        existing.Delete();
                    }
                    finally
                    {
                        UrbanDelineationExtension.ReleaseComObject(existing);
                    }
                }

                //Convert to polygon feature
                SetAnalysisEnvironment((IRasterAnalysisEnvironment)conversionOp);
                IGeoDataset polygons = conversionOp.RasterDataToPolygonFeatureData((IGeoDataset)inputRaster, workspace, outputName, smoothShapes);
                return((IFeatureClass)polygons);
            }
            finally
            {
                UrbanDelineationExtension.ReleaseComObject(workspace);
                UrbanDelineationExtension.ReleaseComObject(conversionOp);
            }
        }
Exemplo n.º 17
0
        private IEnumNameEdit getFCNames(IWorkspace wsp, String tabnames)
        {
            Log.p("get featureclass list...");
            IEnumNameEdit edtNames = new NamesEnumeratorClass();

            String[]         tabs      = tabnames.Split(',');
            int              numItems  = 0;
            IEnumDatasetName dsetNames = wsp.get_DatasetNames(
                esriDatasetType.esriDTFeatureClass);
            //esriDatasetType.esriDTFeatureDataset);

            IDatasetName dsetName = null;

            foreach (String t in tabs)
            {
                Log.p(String.Format("    tabname is [{0}]", t));
                dsetNames.Reset();
                while (true)
                {
                    dsetName = dsetNames.Next();
                    if (dsetName == null)
                    {
                        break;
                    }
                    //Log.p(String.Format("    check feature class name [{0}]", dsetName.Name));
                    if (t.ToUpper() == dsetName.Name.ToUpper())
                    {
                        Log.p(String.Format("    add feature class name [{0}]", dsetName.Name));
                        edtNames.Add((IName)dsetName);
                        numItems += 1;
                        break;
                    }
                }
                if (dsetName == null)
                {
                    Log.p(String.Format("Error, tabname [{0}] will not exported", t), "both");
                }
            }

            if (numItems != tabs.GetLength(0))
            {
                throw new ArgumentException("Can't find all of tables in gdb.");
            }
            return(edtNames);
        } // getFCNames
Exemplo n.º 18
0
 private void method_0(IDatasetName idatasetName_0, TreeNode treeNode_0)
 {
     try
     {
         IEnumDatasetName subsetNames = idatasetName_0.SubsetNames;
         subsetNames.Reset();
         for (IDatasetName name2 = subsetNames.Next(); name2 != null; name2 = subsetNames.Next())
         {
             TreeNode node = new TreeNode(name2.Name)
             {
                 Tag = (name2 as IName).Open()
             };
             treeNode_0.Nodes.Add(node);
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 19
0
        public static IEnumerable <IDatasetName> EnumerateDatasetNames(IEnumDatasetName enumDatasetNames, bool recursive)
        {
            if (enumDatasetNames != null)
            {
                enumDatasetNames.Reset();
                IDatasetName datasetName = enumDatasetNames.Next();
                while (datasetName != null)
                {
                    yield return(datasetName);

                    if (recursive && (datasetName.Type == esriDatasetType.esriDTFeatureDataset))
                    {
                        foreach (var subDatasetName in EnumerateDatasetNames(datasetName.SubsetNames, recursive))
                        {
                            yield return(subDatasetName);
                        }
                    }
                    datasetName = enumDatasetNames.Next();
                }
            }
        }
Exemplo n.º 20
0
        public static string Check(IEnumDatasetName edn, string feat_Name, string index)
        {
            edn.Reset();
            IDatasetName dsName = edn.Next();

            while (dsName != null)
            {
                if (dsName.Name.ToLower().Equals((feat_Name + index).ToLower()))
                {
                    if (index == string.Empty)
                    {
                        return(Check(edn, feat_Name, "1"));
                    }
                    else
                    {
                        return(Check(edn, feat_Name, (int.Parse(index) + 1).ToString()));
                    }
                }
                dsName = edn.Next();
            }
            return(feat_Name + index.ToString());
        }
Exemplo n.º 21
0
        /// <summary>
        /// Determines if a table exists within the specified workspace. <para/><b>Note</b> you should use <see cref="IWorkspace2.NameExists">IWorkspace2.NameExists</see>
        /// when working with workspaces other than a ShapefileWorkspace as it does not implement <see cref="IWorkspace2">IWorkspace2</see>.
        /// </summary>
        /// <param name="workspace">The workspace.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <returns></returns>
        public static bool TableExists(IWorkspace workspace, string tableName)
        {
            // Loop over all table dataset names in workspace
            IEnumDatasetName datasetNames = workspace.get_DatasetNames(esriDatasetType.esriDTTable);

            if (datasetNames == null)
            {
                return(false);
            }
            datasetNames.Reset();
            IDatasetName datasetName = datasetNames.Next();

            while (datasetName != null)
            {
                if (datasetName.Name.ToLower().Equals(tableName.ToLower()))
                {
                    return(true);
                }
                datasetName = datasetNames.Next();
            }
            return(false);
        }
Exemplo n.º 22
0
 private void method_0(IWorkspace iworkspace_1)
 {
     try
     {
         IEnumDatasetName name = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTAny);
         name.Reset();
         IDatasetName name2 = name.Next();
         IGxObject    obj2  = null;
         while (name2 != null)
         {
             obj2 = null;
             if ((name2.Type == esriDatasetType.esriDTRasterDataset) ||
                 (name2.Type == esriDatasetType.esriDTRasterCatalog))
             {
                 obj2 = new GxRasterDataset();
             }
             else if ((name2.Type == esriDatasetType.esriDTFeatureClass) ||
                      (name2.Type == esriDatasetType.esriDTTable))
             {
                 obj2 = new GxDataset();
             }
             else
             {
                 obj2 = new GxDataset();
             }
             if (obj2 != null)
             {
                 (obj2 as IGxDataset).DatasetName = name2;
                 obj2.Attach(this, this.igxCatalog_0);
             }
             name2 = name.Next();
         }
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
     }
 }
Exemplo n.º 23
0
 private void method_1()
 {
     try
     {
         IEnumDatasetName featureClassNames = (this.idatasetName_0 as IFeatureDatasetName2).FeatureClassNames;
         featureClassNames.Reset();
         IDatasetName name2 = featureClassNames.Next();
         IGxObject    obj2  = null;
         while (name2 != null)
         {
             obj2 = new GxCoverageDataset();
             if (obj2 != null)
             {
                 (obj2 as IGxDataset).DatasetName = name2;
                 obj2.Attach(this, this.igxCatalog_0);
             }
             name2 = featureClassNames.Next();
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "错误");
     }
 }
Exemplo n.º 24
0
        private bool CheckIfDatasetOrFeatureClass(string checkedName, esriDatasetType datasetType)
        {
            bool             checkedYes   = false;
            IWorkspace       workspace    = featureWorkspace as IWorkspace;
            IEnumDatasetName datasetNames = workspace.get_DatasetNames(datasetType);

            if (datasetNames == null)
            {
                return(false);
            }
            datasetNames.Reset();
            IDatasetName datasetName = datasetNames.Next();

            while (datasetName != null)
            {
                if (checkedName == datasetName.Name)
                {
                    checkedYes = true;
                    break;
                }
                datasetName = datasetNames.Next();
            }
            return(checkedYes);
        }
        public IRepresentationClass GetRepresentationClassForFeatureClass(IFeatureClass featureClass)
        {
            if (RepresentationWorkspaceExtension == null)
            {
                return(null);
            }

            IRepresentationClass repClass = null;

            IEnumDatasetName datasetNames = RepresentationWorkspaceExtension.get_FeatureClassRepresentationNames(featureClass);

            datasetNames.Reset();
            IDatasetName dsName;

            while ((dsName = datasetNames.Next()) != null)
            {
                string repName = dsName.Name;
                repClass = RepresentationWorkspaceExtension.OpenRepresentationClass(repName);
                // TODO: only gets first Rep Class set / assumes only one name/set
                break;
            }

            return(repClass);
        }
Exemplo n.º 26
0
        private void CoverageTicPropertyPage_Load(object sender, EventArgs e)
        {
            DataColumn column = new DataColumn("ID")
            {
                DataType = System.Type.GetType("System.Int32"),
                Caption  = "ID"
            };

            this.dataTable_0.Columns.Add(column);
            column = new DataColumn("X")
            {
                DataType = System.Type.GetType("System.Double"),
                Caption  = "X"
            };
            this.dataTable_0.Columns.Add(column);
            column = new DataColumn("Y")
            {
                DataType = System.Type.GetType("System.Double"),
                Caption  = "Y"
            };
            this.dataTable_0.Columns.Add(column);
            IEnumDatasetName featureClassNames = (this.icoverageName_0 as IFeatureDatasetName2).FeatureClassNames;

            featureClassNames.Reset();
            for (IDatasetName name2 = featureClassNames.Next(); name2 != null; name2 = featureClassNames.Next())
            {
                if ((name2 as ICoverageFeatureClassName).FeatureClassType == esriCoverageFeatureClassType.esriCFCTTic)
                {
                    this.idatasetName_0 = name2;
                    break;
                }
            }
            if (this.idatasetName_0 != null)
            {
                IFeatureClass class2 = (this.idatasetName_0 as IName).Open() as IFeatureClass;
                IEnvelope     extent = (class2 as IGeoDataset).Extent;
                if (extent.IsEmpty)
                {
                    this.txtMinX.Text = "-1";
                    this.txtMinY.Text = "-1";
                    this.txtMaxX.Text = "-1";
                    this.txtMaxY.Text = "-1";
                }
                else
                {
                    this.txtMinX.Text = extent.XMin.ToString();
                    this.txtMinY.Text = extent.YMin.ToString();
                    this.txtMaxX.Text = extent.XMax.ToString();
                    this.txtMaxY.Text = extent.YMax.ToString();
                }
                IFeatureCursor cursor = class2.Search(null, false);
                int            index  = class2.Fields.FindField("IDTIC");
                int            num3   = class2.Fields.FindField("XTIC");
                int            num4   = class2.Fields.FindField("YTIC");
                for (IFeature feature = cursor.NextFeature(); feature != null; feature = cursor.NextFeature())
                {
                    DataRow row = this.dataTable_0.NewRow();
                    row[0] = feature.get_Value(index);
                    row[1] = feature.get_Value(num3);
                    row[2] = feature.get_Value(num4);
                    this.dataTable_0.Rows.Add(row);
                }
                class2     = null;
                this.int_0 = this.dataTable_0.Rows.Count;
            }
        }
Exemplo n.º 27
0
        internal IFeatureClass CreateShapefile(string path, string name, esriGeometryType geometryType, ISpatialReference spatialRef, string idFieldName)
        {
            const string SHAPE_FIELD = "Shape";

            IFeatureClass shapeFile = null;
            IWorkspace    workspace = null;

            try
            {
                workspace = OpenShapeFileWorkspace(path);
                IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;

                //Delete any existing
                IEnumDatasetName datasets = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
                datasets.Reset();
                IDataset     existing    = null;
                IDatasetName datasetName = datasets.Next();
                while (datasetName != null)
                {
                    if (string.Compare(name, datasetName.Name, true) == 0)
                    {
                        existing = (IDataset)((IName)datasetName).Open();
                        break;
                    }
                    datasetName = datasets.Next();
                }
                if (existing != null)
                {
                    try
                    {
                        existing.Delete();
                    }
                    finally
                    {
                        UrbanDelineationExtension.ReleaseComObject(existing);
                    }
                }

                //Get elements to create a new table/feature class
                IFieldsEdit fields = new FieldsClass();

                IGeometryDefEdit geometryDef = new GeometryDefClass();
                geometryDef.GeometryType_2     = geometryType;
                geometryDef.SpatialReference_2 = spatialRef;

                IFieldEdit shapeField = new FieldClass();
                shapeField.Name_2        = SHAPE_FIELD;
                shapeField.Type_2        = esriFieldType.esriFieldTypeGeometry;
                shapeField.GeometryDef_2 = geometryDef;
                fields.AddField(shapeField);

                IFieldEdit eidField = new FieldClass();
                eidField.Name_2   = idFieldName;
                eidField.Type_2   = esriFieldType.esriFieldTypeInteger;
                eidField.Length_2 = 16;
                fields.AddField(eidField as IField);

                //Create feature class
                shapeFile = featureWorkspace.CreateFeatureClass(name, fields, null, null, esriFeatureType.esriFTSimple, SHAPE_FIELD, null);
            }
            finally
            {
                UrbanDelineationExtension.ReleaseComObject(workspace);
            }

            return(shapeFile);
        }
Exemplo n.º 28
0
 private void method_0(IWorkspace iworkspace_1)
 {
     try
     {
         IEnumDatasetName name = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTAny);
         name.Reset();
         IDatasetName name2 = name.Next();
         IGxObject    obj2  = null;
         while (name2 != null)
         {
             obj2 = null;
             if (this.IsEnterpriseGeodatabase)
             {
                 if ((name2.Type == esriDatasetType.esriDTRasterDataset) ||
                     (name2.Type == esriDatasetType.esriDTRasterCatalog))
                 {
                     obj2 = new GxRasterDataset();
                 }
                 else if ((name2.Type == esriDatasetType.esriDTFeatureClass) ||
                          (name2.Type == esriDatasetType.esriDTTable))
                 {
                     if (AppConfigInfo.UserID.Length > 0)
                     {
                         if (AppConfigInfo.UserID.ToLower() == "admin")
                         {
                             obj2 = new GxDataset();
                         }
                         else if (this.sysGrants_0 != null)
                         {
                             if (this.sysGrants_0.GetStaffAndRolesLayerPri(AppConfigInfo.UserID, 1, name2.Name))
                             {
                                 obj2 = new GxDataset();
                             }
                         }
                         else
                         {
                             obj2 = new GxDataset();
                         }
                     }
                     else
                     {
                         obj2 = new GxDataset();
                     }
                 }
                 else
                 {
                     obj2 = new GxDataset();
                 }
                 if (obj2 != null)
                 {
                     (obj2 as IGxDataset).DatasetName = name2;
                     obj2.Attach(this, this.igxCatalog_0);
                 }
             }
             else
             {
                 if ((name2.Type == esriDatasetType.esriDTRasterDataset) ||
                     (name2.Type == esriDatasetType.esriDTRasterCatalog))
                 {
                     obj2 = new GxRasterDataset();
                 }
                 else if ((name2.Type == esriDatasetType.esriDTFeatureClass) ||
                          (name2.Type == esriDatasetType.esriDTTable))
                 {
                     obj2 = new GxDataset();
                 }
                 else
                 {
                     obj2 = new GxDataset();
                 }
                 if (obj2 != null)
                 {
                     (obj2 as IGxDataset).DatasetName = name2;
                     obj2.Attach(this, this.igxCatalog_0);
                 }
             }
             name2 = name.Next();
         }
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
     }
 }
Exemplo n.º 29
0
        public static IDatasetName RAS_META_TABLE = null; //栅格元数据表



        //初始化,得到所有数据name
        public static void init()
        {
            vec_workspace = OpenFileGdbWorkspace(DbPath, vecDbName);
            ras_workspace = OpenFileGdbWorkspace(DbPath, rasDbName);
            doc_workspace = OpenFileGdbWorkspace(DbPath, docDbName);

            if (vec_workspace == null || ras_workspace == null || doc_workspace == null)
            {
                MessageBox.Show("workspace == null");
                return;
            }
            //1 vec
            IEnumDatasetName vec_datasetNames = vec_workspace.get_DatasetNames(esriDatasetType.esriDTTable);

            vec_datasetNames.Reset();
            IDatasetName vec_ids = vec_datasetNames.Next() as IDatasetName;

            while (vec_ids is IDatasetName)
            {
                if (vec_ids.Name.Equals("VEC_TABLE"))
                {
                    VEC_TABLE = vec_ids;
                }
                else if (vec_ids.Name.Equals("VEC_META_TABLE"))
                {
                    VEC_META_TABLE = vec_ids;
                }
                vec_ids = vec_datasetNames.Next() as IDatasetName;
            }
            vec_datasetNames.Reset();
            //2 ras
            IEnumDatasetName ras_datasetNames = ras_workspace.get_DatasetNames(esriDatasetType.esriDTTable);

            ras_datasetNames.Reset();
            IDatasetName ras_ids = ras_datasetNames.Next() as IDatasetName;

            while (ras_ids is IDatasetName)
            {
                if (ras_ids.Name.Equals("RAS_TABLE"))
                {
                    RAS_TABLE = ras_ids;
                }
                else if (ras_ids.Name.Equals("RAS_META_TABLE"))
                {
                    RAS_META_TABLE = ras_ids;
                }
                ras_ids = ras_datasetNames.Next() as IDatasetName;
            }
            ras_datasetNames.Reset();
            //3 doc
            IEnumDatasetName doc_datasetNames = doc_workspace.get_DatasetNames(esriDatasetType.esriDTTable);

            doc_datasetNames.Reset();
            IDatasetName ids = doc_datasetNames.Next() as IDatasetName;

            while (ids is IDatasetName)
            {
                if (ids.Name.Equals("USER_TABLE"))
                {
                    USER_TABLE = ids;
                }
                else if (ids.Name.Equals("DOC_TABLE"))
                {
                    DOC_TABLE = ids;
                }
                ids = doc_datasetNames.Next() as IDatasetName;
            }
            doc_datasetNames.Reset();
            if (DOC_TABLE == null || USER_TABLE == null || RAS_META_TABLE == null || RAS_TABLE == null || VEC_META_TABLE == null || VEC_TABLE == null)
            {
                MessageBox.Show("table == null");
                return;
            }
            return;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Adds the feature class to ListBox.
        /// </summary>
        /// <param name="pEnumDatasetName">Name of the p enum dataset.</param>
        /// <param name="imageListBoxControl1">The image ListBox control1.</param>
        /// <param name="dataType">Type of the data.</param>
        /// <param name="geometryType">Type of the geometry.</param>
        public static void AddFeatureClassToListBox(IEnumDatasetName pEnumDatasetName, ImageListBoxControl imageListBoxControl1, DataType dataType, esriGeometryType geometryType)
        {
            if (pEnumDatasetName != null)
            {
                IconType value  = IconType.PGDBAnnotation;
                IconType value2 = IconType.PGDBPoint;
                IconType value3 = IconType.PGDBLine;
                IconType value4 = IconType.PGDBPolygon;
                if (dataType <= DataType.gdb)
                {
                    if (dataType != DataType.shp)
                    {
                        if (dataType == DataType.gdb)
                        {
                            value  = IconType.FGDBAnnotation;
                            value2 = IconType.FGDBPoint;
                            value3 = IconType.FGDBLine;
                            value4 = IconType.FGDBPolygon;
                        }
                    }
                    else
                    {
                        value2 = IconType.ShpPoint;
                        value3 = IconType.ShpLine;
                        value4 = IconType.ShpPolygon;
                    }
                }
                else if (dataType != DataType.sde)
                {
                    if (dataType != DataType.cad)
                    {
                        if (dataType == DataType.coverage)
                        {
                            value  = IconType.CovAnnotation;
                            value2 = IconType.CovPoint;
                            value3 = IconType.CovArc;
                            value4 = IconType.CovPolygon;
                        }
                    }
                    else
                    {
                        value  = IconType.CadAnnotation;
                        value2 = IconType.CadPoint;
                        value3 = IconType.CadLine;
                        value4 = IconType.CadPolygon;
                    }
                }
                else
                {
                    value  = IconType.SDEAnnotation;
                    value2 = IconType.SDEPoint;
                    value3 = IconType.SDELine;
                    value4 = IconType.SDEPolygon;
                }
                SortedDictionary <string, IconType> sortedDictionary = new SortedDictionary <string, IconType>();
                try
                {
                    pEnumDatasetName.Reset();
                    IDatasetName datasetName;
                    while ((datasetName = pEnumDatasetName.Next()) != null)
                    {
                        IFeatureClassName featureClassName = datasetName as IFeatureClassName;
                        if (featureClassName != null)
                        {
                            if (geometryType == esriGeometryType.esriGeometryAny || geometryType == featureClassName.ShapeType)
                            {
                                if (featureClassName.FeatureType == esriFeatureType.esriFTAnnotation || featureClassName.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                                {
                                    sortedDictionary.Add(datasetName.Name, value);
                                }
                                else if (featureClassName.FeatureType == esriFeatureType.esriFTSimple)
                                {
                                    switch (featureClassName.ShapeType)
                                    {
                                    case esriGeometryType.esriGeometryPoint:
                                    case esriGeometryType.esriGeometryMultipoint:
                                        sortedDictionary.Add(datasetName.Name, value2);
                                        break;

                                    case esriGeometryType.esriGeometryPolyline:
                                        sortedDictionary.Add(datasetName.Name, value3);
                                        break;

                                    case esriGeometryType.esriGeometryPolygon:
                                        sortedDictionary.Add(datasetName.Name, value4);
                                        break;

                                    case esriGeometryType.esriGeometryMultiPatch:
                                        sortedDictionary.Add(datasetName.Name, IconType.CadMultiPatch);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(pEnumDatasetName);
                }
                foreach (KeyValuePair <string, IconType> current in sortedDictionary)
                {
                    ControlAPI.AddItemToListBox(current.Value, current.Key, imageListBoxControl1);
                }
            }
        }