Beispiel #1
0
        private bool ValidateForm()
        {
            // Sanity check to avoid empty names
            txtName.Text = txtName.Text.Trim();

            if (string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show("You must provide a name for the point density associated surface.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            if (!DEM.IsAssocNameUnique(txtName.Text, Assoc))
            {
                MessageBox.Show("The name '" + txtName.Text + "' is already in use by another associated surface within this survey. Please choose a unique name.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtName.Select();
                return(false);
            }

            if (ucPointCloud.SelectedItem is GCDConsoleLib.Vector)
            {
                if (!GISDatasetValidation.DSHasSpatialRef(ucPointCloud.SelectedItem, "feature class", "feature classes") ||
                    !GISDatasetValidation.DSSpatialRefMatchesProjectWithMsgbox(ucPointCloud.SelectedItem, "feature class", "feature classes") ||
                    !GISDatasetValidation.DSHorizUnitsMatchProject(ucPointCloud.SelectedItem, "feature class", "feature classes") ||
                    !GISDatasetValidation.DSGeometryTypeMatches((Vector)ucPointCloud.SelectedItem, GDalGeometryType.SimpleTypes.Point))
                {
                    ucPointCloud.Select();
                    return(false);
                }
            }
            else
            {
                MessageBox.Show("You must select a point cloud Shape File to continue.", "Missing Point Shape File", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        private bool ValidateForm()
        {
            // Sanity check to avoid names with only spaces
            txtName.Text = txtName.Text.Trim();

            if (string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show("The raster name cannot be empty.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtName.Select();
                return(false);
            }

            switch (Purpose)
            {
            case Purposes.SubsequentDEM:
                if (!ProjectManager.Project.IsDEMNameUnique(txtName.Text, null))
                {
                    MessageBox.Show(string.Format("There is already another DEM survey in this project with the name '{0}'. Each DEM Survey must have a unique name.", txtName.Text), Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtName.Select();
                    return(false);
                }
                break;

            case Purposes.AssociatedSurface:
                if (!((DEMSurvey)ReferenceSurface).IsAssocNameUnique(txtName.Text, null))
                {
                    MessageBox.Show(string.Format("There is already another associated surface for this DEM with the name '{0}'. The associated surfaces for each DEM must have a unique name.", txtName.Text), Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtName.Select();
                    return(false);
                }
                break;

            case Purposes.ErrorSurface:
            case Purposes.ReferenceErrorSurface:
                if (!ReferenceSurface.IsErrorNameUnique(txtName.Text, null))
                {
                    string parentType = "Reference Surface";
                    if (ReferenceSurface is DEMSurvey)
                    {
                        parentType = "DEM Survey";
                    }

                    MessageBox.Show(string.Format("There is already another error surface for this {0} with the name '{1}'. The error surfaces for each {0} must have a unique name.", parentType, txtName.Text), Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtName.Select();
                    return(false);
                }
                break;

            case Purposes.ReferenceSurface:
                if (!ProjectManager.Project.IsReferenceSurfaceNameUnique(txtName.Text, null))
                {
                    MessageBox.Show(string.Format("There is already another reference surface with the name '{0}'. Each reference surface must have a unique name.", txtName.Text), Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtName.Select();
                    return(false);
                }
                break;
            }


            NeedsForcedProjection = false;

            // Importing rasters into GCD projects requires unit checks
            if (!GISDatasetValidation.DSSpatialRefMatchesProject(SourceRaster))
            {
                string msg = string.Format(
                    "{0}{1}{0}If you believe that these projections are the same (or equivalent) choose \"Yes\" to continue anyway. Otherwise choose \"No\" to abort.",
                    Environment.NewLine, GISDatasetValidation.SpatialRefNoMatchString(SourceRaster, "raster", "rasters"));

                DialogResult result = MessageBox.Show(msg, Properties.Resources.ApplicationNameLong, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);

                if (result == DialogResult.No)
                {
                    NeedsForcedProjection = false;
                    return(false);
                }
                else
                {
                    NeedsForcedProjection = true;
                }
            }

            // TODO: This check appears to be VERY similar to the next block of code. Research and simplify if possible.
            if (!GISDatasetValidation.DSHorizUnitsMatchProject(SourceRaster, "raster", "rasters"))
            {
                return(false);
            }

            // Verify that the horizontal units match those of the project.
            if (ProjectManager.Project.Units.HorizUnit != SourceRaster.Proj.HorizontalUnit)
            {
                string msg = string.Format("The horizontal units of the raster ({0}) do not match those of the GCD project ({1}).", SourceRaster.Proj.HorizontalUnit.ToString(), ProjectManager.Project.Units.HorizUnit.ToString());
                if (ProjectManager.Project.DEMSurveys.Count < 1)
                {
                    msg += " You can change the GCD project horizontal units by canceling this form and opening the GCD project properties form.";
                }
                MessageBox.Show(msg, "HorizontalUnits Mismatch", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            // Verify the optional vertical units (if they are specified) for rasters that should share the project vertical units
            if (Purpose == Purposes.FirstDEM || Purpose == Purposes.SubsequentDEM)
            {
                if (SourceRaster.VerticalUnits != UnitsNet.Units.LengthUnit.Undefined)
                {
                    if (SourceRaster.VerticalUnits != ProjectManager.Project.Units.VertUnit)
                    {
                        MessageBox.Show(string.Format("The raster has different vertical units ({0}) than the GCD project ({1})." + " You must change the vertical units of the raster before it can be used within the GCD.", SourceRaster.VerticalUnits.ToString(), ProjectManager.Project.Units.VertUnit.ToString()), "Vertical Units Mismatch", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(false);
                    }
                }
            }


            if (string.IsNullOrEmpty(txtRasterPath.Text))
            {
                //if (ExtImporter.Purpose == ExtentImporter.Purposes.Standalone)
                //{
                //    MessageBox.Show("The output raster path cannot be empty. Click the Save button to specify an output raster path.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
                //else
                //{
                MessageBox.Show("The output raster path cannot be empty. Try using a different name.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
                return(false);
            }
            else
            {
                System.IO.FileInfo outputPath = new System.IO.FileInfo(txtRasterPath.Text);
                if (ProjectManager.Project != null)
                {
                    outputPath = ProjectManager.Project.GetAbsolutePath(txtRasterPath.Text);
                }

                if (outputPath.Exists)
                {
                    MessageBox.Show("The project raster path already exists. Try using a different name for the raster.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                else
                {
                    string sExtension = System.IO.Path.GetExtension(txtRasterPath.Text);
                    if (string.Compare(sExtension, ".tif", true) != 0)
                    {
                        MessageBox.Show("This tool can only currently produce GeoTIFF rasters. Please provide an output raster path ending with '.tif'", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(false);
                    }
                }
            }

            if (valCellSize.Value <= 0)
            {
                MessageBox.Show("The cell size must be greater than or equal to zero.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            if ((valRight.Value - valLeft.Value) < valCellSize.Value)
            {
                MessageBox.Show("The right edge of the extent must be at least one cell width more than the left edge of the extent.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            if (valTop.Value - valBottom.Value < valCellSize.Value)
            {
                MessageBox.Show("The top edge of the extent must be at least one cell width more than the bottom edge of the extent.", Properties.Resources.ApplicationNameLong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            return(true);
        }