public static GCDConsoleLib.Raster BrowseRaster(string formTitle, IntPtr parentWindow) { FileInfo path = null; if (IsArcMap) { if (GISLayerBrowsingEventHandler != null) { naru.ui.PathEventArgs e = new naru.ui.PathEventArgs(path, formTitle, parentWindow); ProjectManager.GISLayerBrowsingEventHandler(null, e); if (e.Path is FileInfo) { path = e.Path; } } } else { path = naru.os.File.BrowseOpenFile(formTitle, "Raster Files (*.tif, *.tiff, *.img)|*.tif;*.tiff;*.img"); } GCDConsoleLib.Raster raster = null; if (path is FileInfo) { raster = new GCDConsoleLib.Raster(path); } return(raster); }
public void Initialize(string noun, GCDConsoleLib.Raster raster) { grpProperties.Text = string.Format("{0} {1}Properties", noun, noun.ToLower().EndsWith("raster") ? string.Empty : "Raster "); ItemProperties.Add(new GridViewPropertyValueItem("Raster Properties")); ItemProperties.Add(new GridViewPropertyValueItem("Cell size", UnitsNet.Length.From((double)raster.Extent.CellWidth, raster.Proj.HorizontalUnit).ToString(raster.Proj.HorizontalUnit))); ItemProperties.Add(new GridViewPropertyValueItem("Rows", raster.Extent.Rows.ToString("N0"))); ItemProperties.Add(new GridViewPropertyValueItem("Columns", raster.Extent.Cols.ToString("N0"))); ItemProperties.Add(new GridViewPropertyValueItem("Height", UnitsNet.Length.From((double)raster.Extent.Height, raster.Proj.HorizontalUnit).ToString(raster.Proj.HorizontalUnit))); ItemProperties.Add(new GridViewPropertyValueItem("Width", UnitsNet.Length.From((double)raster.Extent.Width, raster.Proj.HorizontalUnit).ToString(raster.Proj.HorizontalUnit))); ItemProperties.Add(new GridViewPropertyValueItem("Spatial Reference", raster.Proj.Wkt)); try { raster.ComputeStatistics(); Dictionary <string, decimal> stats = raster.GetStatistics(); ItemProperties.Add(new GridViewPropertyValueItem("Raster Statistics")); ItemProperties.Add(new GridViewPropertyValueItem("Maximum raster value", stats["max"].ToString("n2"))); ItemProperties.Add(new GridViewPropertyValueItem("Minimum raster value", stats["min"].ToString("n2"))); ItemProperties.Add(new GridViewPropertyValueItem("Mean raster value", stats["mean"].ToString("n2"))); ItemProperties.Add(new GridViewPropertyValueItem("Standard deviation of raster values", stats["stddev"].ToString("n2"))); } catch (Exception ex) { ItemProperties.Add(new GridViewPropertyValueItem("Raster Statistics", "Failed to compute statistics")); } }
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; } } } } }
public Surface(string name, GCDConsoleLib.Raster raster, GCDConsoleLib.Raster rHillShade) : base(name, raster) { if (rHillShade != null) { Hillshade = new HillShade(string.Format("{0} Hillshade", Noun), rHillShade); } ErrorSurfaces = new naru.ui.SortableBindingList <ErrorSurface>(); LinearExtractions = new List <LinearExtraction.LinearExtraction>(); }
public static IRasterDataset GetRasterDataset(GCDConsoleLib.Raster raster) { IWorkspace pWorkspace = GetWorkspace(raster.GISFileInfo); IRasterDataset pRDS = ((IRasterWorkspace)pWorkspace).OpenRasterDataset(raster.GISFileInfo.Name); int refsLeft = 0; do { refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComObject(pWorkspace); }while (refsLeft > 0); return(pRDS); }
public Surface Run(FileInfo rsPath, FileInfo errPath) { GCDConsoleLib.Raster rSurface = BuildReferenceSurface(rsPath); GCDConsoleLib.Raster rErrorSf = BuildErrorSurface(errPath); GCDConsoleLib.Raster rHillshd = GCDConsoleLib.RasterOperators.Hillshade(rSurface, Surface.HillShadeRasterPath(rsPath), ProjectManager.OnProgressChange); Surface refSurf = new GCDCore.Project.Surface(Name, rSurface, rHillshd); refSurf.ErrorSurfaces.Add(new ErrorSurface(ErrorSurfaceName, errPath, refSurf)); ProjectManager.Project.ReferenceSurfaces.Add(refSurf); ProjectManager.Project.Save(); return(refSurf); }
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"); } }
public void OnGISBrowseRaster(System.Windows.Forms.TextBox txt, naru.ui.PathEventArgs e) { System.IO.DirectoryInfo dir = null; string RasterName = string.Empty; if (e.Path is System.IO.FileInfo) { dir = e.Path.Directory; RasterName = System.IO.Path.GetFileName(e.Path.FullName); } GCDConsoleLib.Raster result = ArcMapBrowse.BrowseOpenRaster(e.FormTitle, dir, RasterName, e.hWndParent); if (result is GCDConsoleLib.Raster) { e.Path = result.GISFileInfo; } }
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"); } }
public static GCDConsoleLib.Raster BrowseOpenRaster(string sFormTitle, System.IO.DirectoryInfo diWorkspace, string sName, IntPtr hParentWindowHandle) { IGxDialog pGxDialog = new GxDialogClass(); IGxObjectFilter pRasterFilter = new GxFilterRasterDatasets(); IGxObjectFilterCollection pFilterCol = (IGxObjectFilterCollection)pGxDialog; pFilterCol.AddFilter(pRasterFilter, true); pGxDialog.RememberLocation = true; pGxDialog.AllowMultiSelect = false; pGxDialog.Title = sFormTitle; IEnumGxObject pEnumGx = null; IGxObject pGxObject = null; if (diWorkspace is System.IO.DirectoryInfo && diWorkspace.Exists) { pGxDialog.set_StartingLocation(diWorkspace.FullName); } GCDConsoleLib.Raster rResult = null; try { if (pGxDialog.DoModalOpen(hParentWindowHandle.ToInt32(), out pEnumGx)) { pGxObject = pEnumGx.Next(); System.IO.FileInfo sFile = new System.IO.FileInfo(pGxObject.FullName); sName = pGxObject.Name; diWorkspace = sFile.Directory; rResult = new GCDConsoleLib.Raster(new System.IO.FileInfo(pGxObject.FullName)); } } catch (Exception ex) { ex.Data["Title"] = sFormTitle; ex.Data["Name"] = sName; throw; } return(rResult); }
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; } } } } }
public DoDRaster(string name, GCDConsoleLib.Raster raster) : base(name, raster) { }
public DoDIntermediateRaster(string noun, GCDConsoleLib.Raster raster) : base(noun, raster) { _Noun = noun; }
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 void InitializeExisting(string sNoun, GCDConsoleLib.Raster raster) { base.InitializeExisting(sNoun, raster.GISFileInfo, ProjectManager.Project.GetRelativePath(raster.GISFileInfo)); }
public HillShade(string name, GCDConsoleLib.Raster raster) : base(name, raster) { }