Esempio n. 1
0
        private void getFeaturePath()
        {
            string outPath = null;
            string outName = "";

            ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
            gxDialog.AllowMultiSelect = false;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt = null;
            flt = new ESRI.ArcGIS.Catalog.GxFilterPointFeatureClassesClass();
            gxDialog.ObjectFilter = flt;
            gxDialog.Title        = "Select a Feature";
            ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
            if (gxDialog.DoModalOpen(0, out eGxObj))
            {
                ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
                outPath = gxObj.FullName;
                outName = gxObj.BaseName;
                if (!ftrDic.ContainsKey(outName))
                {
                    ftrDic.Add(outName, geoUtil.getFeatureClass(outPath));
                    cmbSampleFeatureClass.Items.Add(outName);
                }
                else
                {
                    ftrDic[outName] = geoUtil.getFeatureClass(outPath);
                }
                cmbSampleFeatureClass.SelectedItem = outName;
            }
            return;
        }
Esempio n. 2
0
        private void getFeaturePath(bool featureClass)
        {
            string outPath = null;
            string outName = "";

            ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
            gxDialog.AllowMultiSelect = false;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt = null;
            if (featureClass)
            {
                flt = new ESRI.ArcGIS.Catalog.GxFilterGeoDatasetsClass();//.GxFilterPolygonFeatureClassesClass();
            }
            else
            {
                flt = new ESRI.ArcGIS.Catalog.GxFilterRasterDatasetsClass();
            }
            gxDialog.ObjectFilter = flt;
            gxDialog.Title        = "Select a Feature";
            ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
            if (gxDialog.DoModalOpen(0, out eGxObj))
            {
                ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
                outPath = gxObj.FullName;
                outName = gxObj.BaseName;
                if (featureClass)
                {
                    if (!ftrDic.ContainsKey(outName))
                    {
                        ftrDic.Add(outName, geoUtil.getFeatureClass(outPath));
                        cmbSampleFeatureClass.Items.Add(outName);
                    }
                    else
                    {
                        ftrDic[outName] = geoUtil.getFeatureClass(outPath);
                    }
                    cmbSampleFeatureClass.Text = outName;
                }
                else
                {
                    if (!rstDic.ContainsKey(outName))
                    {
                        rstDic.Add(outName, rsUtil.returnRaster(outPath));
                        cmbRaster.Items.Add(outName);
                    }
                    else
                    {
                        rstDic[outName] = rsUtil.returnRaster(outPath);
                    }
                    cmbRaster.Text = outName;
                }
            }
            return;
        }
Esempio n. 3
0
        private void getRasterOrFeaturePath()
        {
            string outPath = null;
            string outName = "";

            ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
            ESRI.ArcGIS.Catalog.IGxObjectFilterCollection fltColl = (ESRI.ArcGIS.Catalog.IGxObjectFilterCollection)gxDialog;
            gxDialog.AllowMultiSelect = false;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt  = new ESRI.ArcGIS.Catalog.GxFilterRasterDatasetsClass();
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt2 = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClassesClass();
            fltColl.AddFilter(flt, true);
            fltColl.AddFilter(flt2, false);
            gxDialog.Title = "Select a Raster Polygon Dataset";
            ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
            if (gxDialog.DoModalOpen(0, out eGxObj))
            {
                ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
                while (gxObj != null)
                {
                    outPath = gxObj.FullName;
                    outName = gxObj.BaseName;
                    if (gxDialog.ObjectFilter is ESRI.ArcGIS.Catalog.GxFilterRasterDatasetsClass)
                    {
                        IRaster rs = rsUtil.returnRaster(outPath);
                        if (!rstDic.ContainsKey(outName))
                        {
                            rstDic.Add(outName, rs);
                            cmbStrata.Items.Add(outName);
                        }
                        else
                        {
                            rstDic[outName] = rs;
                        }
                    }
                    else
                    {
                        IFeatureClass ftrCls = geoUtil.getFeatureClass(outPath);
                        if (!ftrDic.ContainsKey(outName))
                        {
                            ftrDic.Add(outName, ftrCls);
                            cmbStrata.Items.Add(outName);
                        }
                        else
                        {
                            ftrDic[outName] = ftrCls;
                        }
                    }
                    gxObj = eGxObj.Next();
                }
                cmbStrata.SelectedItem = outName;
            }
            return;
        }
