Example #1
0
 public ChangeDetectionEnginePropProb(Surface newDEM, Surface oldDEM, ErrorSurface newError, ErrorSurface oldError, Project.Masks.AOIMask aoi,
                                      bool isAsync = false)
     : base(newDEM, oldDEM, aoi, isAsync)
 {
     NewError = newError;
     OldError = oldError;
 }
Example #2
0
 public Epoch(DEMSurvey newDEM, ErrorSurface newDEMErrorSurface, DEMSurvey oldDEM, ErrorSurface oldDEMErrorSurface)
 {
     NewDEM             = newDEM;
     NewDEMErrorSurface = newDEMErrorSurface;
     OldDEM             = oldDEM;
     OldDEMErrorSurface = oldDEMErrorSurface;
     IsActive           = true;
 }
Example #3
0
        private void SetDefaultErrorSurface(object sender, EventArgs e)
        {
            ErrorSurface selectedErr = ((TreeNodeItem)TreeView.SelectedNode).Item as ErrorSurface;

            selectedErr.IsDefault = true;
            ProjectManager.Project.Save();

            LoadChildNodes();
        }
Example #4
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            DialogResult eResult = ValidateForm();

            if (eResult != DialogResult.OK)
            {
                DialogResult = eResult;
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            string       successMsg = string.Empty;
            List <float> errVals    = new List <float>();

            if (rdoSingle.Checked)
            {
                successMsg = "Reference Error Surface generated successfully.";
                errVals.Add((float)valSingle.Value);
            }
            else
            {
                for (decimal errVal = valLower.Value; errVal <= valUpper.Value; errVal += valIncrement.Value)
                {
                    errVals.Add((float)errVal);
                }

                successMsg = string.Format("{0} reference error surfaces generated successfully.", errVals.Count);
            }

            try
            {
                foreach (float errVal in errVals)
                {
                    string             name     = GetUniqueName(errVal);
                    System.IO.FileInfo fiOutput = ReferenceSurface.ErrorSurfacePath(name);
                    fiOutput.Directory.Create();

                    GCDConsoleLib.RasterOperators.Uniform <float>(ReferenceSurface.Raster, fiOutput, errVal, ProjectManager.OnProgressChange);
                    ErrorSurface = new ErrorSurface(name, fiOutput, ReferenceSurface);
                    ReferenceSurface.ErrorSurfaces.Add(ErrorSurface);
                }

                ProjectManager.Project.Save();
                Cursor.Current = Cursors.Default;
                MessageBox.Show(successMsg, Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #5
0
 public BatchProps(Surface newSurface, ErrorSurface newError, Surface oldSurface, ErrorSurface oldError, GCDCore.Project.Masks.AOIMask aoiMask, ThresholdProps tProps)
 {
     NewSurface     = newSurface;
     NewError       = newError;
     OldSurface     = oldSurface;
     OldError       = oldError;
     AOIMask        = aoiMask;
     ThresholdProps = tProps;
 }
        public LinearExtractionFromSurface(XmlNode nodItem, Surface surf)
            : base(nodItem)
        {
            Surface = surf;

            if (nodItem.SelectSingleNode("ErrorSurface") is XmlNode)
            {
                ErrorSurface = Surface.ErrorSurfaces.First(x => string.Compare(x.Name, nodItem.SelectSingleNode("ErrorSurface").InnerText, true) == 0);
            }
        }
Example #7
0
        public DEMSurveyItem(DEMSurvey dem, ErrorSurface err)
        {
            DEM       = dem;
            ErrorSurf = err;

            ErrorSurfaces = new naru.ui.SortableBindingList <ErrorSurface>();
            foreach (ErrorSurface es in dem.ErrorSurfaces)
            {
                ErrorSurfaces.Add(es);
            }
            //IsActive = false;
        }
Example #8
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ucName.ValidateForm() || !ucErrProps.ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (chkDefault.Checked && DEM.ErrorSurfaces.Count > 0)
                {
                    // Need to set all other error surfaces to not be the default
                    DEM.ErrorSurfaces.ToList().ForEach(x => x.IsDefault = false);
                }

                if (ErrorSurface == null)
                {
                    // If this is a FIS error surface then copy the FIS file to the project and point the error surface property to
                    // this local file before saving the project. This will ensure that path to the FIS file is local to the project.
                    // MUST BE DONE BEFORE SAVING ERROR PROPERTIES TO THE PROJECT
                    ucErrProps.ErrSurfProperty.CloneToProject(ucName.ItemName, ucName.AbsolutePath.Directory);

                    // Create the raster then add it to the DEM survey
                    ucName.AbsolutePath.Directory.Create();
                    RasterOperators.CreateErrorRaster(DEM.Raster, ucErrProps.ErrSurfProperty.GCDErrSurfPropery, ucName.AbsolutePath, ProjectManager.OnProgressChange);
                    ErrorSurface = new ErrorSurface(ucName.ItemName, ucName.AbsolutePath, DEM, chkDefault.Checked, ucErrProps.ErrSurfProperty);
                    DEM.ErrorSurfaces.Add(ErrorSurface);
                    ProjectManager.AddNewProjectItemToMap(ErrorSurface);
                }
                else
                {
                    ErrorSurface.Name = ucName.ItemName;
                }

                // Handles unsetting default on other error surface and setting it for this one
                DEM.DefaultErrorSurface = ErrorSurface;

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Error Surface Created Successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error editing single region error surface");
            }
        }
Example #9
0
        /// <summary>
        /// Handler support for when error surfaces change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Get selected error surface
            ComboBox     cbo = (ComboBox)sender;
            ErrorSurface selectedDEMErrorSurface = (ErrorSurface)cbo.SelectedItem;

            //set selected error surface on relevant DEMSurveyItem
            DEMSurveyItem selectedDEM = (DEMSurveyItem)grdDEMs.SelectedRows[0].DataBoundItem;

            selectedDEM.SelectedErrorSurface = selectedDEMErrorSurface;

            //Update list of epochs (necessary because we need to make sure the epoch has the correct error surface
            UpdateEpochQueue();
        }
