Skip to content

Commit

Permalink
Fixing clean raster tool fixes #301
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbaileynar committed Aug 22, 2018
1 parent 86319f0 commit 53429b3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
1 change: 1 addition & 0 deletions GCDAddIn/ArcMapUtilities.cs
Expand Up @@ -66,6 +66,7 @@ public static ILayer AddToMap(FileSystemInfo fiFullPath, string sLayerName = "",
IRasterDataset pRDS = ((IRasterWorkspace)pWorkspace).OpenRasterDataset(fiFullPath.Name);
IRasterLayer pRLResult = new RasterLayer();
pRLResult.CreateFromDataset(pRDS);
pResultLayer = pRLResult;
break;

case ArcMapBrowse.GISDataStorageTypes.CAD:
Expand Down
22 changes: 11 additions & 11 deletions GCDAddIn/DataPreparation/btnCleanRaster.cs
Expand Up @@ -8,7 +8,7 @@ protected override void OnClick()
{
GCDCore.UserInterface.SurveyLibrary.frmImportRaster frm = new GCDCore.UserInterface.SurveyLibrary.frmImportRaster(null, GCDCore.UserInterface.SurveyLibrary.ExtentImporter.Purposes.Standalone, string.Empty);

frm.ucRaster.BrowseRaster += BrowseRaster;
//frm.ucRaster.BrowseRaster += BrowseRaster;
frm.GISBrowseSaveRasterHandler += BrowseSaveRaster;

try
Expand All @@ -33,16 +33,16 @@ protected override void OnClick()
ArcMap.Application.CurrentTool = null;
}

private void BrowseRaster(object sender, naru.ui.PathEventArgs e)
{
System.IO.DirectoryInfo diWorkspace = ArcMapUtilities.GetWorkspacePath(e.Path.FullName);
string sDataset = System.IO.Path.GetFileNameWithoutExtension(e.Path.FullName);
GCDConsoleLib.Raster selectedRaster = ArcMapBrowse.BrowseOpenRaster(e.FormTitle, diWorkspace, sDataset, e.hWndParent);
if (!(selectedRaster == null))
{
((System.Windows.Forms.TextBox)sender).Text = selectedRaster.GISFileInfo.FullName;
}
}
//private void BrowseRaster(object sender, naru.ui.PathEventArgs e)
//{
// System.IO.DirectoryInfo diWorkspace = ArcMapUtilities.GetWorkspacePath(e.Path.FullName);
// string sDataset = System.IO.Path.GetFileNameWithoutExtension(e.Path.FullName);
// GCDConsoleLib.Raster selectedRaster = ArcMapBrowse.BrowseOpenRaster(e.FormTitle, diWorkspace, sDataset, e.hWndParent);
// if (!(selectedRaster == null))
// {
// ((System.Windows.Forms.TextBox)sender).Text = selectedRaster.GISFileInfo.FullName;
// }
//}

private void BrowseSaveRaster(System.Windows.Forms.TextBox txt, string formTitle, IntPtr hParentWindowHandle)
{
Expand Down
66 changes: 33 additions & 33 deletions GCDCore/UserInterface/SurveyLibrary/frmImportRaster.cs
Expand Up @@ -202,7 +202,7 @@ private void SetupToolTips()
tTip.SetToolTip(txtOrigHeight, "The height of the original raster shown in the linear units of the raster.");
tTip.SetToolTip(txtOrigCellSize, "The width of each cell in the original raster shown in the linear units of the raster");
tTip.SetToolTip(txtRasterPath, "The raster file path where the output raster will get generated.");
tTip.SetToolTip(cmdSave,"Browse to specify the output raster file path where the cleaned raster will get generated.");
tTip.SetToolTip(cmdSave, "Browse to specify the output raster file path where the cleaned raster will get generated.");
tTip.SetToolTip(valTop, "The top, northern most extent of the output raster. It must be wholely divisible by the output cell resolution.");
tTip.SetToolTip(valLeft, "The left, western most extent of the output raster. It must be wholely divisible by the output cell resolution.");
tTip.SetToolTip(valRight, "The right, eastern most extent of the output raster. It must be wholely divisible by the output cell resolution.");
Expand Down Expand Up @@ -293,42 +293,38 @@ private bool ValidateForm()
return false;
}

bNeedsForcedProjection = false;

if (!GISDatasetValidation.DSSpatialRefMatchesProject(ucRaster.SelectedItem))
// Importing rasters into GCD projects reuires some unit checks
if (ExtImporter.Purpose != ExtentImporter.Purposes.Standalone)
{
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(ucRaster.SelectedItem, "raster", "rasters"));
if (!GISDatasetValidation.DSSpatialRefMatchesProject(ucRaster.SelectedItem))
{
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(ucRaster.SelectedItem, "raster", "rasters"));

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

if (result == DialogResult.No)
if (result == DialogResult.No)
{
ucRaster.Select();
bNeedsForcedProjection = false;
return false;
}
else
{
bNeedsForcedProjection = true;
}
}

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


if (!GISDatasetValidation.DSHorizUnitsMatchProject(ucRaster.SelectedItem, "raster", "rasters"))
{
ucRaster.Select();
return false;
}


// Importing rasters into GCD projects reuires some unit checks
if (ExtImporter.Purpose != ExtentImporter.Purposes.Standalone)
{
// Verify that the horizontal units match those of the project.
if (ProjectManager.Project.Units.HorizUnit != ucRaster.SelectedItem.Proj.HorizontalUnit)
{
Expand Down Expand Up @@ -369,7 +365,11 @@ private bool ValidateForm()
}
else
{
if (ProjectManager.Project.GetAbsolutePath(txtRasterPath.Text).Exists)
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;
Expand Down Expand Up @@ -574,7 +574,7 @@ public GCDConsoleLib.Raster ProcessRaster()

if (ExtImporter.RequiresResampling)
{
gResult = GCDConsoleLib.RasterOperators.BilinearResample(ucRaster.SelectedItem, fiOutput, ExtImporter.Output,
gResult = GCDConsoleLib.RasterOperators.BilinearResample(ucRaster.SelectedItem, fiOutput, ExtImporter.Output,
ProjectManager.OnProgressChange);
}
else
Expand All @@ -589,14 +589,14 @@ public GCDConsoleLib.Raster ProcessRaster()
}
else
{
gResult = GCDConsoleLib.RasterOperators.ExtendedCopy(ucRaster.SelectedItem, fiOutput,
gResult = GCDConsoleLib.RasterOperators.ExtendedCopy(ucRaster.SelectedItem, fiOutput,
ProjectManager.OnProgressChange);
}
}
else
{
// Output extent differs from original raster. Use extended copy
gResult = GCDConsoleLib.RasterOperators.ExtendedCopy(ucRaster.SelectedItem, fiOutput, ExtImporter.Output,
gResult = GCDConsoleLib.RasterOperators.ExtendedCopy(ucRaster.SelectedItem, fiOutput, ExtImporter.Output,
ProjectManager.OnProgressChange);
}
}
Expand All @@ -609,7 +609,7 @@ public GCDConsoleLib.Raster ProcessRaster()
// Now try the hillshade for DEM Surveys
System.IO.FileInfo sHillshadePath = Surface.HillShadeRasterPath(fiOutput);
GCDConsoleLib.RasterOperators.Hillshade(gResult, sHillshadePath, ProjectManager.OnProgressChange);
ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.Hillshade,
ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.Hillshade,
sHillshadePath);
}
}
Expand Down

0 comments on commit 53429b3

Please sign in to comment.