Esempio n. 4
0
        private string getFeatureOrRasterClass(ESRI.ArcGIS.Catalog.GxFilterDatasetsAndLayersClass flt)
        {
            string[]      nm;
            string        ftrPath = frmHlp.getPath(flt, out nm, false)[0];
            IFeatureClass oFtr    = geoUtil.getFeatureClass(ftrPath);

            if (oFtr == null)
            {
                frmHlp.FunctionRasterDictionary[nm[0]] = rsUtil.createIdentityRaster(ftrPath);
            }
            else
            {
                frmHlp.FeatureDictionary[nm[0]] = oFtr;
            }

            return(nm[0]);
        }
Esempio n. 5
0
 private void btnROI_Click(object sender, EventArgs e)
 {
     ESRI.ArcGIS.Catalog.IGxObjectFilter flt = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClassesClass();
     ftrClsPath = frmHelper.getPath(flt, out ftrClsName)[0];
     frmHelper.FeatureDictionary[ftrClsName[0]] = geoUtil.getFeatureClass(ftrClsPath);
     cmbROI.Items.Add(ftrClsName[0]);
     cmbROI.SelectedItem = ftrClsName[0];
 }
Esempio n. 6
0
        private void btnInFtrCls_Click(object sender, EventArgs e)
        {
            string[] nm;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClasses();
            string outPath = frmHlp.getPath(flt, out nm)[0];

            cmbInFtrCls.Items.Add(nm[0]);
            frmHlp.FeatureDictionary[nm[0]] = geoUtil.getFeatureClass(outPath);
            cmbInFtrCls.Text = nm[0];
        }
Esempio n. 7
0
        private void btnFtrCls_Click(object sender, EventArgs e)
        {
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClassesClass();
            string[] nm;
            string   ftrPath = frmHlp.getPath(flt, out nm, false)[0];

            ftrDic[nm[0]] = geoUtil.getFeatureClass(ftrPath);
            cmbFtrCls.Items.Add(nm);
            cmbFtrCls.SelectedItem = nm;
        }
Esempio n. 8
0
 private void btnOpenFeatureClass_Click(object sender, EventArgs e)
 {
     ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
     gxDialog.AllowMultiSelect = false;
     ESRI.ArcGIS.Catalog.IGxObjectFilter flt = null;
     flt = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClassesClass();
     gxDialog.ObjectFilter = flt;
     gxDialog.Title        = "Select a RCZ Layer";
     ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
     if (gxDialog.DoModalOpen(0, out eGxObj))
     {
         ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
         string        nm     = gxObj.Name;
         IFeatureClass ftrCls = geoUtil.getFeatureClass(gxObj.FullName);
         ftrDic.Add(nm, ftrCls);
         cmbInFeatureClass.Items.Add(nm);
         cmbInFeatureClass.SelectedItem = nm;
     }
 }
Esempio n. 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClassesClass();
            string[] outName;
            string   outPath = frmHlp.getPath(flt, out outName, false)[0];

            frmHlp.FeatureDictionary[outName[0]] = geoUtil.getFeatureClass(outPath);
            cmbFtrCls.Items.Add(outName[0]);
            cmbFtrCls.SelectedItem = outName[0];
        }
