public void Bind(object pArgument)
 {
     if (pArgument is LandscapeFunctionArguments)
     {
         LandscapeFunctionArguments args = (LandscapeFunctionArguments)pArgument;
         inrs = args.InRaster;
         orig = args.OriginalRaster;
         inop = args.Operation;
         landType = args.LandscapeType;
         inWindow = args.WindowType;
         clms = args.Columns;
         rws = args.Rows;
         radius = args.Radius;
         myFunctionHelper.Bind(inrs);
         myFunctionHelperCoef.Bind(orig);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype = myRasterInfo.PixelType;
         myValidFlag = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: FocalFunctonArguments");
     }
 }
예제 #2
0
 public void Bind(object pArgument)
 {
     if (pArgument is LandscapeFunctionArguments)
     {
         LandscapeFunctionArguments args = (LandscapeFunctionArguments)pArgument;
         inrs     = args.InRaster;
         orig     = args.OriginalRaster;
         inop     = args.Operation;
         landType = args.LandscapeType;
         inWindow = args.WindowType;
         clms     = args.Columns;
         rws      = args.Rows;
         radius   = args.Radius;
         myFunctionHelper.Bind(inrs);
         myFunctionHelperCoef.Bind(orig);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype  = myRasterInfo.PixelType;
         myValidFlag  = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: FocalFunctonArguments");
     }
 }
예제 #3
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string inRst1Nm       = cmbRaster.Text;
            string inFocalStat    = cmbFocalStat.Text;
            string windowType     = cmbWindowType.Text;
            string landMetricType = cmbMetric.Text;
            string outNmRst       = txtOutName.Text;
            int    clms           = System.Convert.ToInt32(nudColumns.Value);
            int    rws            = System.Convert.ToInt32(nudRows.Value);

            if (inRst1Nm == "" || inRst1Nm == null)
            {
                MessageBox.Show("You must specify an input raster for In Raster 1 or type in a number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (inFocalStat == "" || inFocalStat == null)
            {
                MessageBox.Show("You must specify an Focal Statistic", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (windowType == "" || windowType == null)
            {
                MessageBox.Show("You must select a widow type from dropdown menu", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (landMetricType == "" || landMetricType == null)
            {
                MessageBox.Show("You must select a metric type from dropdown menu", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (outNmRst == "" || outNmRst == null)
            {
                MessageBox.Show("You must specify an output raster name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            IRaster rs1   = rstDic[inRst1Nm];
            IRaster outRs = null;

            rasterUtil.windowType wdType = (rasterUtil.windowType)Enum.Parse(typeof(rasterUtil.windowType), windowType);

            rasterUtil.landscapeType lcType = (rasterUtil.landscapeType)Enum.Parse(typeof(rasterUtil.landscapeType), landMetricType);
            rasterUtil.focalType     fcType = (rasterUtil.focalType)Enum.Parse(typeof(rasterUtil.focalType), inFocalStat);
            esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false);
            DateTime dt = DateTime.Now;

            rp.addMessage("Creating Raster. This may take a while...");
            rp.stepPGBar(10);
            rp.TopMost = true;
            try
            {
                if (wdType == rasterUtil.windowType.CIRCLE)
                {
                    outRs = rsUtil.createRaster(rsUtil.calcLandscapeFunction(rs1, clms, fcType, lcType));
                }
                else
                {
                    outRs = rsUtil.createRaster(rsUtil.calcLandscapeFunction(rs1, clms, rws, fcType, lcType));
                }
                outraster     = outRs;
                outrastername = outNmRst;
                if (mp != null && addToMap)
                {
                    rp.addMessage("Estimating Statistics...");
                    rp.Show();
                    rp.Refresh();
                    IRasterLayer rsLyr = new RasterLayerClass();
                    //rsUtil.calcStatsAndHist
                    rsLyr.CreateFromRaster(outraster);
                    rsLyr.Name    = OutRasterName;
                    rsLyr.Visible = false;
                    mp.AddLayer(rsLyr);
                }
                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 Landscape Analysis" + t);
                rp.enableClose();
                this.Close();
            }
        }