Example #10
0
        public frmSingleMethodError(ErrorSurface errSurface)
        {
            InitializeComponent();
            DEM          = errSurface.Surf as DEMSurvey;
            ErrorSurface = errSurface;

            // Need to exclude the current item from this list
            List <string> existingNames = DEM.ErrorSurfaces.Where(x => !x.Equals(errSurface)).Select(x => x.Name).ToList();

            ucErrProps.InitializeExisting(errSurface.ErrorProperties.Values.First(), DEM.AssocSurfaces.ToList(), errSurface == null);
            ucName.InitializeExisting("Error Surface", existingNames, ErrorSurface.Name, ErrorSurface.Raster.GISFileInfo);

            // Initialize raster properties
            ucRasterProperties1.Initialize(errSurface.Noun, errSurface.Raster);
        }
Example #11
0
        public frmMultiMethodError(ErrorSurface errSurf)
        {
            InitializeComponent();
            DEM          = errSurf.Surf as DEMSurvey;
            ErrorSurface = errSurf;
            ErrProps     = new naru.ui.SortableBindingList <ErrorSurfaceProperty>(errSurf.ErrorProperties.Values.ToList());

            // Need to exclude the current item from this list
            List <string> existingNames = DEM.ErrorSurfaces.Where(x => !x.Equals(errSurf)).Select(x => x.Name).ToList();

            ucName.InitializeExisting("Error Surface", existingNames, ErrorSurface.Name, ErrorSurface.Raster.GISFileInfo);

            // Populate the raster statistics
            ucRasterProperties1.Initialize(errSurf.Noun, errSurf.Raster);
        }
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                this.DialogResult = DialogResult.None;
                return;
            }

            RasterOperators.MultiMathOpType eMethod = (RasterOperators.MultiMathOpType)((naru.db.NamedObject)cboMethod.SelectedItem).ID;

            List <Tuple <DEMSurvey, ErrorSurface> > rInputs = new List <Tuple <DEMSurvey, ErrorSurface> >();

            for (int i = 0; i < grdData.Rows.Count; i++)
            {
                DEMItem dem = grdData.Rows[i].DataBoundItem as DEMItem;
                if (!dem.Include)
                {
                    continue;
                }

                DataGridViewComboBoxCell comboCell = grdData.Rows[i].Cells["colError"] as DataGridViewComboBoxCell;
                BindingSource            bs        = comboCell.DataSource as BindingSource;
                ErrorSurface             err       = bs.Current as ErrorSurface;

                rInputs.Add(new Tuple <DEMSurvey, ErrorSurface>(dem._DEM, err));
            }

            Engines.ReferenceSurfaceEngine eng = new Engines.ReferenceSurfaceEngine(txtName.Text, rInputs, eMethod);

            System.IO.FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
            System.IO.FileInfo fiError  = Surface.ErrorSurfaceRasterPath(fiOutput.Directory, txtName.Text);

            try
            {
                Cursor = Cursors.WaitCursor;

                Surface surf = eng.Run(fiOutput, fiError);
                ProjectManager.AddNewProjectItemToMap(surf);
                Cursor = Cursors.Default;
                MessageBox.Show("Reference surface generated successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error generating reference surface from DEM surveys.");
                this.DialogResult = DialogResult.None;
            }
        }