Esempio n. 10
0
 private void btnSample_Click(object sender, EventArgs e)
 {
     ESRI.ArcGIS.Catalog.IGxObjectFilter flt = new ESRI.ArcGIS.Catalog.GxFilterPointFeatureClassesClass();
     string[] flNames;
     string[] flPath = frmHlp.getPath(flt, out flNames, false);
     if (flPath.Length > 0)
     {
         cmbSample.Items.Add(flNames[0]);
         ESRI.ArcGIS.Geodatabase.IFeatureClass ftrCls = geoUtil.getFeatureClass(flPath[0]);
         frmHlp.FeatureDictionary.Add(flNames[0], ftrCls);
         cmbSample.SelectedItem = flNames[0];
     }
 }
Esempio n. 11
0
        private void btnOpenTable_Click(object sender, EventArgs e)
        {
            ComboBox cmb = cmbStrata;

            if (((Button)sender).Name.ToLower().Contains("stands"))
            {
                cmb = cmbStands;
            }
            string outPath = null;
            string outName = "";

            ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
            ESRI.ArcGIS.Catalog.IGxObjectFilterCollection fltColl = (ESRI.ArcGIS.Catalog.IGxObjectFilterCollection)gxDialog;
            gxDialog.AllowMultiSelect = false;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt2 = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClassesClass();
            fltColl.AddFilter(flt2, false);
            gxDialog.Title = "Select a Feature Class";
            ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
            if (gxDialog.DoModalOpen(0, out eGxObj))
            {
                ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
                while (gxObj != null)
                {
                    outPath = gxObj.FullName;
                    outName = gxObj.BaseName;


                    IFeatureClass ftrCls = geoUtil.getFeatureClass(outPath);//need to check if this works for feature classes
                    if (!ftrDic.ContainsKey(outName))
                    {
                        ftrDic.Add(outName, ftrCls);
                        cmb.Items.Add(outName);
                    }
                    else
                    {
                        ftrDic[outName] = ftrCls;
                    }

                    gxObj = eGxObj.Next();
                }
                cmb.SelectedItem = outName;
            }
            return;
        }
Esempio n. 12
0
        /// <summary>
        /// adds a layer to the active view
        /// </summary>
        /// <param name="path">full path name</param>
        /// <returns>Ilayer</returns>
        public ILayer addLayer(string path)
        {
            IMap map = (IMap)acView;
            geoDatabaseUtility geoUtil = new geoDatabaseUtility();
            esriDatasetType    dType   = geoUtil.getDataType(path);
            ILayer             lyr     = null;

            switch (dType)
            {
            case esriDatasetType.esriDTFeatureClass:
                IFeatureLayer ftrLayer = new FeatureLayerClass();
                ftrLayer.FeatureClass = geoUtil.getFeatureClass(path);
                lyr      = (ILayer)ftrLayer;
                lyr.Name = ftrLayer.FeatureClass.AliasName;
                map.AddLayer(lyr);
                break;

            case esriDatasetType.esriDTRasterBand:
            case esriDatasetType.esriDTRasterCatalog:
            case esriDatasetType.esriDTRasterDataset:
                IRasterLayer rasterLayer = new RasterLayerClass();
                rasterLayer.CreateFromDataset(geoUtil.getRasterDataset(path));
                rasterLayer.Name = rasterLayer.Name;
                map.AddLayer((ILayer)rasterLayer);
                break;

            case esriDatasetType.esriDTTable:
                ITable           tbl             = geoUtil.getTable(path);
                ITableCollection tableCollection = (ITableCollection)map;
                tableCollection.AddTable(tbl);
                break;

            default:
                break;
            }
            acView.Refresh();
            return(lyr);
        }
