Example #1
0
        public override void OnAdd(object sender, EventArgs e)
        {
            SurveyLibrary.frmImportRaster frm = SurveyLibrary.frmImportRaster.PrepareToImportRaster(DEM, SurveyLibrary.frmImportRaster.Purposes.AssociatedSurface, "Associated Surface", new IntPtr(0));

            if (EditTreeItem(frm) == DialogResult.OK)
            {
                GCDConsoleLib.Raster rAssoc = frm.ProcessRaster();
                AssocSurface         assoc  = new AssocSurface(frm.txtName.Text, rAssoc.GISFileInfo, DEM, AssocSurface.AssociatedSurfaceTypes.Other);
                DEM.AssocSurfaces.Add(assoc);
                ProjectManager.Project.Save();
                ProjectManager.AddNewProjectItemToMap(assoc);
                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(assoc))
                        {
                            TreeView.SelectedNode = childNode;
                            break;
                        }
                    }
                }
            }
        }
Example #2
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (Assoc == null)
                {
                    FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiOutput.Directory.Create();

                    switch (SelectedAssociatedSurfaceType)
                    {
                    case AssocSurface.AssociatedSurfaceTypes.SlopeDegree:
                        GCDConsoleLib.RasterOperators.SlopeDegrees(DEM.Raster, fiOutput, ProjectManager.OnProgressChange);
                        break;

                    case AssocSurface.AssociatedSurfaceTypes.SlopePercent:
                        GCDConsoleLib.RasterOperators.SlopePercent(DEM.Raster, fiOutput, ProjectManager.OnProgressChange);

                        break;

                    default:
                        // This form is not capable of creating other associated surface types
                        throw new NotImplementedException(string.Format("The associated surface form is not capable of creating {0} rasters", SelectedAssociatedSurfaceType));
                    }

                    Assoc = new AssocSurface(txtName.Text, fiOutput, DEM, SelectedAssociatedSurfaceType);
                    DEM.AssocSurfaces.Add(Assoc);
                    ProjectManager.AddNewProjectItemToMap(Assoc);
                }
                else
                {
                    Assoc.Name             = txtName.Text;
                    Assoc.AssocSurfaceType = SelectedAssociatedSurfaceType;
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error generating associated surface raster.");
                DialogResult = DialogResult.None;
            }
        }
Example #3
0
        private void addToMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (grdData.SelectedRows.Count < 1)
            {
                return;
            }

            if (grdData.SelectedRows[0].DataBoundItem is GridViewGCDProjectItem)
            {
                GridViewGCDProjectItem propItem = (GridViewGCDProjectItem)grdData.SelectedRows[0].DataBoundItem;
                ProjectManager.AddNewProjectItemToMap(propItem.ProjectItem);
            }
        }