Example #13
0
        public void AddErrSurface(ErrorSurface errRow)
        {
            IGroupLayer pErrGrpLyr = null;

            if (errRow.Surf is DEMSurvey)
            {
                pErrGrpLyr = AddErrorSurfacesGroupLayer(errRow.Surf as DEMSurvey);
            }
            else
            {
                pErrGrpLyr = AddReferenceErrorSurfacesGroupLayer(errRow.Surf);
            }

            string sHeader = string.Format("Error ({0})", UnitsNet.Length.GetAbbreviation(ProjectManager.Project.Units.VertUnit));

            short dTransparency = -1;

            if (GCDCore.Properties.Settings.Default.TransparencyErrorLayers)
            {
                dTransparency = GCDCore.Properties.Settings.Default.AutoTransparencyValue;
            }

            errRow.Raster.ComputeStatistics();
            Dictionary <string, decimal> stats = errRow.Raster.GetStatistics();
            double rMin = (double)stats["min"];
            double rMax = (double)stats["max"];

            if (rMin == rMax)
            {
                IRasterRenderer rasterRenderer = RasterSymbolization.CreateESRIDefinedContinuousRenderer(errRow.Raster, 1, "Partial Spectrum");
                AddRasterLayer(errRow.Raster, rasterRenderer, errRow.Name, pErrGrpLyr, sHeader, dTransparency);
            }
            else if (rMax <= 1 & rMax > 0.25)
            {
                IRasterRenderer rasterRenderer = RasterSymbolization.CreateClassifyRenderer(errRow.Raster, 11, "Partial Spectrum", 1.1);
                AddRasterLayer(errRow.Raster, rasterRenderer, errRow.Name, pErrGrpLyr, sHeader, dTransparency);
            }
            else
            {
                IRasterRenderer rasterRenderer = RasterSymbolization.CreateClassifyRenderer(errRow.Raster, 11, "Partial Spectrum");
                AddRasterLayer(errRow.Raster, rasterRenderer, errRow.Name, pErrGrpLyr, sHeader, dTransparency);
            }
        }
Example #14
0
        public override void LoadChildNodes()
        {
            Nodes.Clear();

            Surface.ErrorSurfaces.ToList().ForEach(x => Nodes.Add(new TreeNodeItem(x.NameWithDefault, x, 4, ContextMenuStrip.Container)));

            // Add the menu item to set default error surface
            foreach (TreeNode nod in Nodes)
            {
                ErrorSurface err = ((TreeNodeItem)nod).Item as ErrorSurface;
                if (!err.IsDefault)
                {
                    nod.ContextMenuStrip.Items.Insert(1, new ToolStripMenuItem("Set As Default Error Surface", null, SetDefaultErrorSurface));
                }
            }

            if (Nodes.Count > 0)
            {
                Expand();
            }
        }
Example #15
0
        /// <summary>
        /// One place that both the single and multi-method error surface forms enable/disable and check the default box
        /// </summary>
        /// <param name="chkDefault">Is default checkbox control</param>
        /// <param name="errSurf">error surface being created (null) or edited</param>
        /// <param name="surface">parent surface</param>
        public static void InitializeDefaultCheckBox(CheckBox chkDefault, ErrorSurface errSurf, Surface surface)
        {
            if (errSurf == null)
            {
                chkDefault.Checked = surface.ErrorSurfaces.Count == 0;
                chkDefault.Enabled = surface.ErrorSurfaces.Count > 0;
            }
            else
            {
                chkDefault.Checked = errSurf.IsDefault;

                if (errSurf.IsDefault)
                {
                    chkDefault.Enabled = false;
                }
                else
                {
                    chkDefault.Enabled = surface.ErrorSurfaces.Count > 1;
                }
            }
        }
