public void RasterDeleteTest() { using (ITempDir tmp = TempDir.Create()) { FileInfo sSourceRater = new FileInfo(DirHelpers.GetTestRasterPath("const990.tif")); FileInfo sDeletePath = new FileInfo(Path.Combine(tmp.Name, "DeleteRasterTest.tif")); Raster rRaster = new Raster(sSourceRater); rRaster.Copy(sDeletePath); // Make sure our setup worked Assert.IsTrue(sDeletePath.Exists); Raster rDeleteRaster = new Raster(sDeletePath); rDeleteRaster.Delete(); // Make sure we're good. sDeletePath.Refresh(); Assert.IsFalse(sDeletePath.Exists); Assert.IsFalse(File.Exists(Path.Combine(tmp.Name, "DeleteRasterTest.tif.aux.xml"))); Assert.IsFalse(File.Exists(Path.Combine(tmp.Name, "DeleteRasterTest.tif.ovr"))); rRaster.UnloadDS(); rDeleteRaster.UnloadDS(); rDeleteRaster = null; rRaster = null; } }
public void BasicRasterDSCopyTest() { using (ITempDir tmp = TempDir.Create()) { Raster rTemplaetRaster = new Raster(new FileInfo(DirHelpers.GetTestRasterPath("SinWave950-980.tif"))); rTemplaetRaster.Copy(new FileInfo(Path.Combine(tmp.Name, "CopyRasterTest.tif"))); // Make sure we're good. Assert.IsTrue(File.Exists(Path.Combine(tmp.Name, "CopyRasterTest.tif"))); Assert.IsTrue(File.Exists(Path.Combine(tmp.Name, "CopyRasterTest.tif.aux.xml"))); Assert.IsTrue(File.Exists(Path.Combine(tmp.Name, "CopyRasterTest.tif.ovr"))); rTemplaetRaster.UnloadDS(); rTemplaetRaster = null; } }
public Raster ProcessRaster() { Cursor = Cursors.WaitCursor; Raster gResult = null; System.IO.FileInfo fiOutput = ProjectManager.Project.GetAbsolutePath(txtRasterPath.Text); if (fiOutput.Exists) { Exception ex = new Exception("The raster path already exists."); ex.Data.Add("Raster path", txtRasterPath.Text); throw ex; } fiOutput.Directory.Create(); if (ExtImporter.RequiresResampling) { gResult = RasterOperators.BilinearResample(SourceRaster, fiOutput, ExtImporter.OutExtent, ProjectManager.OnProgressChange); } else { if (SourceRaster.Extent.Equals(ExtImporter.OutExtent)) { // Output extent is same as original raster. Simple dataset copy if (SourceRaster.driver == Raster.RasterDriver.GTiff) { SourceRaster.Copy(fiOutput); gResult = new Raster(fiOutput); } else { gResult = RasterOperators.ExtendedCopy(SourceRaster, fiOutput, ProjectManager.OnProgressChange); } } else { // Output extent differs from original raster. Use extended copy gResult = RasterOperators.ExtendedCopy(SourceRaster, fiOutput, ExtImporter.OutExtent, ProjectManager.OnProgressChange); } } // This method will check to see if pyrmaids are need and then build if necessary. PerformRasterPyramids(new System.IO.FileInfo(txtRasterPath.Text)); if (Purpose == Purposes.FirstDEM || Purpose == Purposes.SubsequentDEM || Purpose == Purposes.ReferenceSurface) { // Now try the hillshade for DEM Surveys and reference surfaces System.IO.FileInfo sHillshadePath = Surface.HillShadeRasterPath(fiOutput); RasterOperators.Hillshade(gResult, sHillshadePath, ProjectManager.OnProgressChange); ProjectManager.PyramidManager.PerformRasterPyramids(RasterPyramidManager.PyramidRasterTypes.Hillshade, sHillshadePath); } Cursor = Cursors.Default; Projection projRef = GISDatasetValidation.GetProjectProjection(); if (projRef != null && NeedsForcedProjection) { gResult.SetProjection(projRef); } return(gResult); }
protected override Raster GenerateErrorRaster(FileInfo errDoDPath) { PropagatedErrRaster.Copy(errDoDPath); return(new Raster(errDoDPath)); }