コード例 #1
0
        public void btnExecute_Click(object sender, EventArgs e)
        {
            string tblNm = txtOutNm.Text;

            if (tblNm == null || tblNm == "")
            {
                MessageBox.Show("You must specify a output name", "No Output", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (lsbRaster.Items.Count < 1)
            {
                MessageBox.Show("You must select at least on Raster", "No Rasters", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IRasterBandCollection rsBc = new RasterClass();

            for (int i = 0; i < lsbRaster.Items.Count; i++)
            {
                rsBc.AppendBands((IRasterBandCollection)rstDic[lsbRaster.Items[i].ToString()]);
            }
            this.Visible = false;
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Building Raster Attribute Table. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            rp.Show();
            try
            {
                string                 outDbStr = geoUtil.getDatabasePath(tblNm);
                string                 outName  = System.IO.Path.GetFileNameWithoutExtension(tblNm);
                IWorkspace             wks      = geoUtil.OpenWorkSpace(outDbStr);
                IFunctionRasterDataset fDset    = rsUtil.compositeBandFunction(rsBc);
                outtbl            = rsUtil.calcCombinRasterFunctionTable(fDset, wks, outName);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                rp.addMessage(ex.ToString());
            }
            finally
            {
                DateTime dt2 = DateTime.Now;
                TimeSpan ts  = dt2.Subtract(dt);
                string   t   = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds .";
                rp.stepPGBar(100);
                rp.addMessage("Finished creating attribute table");
                rp.enableClose();
                this.Close();
            }
        }
コード例 #2
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;
        }
コード例 #3
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;
        }