Example #16
0
        public override void OnAdd(object sender, EventArgs e)
        {
            string noun = "Reference Error Surface";

            SurveyLibrary.frmImportRaster.Purposes ePurpose = SurveyLibrary.frmImportRaster.Purposes.ReferenceErrorSurface;
            if (Surface is DEMSurvey)
            {
                ePurpose = SurveyLibrary.frmImportRaster.Purposes.ErrorSurface;
                noun     = "Error Surface";
            }

            SurveyLibrary.frmImportRaster frm = SurveyLibrary.frmImportRaster.PrepareToImportRaster(Surface, ePurpose, noun, new IntPtr(0));

            if (EditTreeItem(frm) == DialogResult.OK)
            {
                GCDConsoleLib.Raster raster = frm.ProcessRaster();
                ErrorSurface         err    = new ErrorSurface(frm.txtName.Text, raster.GISFileInfo, Surface, Surface.ErrorSurfaces.Count == 0, null);
                Surface.ErrorSurfaces.Add(err);
                ProjectManager.Project.Save();
                ProjectManager.AddNewProjectItemToMap(err);
                LoadChildNodes();

                // Loop through the child nodes and select the item that was just added
                foreach (TreeNode childNode in Nodes)
                {
                    if (childNode is TreeNodeItem)
                    {
                        if (((TreeNodeItem)childNode).Item.Equals(err))
                        {
                            TreeView.SelectedNode = childNode;
                            break;
                        }
                    }
                }
            }
        }
Example #17
0
        public void OnEdit(object sender, EventArgs e)
        {
            TreeNodeItem node = sender as TreeNodeItem;
            Form         frm  = null;

            if (Item is AssocSurface)
            {
                AssocSurface assoc = Item as AssocSurface;
                frm = new SurveyLibrary.frmAssociatedSurface(assoc.DEM, assoc);
            }
            else if (Item is ErrorSurface && ((ErrorSurface)Item).Surf is DEMSurvey)
            {
                ErrorSurface err = Item as ErrorSurface;
                if (err.ErrorProperties.Count < 1)
                {
                    frm = new SurveyLibrary.frmSurfaceProperties(Item as GCDProjectRasterItem, true);
                }
                else
                {
                    if (err.Mask == null)
                    {
                        frm = new SurveyLibrary.ErrorSurfaces.frmSingleMethodError(err);
                    }
                    else
                    {
                        frm = new SurveyLibrary.ErrorSurfaces.frmMultiMethodError(err);
                    }
                }
            }
            else if (Item is GCDCore.Project.ProfileRoutes.ProfileRoute)
            {
                GCDCore.Project.ProfileRoutes.ProfileRoute route = Item as GCDCore.Project.ProfileRoutes.ProfileRoute;
                frm = new UserInterface.ProfileRoutes.frmProfileRouteProperties(route.ProfileRouteType, route);
            }
            else if (Item is GCDCore.Project.Masks.DirectionalMask)
            {
                frm = new Masks.frmDirectionalMaskProps(Item as GCDCore.Project.Masks.DirectionalMask);
            }
            else if (Item is GCDCore.Project.Masks.AOIMask)
            {
                frm = new Masks.frmAOIProperties(Item as GCDCore.Project.Masks.AOIMask);
            }
            else if (Item is GCDCore.Project.Masks.RegularMask)
            {
                frm = new Masks.frmMaskProperties(Item as GCDCore.Project.Masks.RegularMask);
            }
            else if (Item is GCDCore.Project.LinearExtraction.LinearExtraction)
            {
                frm = new LinearExtraction.frmLinearExtractionProperties(Item as GCDCore.Project.LinearExtraction.LinearExtraction);
            }
            else
            {
                // Generic raster properties form
                if (Item is GCDProjectRasterItem)
                {
                    frm = new SurveyLibrary.frmSurfaceProperties(Item as GCDProjectRasterItem, true);
                }
                else
                {
                    throw new NotImplementedException("Unhandled editing of project type");
                }
            }

            if (frm is Form)
            {
                EditTreeItem(frm);
            }
        }