Example #4
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 #5
0
        private void cmdOK_Click(System.Object sender, System.EventArgs e)
        {
            if (!ValidateForm())
            {
                this.DialogResult = System.Windows.Forms.DialogResult.None;
                return;
            }

            try
            {
                Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                System.IO.DirectoryInfo dFolder = ProjectManager.Project.GetAbsoluteDir(txtOutputFolder.Text);
                GCDCore.Engines.ChangeDetectionEngineBase cdEngine = null;

                if (ucThresholding.ThresholdProperties.Method == Engines.DoD.ThresholdProps.ThresholdMethods.MinLoD)
                {
                    cdEngine = new Engines.ChangeDetectionEngineMinLoD(ucDEMs.NewSurface, ucDEMs.OldSurface, ucDEMs.AOIMask, ucThresholding.ThresholdProperties.Threshold);
                }
                else
                {
                    if (ucThresholding.ThresholdProperties.Method == Engines.DoD.ThresholdProps.ThresholdMethods.Propagated)
                    {
                        cdEngine = new Engines.ChangeDetectionEnginePropProb(ucDEMs.NewSurface, ucDEMs.OldSurface, ucDEMs.NewError, ucDEMs.OldError, ucDEMs.AOIMask);
                    }
                    else
                    {
                        cdEngine = new Engines.ChangeDetectionEngineProbabilistic(ucDEMs.NewSurface, ucDEMs.OldSurface, ucDEMs.AOIMask, ucDEMs.NewError, ucDEMs.OldError, ucThresholding.ThresholdProperties.Threshold, ucThresholding.ThresholdProperties.SpatialCoherenceProps);
                    }
                }

                DoD = cdEngine.Calculate(txtName.Text, dFolder, true, ProjectManager.Project.Units);

                ProjectManager.OnAddRasterToMap(DoD.ThrDoD);

                ProjectManager.Project.DoDs.Add(DoD);
                ProjectManager.Project.Save();
                ProjectManager.AddNewProjectItemToMap(DoD);
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex);
                DoD = null;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Example #6
0
        public override void OnAdd(object sender, EventArgs e)
        {
            // Determine if this is the first DEM in the project or use the first existing DEM as a reference surface
            DEMSurvey referenceDEM = null;

            SurveyLibrary.frmImportRaster.Purposes ePurpose = SurveyLibrary.frmImportRaster.Purposes.FirstDEM;
            if (ProjectManager.Project.DEMSurveys.Count > 0)
            {
                referenceDEM = ProjectManager.Project.DEMSurveys.First();
                ePurpose     = SurveyLibrary.frmImportRaster.Purposes.SubsequentDEM;
            }

            try
            {
                SurveyLibrary.frmImportRaster frm = SurveyLibrary.frmImportRaster.PrepareToImportRaster(referenceDEM, ePurpose, "DEM Survey", new IntPtr(0));

                if (EditTreeItem(frm, false) == DialogResult.OK)
                {
                    GCDConsoleLib.Raster rDEM = frm.ProcessRaster();
                    DEMSurvey            dem  = new DEMSurvey(frm.txtName.Text, null, rDEM.GISFileInfo, Surface.HillShadeRasterPath(rDEM.GISFileInfo));
                    ProjectManager.Project.DEMSurveys.Add(dem);

                    // If this was the first raster then we need to store the cell resolution on the project
                    if (ePurpose == SurveyLibrary.frmImportRaster.Purposes.FirstDEM)
                    {
                        ProjectManager.Project.CellArea = dem.Raster.Extent.CellArea(ProjectManager.Project.Units);
                    }

                    ProjectManager.Project.Save();
                    ProjectManager.AddNewProjectItemToMap(dem);
                    LoadChildNodes();

                    // Loop through the child nodes and select the item that was just added
                    foreach (TreeNodeItem childNode in Nodes)
                    {
                        if (childNode.Item.Equals(dem))
                        {
                            TreeView.SelectedNode = childNode;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error Importing DEM Survey");
            }
        }
        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 #8
0
        public override void OnAdd(object sender, EventArgs e)
        {
            DEMSurvey referenceDEM = null;

            if (ProjectManager.Project.DEMSurveys.Count > 0)
            {
                referenceDEM = ProjectManager.Project.DEMSurveys.First();
            }
            else
            {
                MessageBox.Show("You must have at least one DEM survey in your GCD project before you can generate a constant reference surface.", "DEM Surveys Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            try
            {
                SurveyLibrary.frmImportRaster frm = SurveyLibrary.frmImportRaster.PrepareToImportRaster(referenceDEM, SurveyLibrary.frmImportRaster.Purposes.ReferenceSurface, "Reference Surface", new IntPtr(0));

                if (EditTreeItem(frm, false) == DialogResult.OK)
                {
                    GCDConsoleLib.Raster    rDEM = frm.ProcessRaster();
                    GCDCore.Project.Surface surf = new Surface(frm.txtName.Text, rDEM.GISFileInfo, Surface.HillShadeRasterPath(rDEM.GISFileInfo));
                    ProjectManager.Project.ReferenceSurfaces.Add(surf);

                    ProjectManager.Project.Save();
                    LoadChildNodes();

                    ProjectManager.AddNewProjectItemToMap(surf);

                    // Loop through the child nodes and select the item that was just added
                    foreach (TreeNodeItem childNode in Nodes)
                    {
                        if (childNode.Item.Equals(surf))
                        {
                            TreeView.SelectedNode = childNode;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error Importing DEM Survey");
            }
        }
Example #9
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (Mask == null)
                {
                    FileInfo fiMask = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiMask.Directory.Create();

                    ucPolygon.SelectedItem.Copy(fiMask);

                    string lablField = chkLabel.Checked ? cboLabel.Text : string.Empty;
                    string distField = chkDistance.Checked ? cboDistance.Text : string.Empty;

                    Mask = new DirectionalMask(txtName.Text, fiMask, cboField.Text, lablField, cboDirection.Text, rdoAscending.Checked, distField);
                    ProjectManager.Project.Masks.Add(Mask);
                    ProjectManager.AddNewProjectItemToMap(Mask);
                }
                else
                {
                    Mask.Name          = txtName.Text;
                    Mask.LabelField    = chkLabel.Checked ? cboLabel.Text : string.Empty;
                    Mask.DistanceField = chkDistance.Checked ? cboDistance.Text : string.Empty;
                    Mask.Ascending     = rdoAscending.Checked;
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error creating regular mask.");
            }
        }
Example #10
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (AOIMask == null)
                {
                    FileInfo fiDestination = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiDestination.Directory.Create();

                    ucPolygon.SelectedItem.Copy(fiDestination);

                    AOIMask = new GCDCore.Project.Masks.AOIMask(txtName.Text, fiDestination);
                    ProjectManager.Project.Masks.Add(AOIMask);
                    ProjectManager.AddNewProjectItemToMap(AOIMask);
                }
                else
                {
                    AOIMask.Name = txtName.Text;
                }

                ProjectManager.Project.Save();
                Cursor = Cursors.Default;
                MessageBox.Show("Area of interest mask saved successfully.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                DialogResult = DialogResult.None;
                GCDException.HandleException(ex, "Error saving area of interest mask.");
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Example #11
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (!ValidateForm())
                {
                    DialogResult = DialogResult.None;
                    return;
                }

                Cursor = Cursors.WaitCursor;

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

                RasterOperators.PointDensity(DEM.Raster, ucPointCloud.SelectedItem, fiOutput, KernelShape, valSampleDistance.Value,
                                             ProjectManager.OnProgressChange);

                Assoc = new AssocSurface(txtName.Text, fiOutput, DEM, AssocSurface.AssociatedSurfaceTypes.PointDensity);
                DEM.AssocSurfaces.Add(Assoc);
                ProjectManager.Project.Save();
                ProjectManager.AddNewProjectItemToMap(Assoc);
                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor       = Cursors.Default;
                DialogResult = DialogResult.None;

                if (ex.Message.ToLower().Contains("multipart") || ex.Message.ToLower().Contains("multi-part"))
                {
                    MessageBox.Show("The ShapeFile contains multi-part features and is incompatible with the GCD. Please select a single part point ShapeFile.", "Multi-Part Features Detected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    GCDException.HandleException(ex, "Error generating point density associated surface raster.");
                }
            }
        }
Example #12
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (ProfileRoute == null)
                {
                    FileInfo fiMask = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiMask.Directory.Create();

                    ucPolyline.SelectedItem.Copy(fiMask);

                    string lablField = chkLabel.Checked ? cboLabel.Text : string.Empty;

                    ProfileRoute = new GCDCore.Project.ProfileRoutes.ProfileRoute(txtName.Text, fiMask, cboDistance.Text, lablField, ProfileRouteType);
                    ProjectManager.Project.ProfileRoutes.Add(ProfileRoute);
                    ProjectManager.AddNewProjectItemToMap(ProfileRoute);
                }
                else
                {
                    ProfileRoute.Name = txtName.Text;
                }

                ProjectManager.Project.Save();

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error creating regular mask.");
            }
        }
Example #13
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                DialogResult = DialogResult.None;
                return;
            }

            try
            {
                Cursor = Cursors.WaitCursor;

                if (Mask == null)
                {
                    FileInfo fiMask = ProjectManager.Project.GetAbsolutePath(txtPath.Text);
                    fiMask.Directory.Create();

                    ucPolygon.SelectedItem.Copy(fiMask);

                    Mask = new GCDCore.Project.Masks.RegularMask(txtName.Text, fiMask, cboField.Text, MaskItems.ToList <GCDCore.Project.Masks.MaskItem>());
                    ProjectManager.Project.Masks.Add(Mask);
                    ProjectManager.AddNewProjectItemToMap(Mask);
                }
                else
                {
                    Mask.Name = txtName.Text;
                }

                ProjectManager.Project.Save();

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                GCDException.HandleException(ex, "Error creating regular mask.");
            }
        }
Example #14
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 #15
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");
            }
        }