Esempio n. 13
0
        private static void CreateNewPoints(string inPath, string outPath, rasterUtil rsUtil, featureUtil ftrUtil, geoDatabaseUtility geoUtil, bool prnd = true, int cShift = 5)
        {
            IFeatureClass  ftrCls    = geoUtil.getFeatureClass(inPath);
            IFeatureClass  newFtrCls = ftrUtil.exportFeatures(ftrCls, outPath, null);
            IFeatureCursor uCur      = newFtrCls.Update(null, true);
            IFeature       ftr       = uCur.NextFeature();

            if (prnd)
            {
                System.Random rnd = new Random();
                while (ftr != null)
                {
                    IPoint opnt = (IPoint)ftr.ShapeCopy;
                    IPoint pnt  = new PointClass();
                    double rndx = rnd.NextDouble() * 10;
                    double rndy = rnd.NextDouble() * 10;
                    pnt.PutCoords(opnt.X + rndx, opnt.Y + rndy);
                    ftr.Shape = pnt;
                    uCur.UpdateFeature(ftr);
                    ftr = uCur.NextFeature();
                }
            }
            else
            {
                while (ftr != null)
                {
                    IPoint opnt = (IPoint)ftr.ShapeCopy;
                    IPoint pnt  = new PointClass();
                    pnt.PutCoords(opnt.X + cShift, opnt.Y + cShift);
                    ftr.Shape = pnt;
                    uCur.UpdateFeature(ftr);
                    ftr = uCur.NextFeature();
                }
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(uCur);
        }
Esempio n. 14
0
        private void getPath(bool isRaster)
        {
            string outPath = null;
            string outName = "";

            ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
            gxDialog.AllowMultiSelect = false;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt = null;
            if (isRaster)
            {
                flt = new ESRI.ArcGIS.Catalog.GxFilterDatasetsClass();
            }
            else
            {
                flt = new ESRI.ArcGIS.Catalog.GxFilterFileGeodatabasesClass();
            }
            gxDialog.ObjectFilter = flt;
            gxDialog.Title        = "Select a Feature";
            ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
            if (gxDialog.DoModalOpen(0, out eGxObj))
            {
                ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
                outPath = gxObj.FullName;
                outName = gxObj.BaseName;
                if (isRaster)
                {
                    string           wksPath    = geoUtil.getDatabasePath(outPath);
                    IWorkspace       wks        = geoUtil.OpenWorkSpace(wksPath);
                    IEnumDatasetName rsDsetName = wks.get_DatasetNames(esriDatasetType.esriDTRasterDataset);
                    bool             rsCheck    = false;
                    IDatasetName     dsName     = rsDsetName.Next();
                    while (dsName != null)
                    {
                        if (outName.ToLower() == dsName.Name.ToLower())
                        {
                            rsCheck = true;
                            break;
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(dsName);
                        dsName = rsDsetName.Next();
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rsDsetName);
                    if (rsCheck)
                    {
                        if (!rstDic.ContainsKey(outName))
                        {
                            rstDic.Add(outName, rsUtil.createIdentityRaster(outPath));
                            cmbRst.Items.Add(outName);
                        }
                        else
                        {
                            rstDic[outName] = rsUtil.createIdentityRaster(outPath);
                        }
                    }
                    else
                    {
                        ftrDic[outName] = geoUtil.getFeatureClass(outPath);
                    }
                    cmbRst.Text = outName;
                }
                else
                {
                    txtOutWorkspace.Text = outPath;
                }
            }
            return;
        }
Esempio n. 15
0
        private void getFeaturePath(bool featureClass)
        {
            string outPath = null;
            string outName = "";

            ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
            gxDialog.AllowMultiSelect = false;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt = null;
            if (featureClass)
            {
                flt = new ESRI.ArcGIS.Catalog.GxFilterPointFeatureClassesClass();
            }
            else
            {
                flt = new ESRI.ArcGIS.Catalog.GxFilterDatasets();
            }
            gxDialog.ObjectFilter = flt;
            gxDialog.Title        = "Select";
            ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
            if (gxDialog.DoModalOpen(0, out eGxObj))
            {
                ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
                outPath = gxObj.FullName;
                outName = gxObj.BaseName;
                if (featureClass)
                {
                    ftrDic[outName] = geoUtil.getFeatureClass(outPath);
                    cmbSampleFeatureClass.Items.Add(outName);
                    cmbSampleFeatureClass.Text = outName;
                }
                else
                {
                    string       wksPath = geoUtil.getDatabasePath(outPath);
                    IWorkspace   wks     = geoUtil.OpenWorkSpace(wksPath);
                    IEnumDataset rsDset  = wks.get_Datasets(esriDatasetType.esriDTAny);
                    bool         rsCheck = false;
                    IDataset     ds      = rsDset.Next();
                    while (ds != null)
                    {
                        if (outName.ToLower() == ds.Name.ToLower() && (ds.Type == esriDatasetType.esriDTMosaicDataset || ds.Type == esriDatasetType.esriDTRasterDataset || ds.Type == esriDatasetType.esriDTRasterCatalog))
                        {
                            rsCheck = true;
                            break;
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(ds);
                        ds = rsDset.Next();
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(rsDset);
                    if (rsCheck)
                    {
                        rstDic[outName] = rsUtil.createIdentityRaster(outPath);
                        cmbRaster.Items.Add(outName);
                        cmbRaster.Text = outName;
                    }
                    else
                    {
                        ftrDic[outName] = geoUtil.getFeatureClass(outPath);
                        cmbRaster.Items.Add(outName);
                        cmbRaster.Text = outName;
                    }
                }
            }
            return;
        }
Esempio n. 16
0
        private void getLayer()
        {
            string outPath = null;
            string outName = "";

            ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass();
            ESRI.ArcGIS.Catalog.IGxObjectFilterCollection fltColl = (ESRI.ArcGIS.Catalog.IGxObjectFilterCollection)gxDialog;
            gxDialog.AllowMultiSelect = true;
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt  = new ESRI.ArcGIS.Catalog.GxFilterRasterDatasetsClass();
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt2 = new ESRI.ArcGIS.Catalog.GxFilterPolygonFeatureClassesClass();
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt3 = new ESRI.ArcGIS.Catalog.GxFilterPointFeatureClassesClass();
            ESRI.ArcGIS.Catalog.IGxObjectFilter flt4 = new ESRI.ArcGIS.Catalog.GxFilterTablesClass();
            fltColl.AddFilter(flt, true);
            fltColl.AddFilter(flt2, false);
            fltColl.AddFilter(flt3, false);
            fltColl.AddFilter(flt4, false);
            gxDialog.Title = "Select a Raster, Polygon, Point, or Table";
            ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj;
            if (gxDialog.DoModalOpen(0, out eGxObj))
            {
                ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next();
                while (gxObj != null)
                {
                    outPath = gxObj.FullName;
                    outName = gxObj.BaseName;
                    if (gxDialog.ObjectFilter is ESRI.ArcGIS.Catalog.GxFilterRasterDatasetsClass)
                    {
                        IFunctionRasterDataset rs = rsUtil.createIdentityRaster(outPath);
                        if (!rstDic.ContainsKey(outName))
                        {
                            rstDic.Add(outName, rs);
                        }
                        else
                        {
                            rstDic[outName] = rs;
                        }
                    }
                    else if (gxDialog.ObjectFilter is ESRI.ArcGIS.Catalog.GxFilterTablesClass)
                    {
                        ITable tbl = geoUtil.getTable(outPath);
                        if (!tblDic.ContainsKey(outName))
                        {
                            tblDic.Add(outName, tbl);
                        }
                        else
                        {
                            tblDic[outName] = tbl;
                        }
                    }
                    else
                    {
                        IFeatureClass ftrCls = geoUtil.getFeatureClass(outPath);
                        if (!ftrDic.ContainsKey(outName))
                        {
                            ftrDic.Add(outName, ftrCls);
                        }
                        else
                        {
                            ftrDic[outName] = ftrCls;
                        }
                    }
                    if (!lyrDic.ContainsKey(outName))
                    {
                        lyrDic.Add(outName, outPath);
                        lsbLayers.Items.Add(outName);
                    }
                    else
                    {
                        lyrDic[outName] = outPath;
                    }
                    gxObj = eGxObj.Next();
                }
            }
            return;
        }