Example #18
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (LinearExtraction == null)
                {
                    GCDCore.Project.ProfileRoutes.ProfileRoute route = cboRoute.SelectedItem as GCDCore.Project.ProfileRoutes.ProfileRoute;

                    ErrorSurface errSurf = null;
                    List <GCDConsoleLib.Raster> rasters = new List <Raster>();


                    if (ElevationSurface is Surface)
                    {
                        rasters.Add(((Surface)ElevationSurface).Raster);
                        if (cboError.SelectedItem is ErrorSurface)
                        {
                            errSurf = cboError.SelectedItem as ErrorSurface;
                            rasters.Add(errSurf.Raster);
                        }
                    }
                    else
                    {
                        DoDBase dod = ElevationSurface as DoDBase;
                        rasters.Add(dod.ThrDoD.Raster);
                        if (dod.ThrErr != null)
                        {
                            rasters.Add(dod.ThrErr.Raster);
                        }
                    }

                    FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiOutput.Directory.Create();

                    RasterOperators.LinearExtractor(route.Vector, rasters, fiOutput, valSampleDistance.Value, route.DistanceField, ProjectManager.OnProgressChange);

                    GCDCore.Project.LinearExtraction.LinearExtraction le;
                    if (ElevationSurface is DEMSurvey)
                    {
                        le = new GCDCore.Project.LinearExtraction.LinearExtractionFromDEM(txtName.Text, route, fiOutput, valSampleDistance.Value, ElevationSurface as DEMSurvey, errSurf);
                    }
                    else if (ElevationSurface is Surface)
                    {
                        le = new GCDCore.Project.LinearExtraction.LinearExtractionFromSurface(txtName.Text, route, fiOutput, valSampleDistance.Value, ElevationSurface as Surface, errSurf);
                    }
                    else
                    {
                        le = new GCDCore.Project.LinearExtraction.LinearExtractionFromDoD(txtName.Text, route, fiOutput, valSampleDistance.Value, ElevationSurface as DoDBase);
                    }

                    if (ElevationSurface is Surface)
                    {
                        ((Surface)ElevationSurface).LinearExtractions.Add(le);
                    }
                    else
                    {
                        ((DoDBase)ElevationSurface).LinearExtractions.Add(le);
                    }
                }
                else
                {
                    LinearExtraction.Name = txtName.Text;
                }


                ProjectManager.Project.Save();

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error performing linear extraction.");
                DialogResult = DialogResult.None;
            }
        }
 public LinearExtractionFromSurface(string name, ProfileRoute route, FileInfo db, decimal sampleDistance, Surface surf, ErrorSurface err)
     : base(name, route, db, sampleDistance)
 {
     Surface      = surf;
     ErrorSurface = err;
 }
Example #20
0
 public LinearExtractionFromDEM(string name, ProfileRoutes.ProfileRoute route, FileInfo db, decimal sampleDistance, DEMSurvey dem, ErrorSurface err)
     : base(name, route, db, sampleDistance, dem, err)
 {
 }
Example #21
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ucName.ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (chkDefault.Checked && DEM.ErrorSurfaces.Count > 0)
                {
                    // Need to set all other error surfaces to not be the default
                    DEM.ErrorSurfaces.ToList().ForEach(x => x.IsDefault = false);
                }

                if (ErrorSurface == null)
                {
                    // Create the raster then add it to the DEM survey
                    ucName.AbsolutePath.Directory.Create();

                    // Get the mask values dictionary
                    GCDCore.Project.Masks.RegularMask     mask       = cboMask.SelectedItem as GCDCore.Project.Masks.RegularMask;
                    List <GCDCore.Project.Masks.MaskItem> maskValues = mask.ActiveFieldValues;

                    // Build dictionary of GCDConsole error properties
                    Dictionary <string, ErrorRasterProperties> gcdErrProps = new Dictionary <string, ErrorRasterProperties>();
                    foreach (GCDCore.Project.Masks.MaskItem item in maskValues)
                    {
                        foreach (ErrorSurfaceProperty prop in ErrProps)
                        {
                            if (string.Compare(prop.Name, item.FieldValue, true) == 0 || string.Compare(prop.Name, item.Label, true) == 0)
                            {
                                // For GCDConsole always add using mask value (not label)
                                gcdErrProps.Add(item.FieldValue, prop.GCDErrSurfPropery);
                                break;
                            }
                        }
                    }

                    // Build dictionary of GCD project error properties
                    Dictionary <string, ErrorSurfaceProperty> errProps = new Dictionary <string, ErrorSurfaceProperty>();
                    ErrProps.ToList().ForEach(x => errProps.Add(x.Name, x));

                    RasterOperators.CreateErrorRaster(DEM.Raster, mask.Vector, mask._Field, gcdErrProps, ucName.AbsolutePath, ProjectManager.OnProgressChange);
                    ErrorSurface = new ErrorSurface(ucName.ItemName, ucName.AbsolutePath, DEM, chkDefault.Checked, errProps, mask);
                    DEM.ErrorSurfaces.Add(ErrorSurface);
                    ProjectManager.AddNewProjectItemToMap(ErrorSurface);

                    // If this is a FIS error surface then copy the FIS file to the project and point the error surface property to
                    // this local file before saving the project. This will ensure that path to the FIS file is local to the project.
                    // MUST BE DONE BEFORE SAVING ERROR PROPERTIES TO THE PROJECT
                    ErrProps.ToList().ForEach(x => x.CloneToProject(string.Format("{0}_{1}", ucName.ItemName, x.Name), ucName.AbsolutePath.Directory));
                }
                else
                {
                    ErrorSurface.Name = ucName.ItemName;
                }

                // Handles unsetting default on other error surface and setting it for this one
                DEM.DefaultErrorSurface = ErrorSurface;

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Error Surface Created Successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error editing single region error surface");
            }
        }
Example #22
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            DialogResult = ValidateForm();
            if (DialogResult != DialogResult.OK)
            {
                return;
            }


            GCDConsoleLib.Raster template = ((DEMSurvey)cboDEMSurvey.SelectedItem).Raster;

            List <float> Values     = new List <float>();
            string       successMsg = string.Empty;

            if (rdoSingle.Checked)
            {
                Values.Add((float)valSingle.Value);
                successMsg = "Reference surface generated successfully.";
            }
            else
            {
                for (decimal aVal = valLower.Value; aVal <= valUpper.Value; aVal += valIncrement.Value)
                {
                    Values.Add((float)aVal);
                }
                successMsg = string.Format("{0} reference surfaces generated successfully.", Values.Count);
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                foreach (float value in Values)
                {
                    string name = GetUniqueName(value);

                    // Get a unique name and ensure directory exists
                    FileInfo fiOutput = ProjectManager.Project.ReferenceSurfacePath(name);
                    fiOutput.Directory.Create();

                    // Generate reference surface
                    GCDConsoleLib.Raster rOut = GCDConsoleLib.RasterOperators.Uniform <float>(template, fiOutput, value, ProjectManager.OnProgressChange);
                    ReferenceSurface = new Surface(name, rOut, null);
                    ProjectManager.Project.ReferenceSurfaces.Add(ReferenceSurface);

                    // Error surface
                    string   errName = string.Format("Uniform Error at {0:0.000}", valError.Value);
                    FileInfo fiError = Surface.ErrorSurfaceRasterPath(fiOutput.Directory, errName);
                    fiError.Directory.Create();

                    GCDConsoleLib.RasterOperators.Uniform <float>(template, fiError, (float)valError.Value, ProjectManager.OnProgressChange);
                    ErrorSurface errSurf = new ErrorSurface(errName, fiError, ReferenceSurface);
                    ReferenceSurface.ErrorSurfaces.Add(errSurf);
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show(successMsg, Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error generating reference surface.");
                this.DialogResult = DialogResult.None;
            }
        }
 public ChangeDetectionEngineProbabilistic(Surface newDEM, Surface oldDEM, Project.Masks.AOIMask aoi, ErrorSurface newError, ErrorSurface oldError,
                                           decimal fThreshold, CoherenceProperties spatCoherence = null, bool isAsync = false)
     : base(newDEM, oldDEM, newError, oldError, aoi, isAsync)
 {
     Threshold        = fThreshold;
     SpatialCoherence = spatCoherence;
 }