Skip to content

Commit

Permalink
Update AdminMenu to true; issue #48: Re-arrange some menu items; issue
Browse files Browse the repository at this point in the history
…#53: Start snapping to source DEM, Fix display of flow accumulation layer
  • Loading branch information
lbross committed Dec 3, 2024
1 parent 6b2a95c commit 41db672
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Settings/bagis-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"MaximumSitesAllowed": 50,
"WinterStartMonth": 11,
"WinterEndMonth": 3,
"AdminMenu": false,
"AdminMenu": true,
"USStateBoundaries": "https://services.arcgis.com/ue9rwulIoeLEI9bj/arcgis/rest/services/US_StateBoundaries/FeatureServer/0",
"FireNifcMinYear": 780,
"FireMtbsMinYear": 1984,
Expand Down Expand Up @@ -183,6 +183,6 @@
"Severity": "None"
}
],
"Version": 18
"Version": 19
}
}
4 changes: 2 additions & 2 deletions bagis-pro/AnalysisTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,7 @@ await QueuedTask.Run(async () =>
}

public static async Task<BA_ReturnCode> ClipRasterLayerNoBufferAsync(string strAoiPath, string strClipPath, string strClipExtent,
string inputRaster, string outputRaster)
string inputRaster, string outputRaster, string snapRasterPath)
{
// Query the extent for the clip
string strClipGdb = Path.GetDirectoryName(strClipPath);
Expand All @@ -3077,7 +3077,7 @@ public static async Task<BA_ReturnCode> ClipRasterLayerNoBufferAsync(string strA
var parameters = Geoprocessing.MakeValueArray(inputRaster, strClipEnvelope, outputRaster, strClipPath,
"", "ClippingGeometry");
// Always set the extent if clipping from an image service
var environments = Geoprocessing.MakeEnvironmentArray(workspace: strAoiPath, extent: strClipEnvelope);
var environments = Geoprocessing.MakeEnvironmentArray(workspace: strAoiPath, snapRaster: snapRasterPath, extent: strClipEnvelope);
var gpResult = await Geoprocessing.ExecuteToolAsync("Clip_management", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (gpResult.IsFailed)
Expand Down
8 changes: 4 additions & 4 deletions bagis-pro/Config.daml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
<button refID="bagis_pro_Menus_MnuMaps_BtnSelectAoi" size="middle" />
<button refID="bagis_pro_DockpaneLayers_ShowButton" size="middle" />
<button refID="bagis_pro_DockAnalysisLayers_ShowButton" size="middle" />
<button refID="bagis_pro_WinExportPdf" size="middle" />
<button refID="bagis_pro_Menus_MnuMaps_BtnMapLoad" size="middle" />
<buttonPalette refID="bagis_pro_Buttons_MapButtonPalette" size="middle" />
<button refID="bagis_pro_WinExportPdf" size="middle" />
<button refID="bagis_pro_Buttons_BtnExcelTables" size="middle" />
<button refID="bagis_pro_DockMapPackage_ShowButton" size="middle" />
</group>
Expand Down Expand Up @@ -190,10 +190,10 @@
<tooltip heading="Tooltip Heading">Selected AOI<disabledText /></tooltip>
</comboBox>
<labelControl id="bagis_pro_Buttons_LblCurrentAoi" caption=" Selected AOI" />
<button id="bagis_pro_DockpaneLayers_ShowButton" caption="Clip Layers" className="DockpaneLayers_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/PaperClip32.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/PaperClip32.png" condition="AdminMenu_ShowButton_Condition" keytip="B55">
<button id="bagis_pro_DockpaneLayers_ShowButton" caption="1. Clip Layers" className="DockpaneLayers_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/PaperClip32.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/PaperClip32.png" condition="AdminMenu_ShowButton_Condition" keytip="B55">
<tooltip heading="Clip Layers">Clip Layers<disabledText>Contact your administrator for permissions to run this tool</disabledText></tooltip>
</button>
<button id="bagis_pro_DockAnalysisLayers_ShowButton" caption="Generate Analysis Layers" className="DockAnalysisLayers_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/CalculateGeometry16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/CalculateGeometry32.png" condition="AdminMenu_ShowButton_Condition" keytip="B56">
<button id="bagis_pro_DockAnalysisLayers_ShowButton" caption="2. Generate Analysis Layers" className="DockAnalysisLayers_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/CalculateGeometry16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/CalculateGeometry32.png" condition="AdminMenu_ShowButton_Condition" keytip="B56">
<tooltip heading="Generate Analysis Layers">Generate Analysis Layers<disabledText>Contact your administrator for permissions to run this tool</disabledText></tooltip>
</button>
<!--<button id="bagis_pro_DockBatchPdfExport_ShowButton" caption="Batch PDF Export" className="DockBatchPdfExport_ShowButton" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/JobExport16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/JobExport16.png" keytip="B57">
Expand Down Expand Up @@ -221,7 +221,7 @@
Export Map Package to PDF<disabledText />
</tooltip>
</button> -->
<button id="bagis_pro_WinExportPdf" caption="Export Map Package" className="BtnWinExportPdf" loadOnClick="true" smallImage="Images\PdfIcon.png" largeImage="Images\PdfIcon.png" condition="BtnExportToPdf_Condition" keytip="B14">
<button id="bagis_pro_WinExportPdf" caption="3. Export Map Package" className="BtnWinExportPdf" loadOnClick="true" smallImage="Images\PdfIcon.png" largeImage="Images\PdfIcon.png" condition="BtnExportToPdf_Condition" keytip="B14">
<tooltip heading="Export Map Package">Click to export Map Package to PDF<disabledText /></tooltip>
</button>
</controls>
Expand Down
34 changes: 25 additions & 9 deletions bagis-pro/DockCreateAOIfromExistingBNDViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Windows;
Expand Down Expand Up @@ -402,7 +403,7 @@ await QueuedTask.Run(() =>
{
IGPResult gpResult = await QueuedTask.Run(() =>
{
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath);
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: strSourceDem);
var parameters = Geoprocessing.MakeValueArray(SourceFile, fieldRasterId, aoiRasterPath, cellSize);
return Geoprocessing.ExecuteToolAsync("FeatureToRaster_conversion", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
Expand Down Expand Up @@ -491,12 +492,12 @@ await QueuedTask.Run(() =>
if (bDemImageService)
{
success = await AnalysisTools.ClipRasterLayerNoBufferAsync(oAoi.FilePath, strOutputFeatures, Constants.FILE_AOI_BUFFERED_VECTOR,
strSourceDem, tempOutput);
strSourceDem, tempOutput, strSourceDem);
}
else
{
success = await AnalysisTools.ClipRasterLayerNoBufferAsync(oAoi.FilePath, strOutputFeatures, Constants.FILE_AOI_BUFFERED_VECTOR,
strSourceDem, tempOutput);
strSourceDem, tempOutput, strSourceDem);
}
string strDem = $@"{surfacesGdbPath}\{Constants.FILE_DEM}";
if (success == BA_ReturnCode.Success)
Expand All @@ -506,7 +507,7 @@ await QueuedTask.Run(() =>
string envExtent = await GeodatabaseTools.GetEnvelope(aoiGdbPath, Constants.FILE_AOI_BUFFERED_VECTOR);
string neighborhood = "Rectangle " + FilterCellWidth + " " + FilterCellHeight + " CELL";
var parameters = Geoprocessing.MakeValueArray(tempOutput, strDem, neighborhood, "MEAN", "DATA");
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, extent: envExtent, mask: $@"{surfacesGdbPath}\{tempDem}");
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, extent: envExtent, mask: $@"{surfacesGdbPath}\{tempDem}", snapRaster: strSourceDem);
var gpResult = await Geoprocessing.ExecuteToolAsync("FocalStatistics_sa", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (gpResult.IsFailed)
Expand Down Expand Up @@ -572,7 +573,7 @@ await QueuedTask.Run(() =>
if (success == BA_ReturnCode.Success)
{
var parameters = Geoprocessing.MakeValueArray(strDem, filledDemPath);
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, mask: $@"{strDem}");
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, mask: $@"{strDem}", snapRaster: strSourceDem);
var gpResult = await Geoprocessing.ExecuteToolAsync("Fill_sa", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (gpResult.IsFailed)
Expand Down Expand Up @@ -639,7 +640,7 @@ await QueuedTask.Run(() =>
}
var parameters = Geoprocessing.MakeValueArray(filledDemPath, $@"{surfacesGdbPath}\{Constants.FILE_SLOPE}",
"PERCENT_RISE", zFactor);
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: Aoi.SnapRasterPath(oAoi.FilePath));
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: strSourceDem);
var gpResult = await Geoprocessing.ExecuteToolAsync("Slope_sa", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (gpResult.IsFailed)
Expand All @@ -666,7 +667,7 @@ await QueuedTask.Run(() =>
{
var parameters = Geoprocessing.MakeValueArray(filledDemPath,
$@"{surfacesGdbPath}\{Constants.FILE_ASPECT}");
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: Aoi.SnapRasterPath(oAoi.FilePath));
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: strSourceDem);
var gpResult = await Geoprocessing.ExecuteToolAsync("Aspect_sa", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (gpResult.IsFailed)
Expand All @@ -691,7 +692,7 @@ await QueuedTask.Run(() =>
{
var parameters = Geoprocessing.MakeValueArray(filledDemPath,
$@"{surfacesGdbPath}\{Constants.FILE_FLOW_DIRECTION}");
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: Aoi.SnapRasterPath(oAoi.FilePath));
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: strSourceDem);
var gpResult = await Geoprocessing.ExecuteToolAsync("FlowDirection_sa", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (gpResult.IsFailed)
Expand All @@ -715,7 +716,7 @@ await QueuedTask.Run(() =>
{
var parameters = Geoprocessing.MakeValueArray($@"{surfacesGdbPath}\{Constants.FILE_FLOW_DIRECTION}",
$@"{surfacesGdbPath}\{ Constants.FILE_FLOW_ACCUMULATION}");
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: Aoi.SnapRasterPath(oAoi.FilePath));
var environments = Geoprocessing.MakeEnvironmentArray(workspace: oAoi.FilePath, snapRaster: strSourceDem);
var gpResult = await Geoprocessing.ExecuteToolAsync("FlowAccumulation_sa", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (gpResult.IsFailed)
Expand All @@ -728,6 +729,21 @@ await QueuedTask.Run(() =>
{
uri = new Uri($@"{surfacesGdbPath}\{Constants.FILE_FLOW_ACCUMULATION}");
await MapTools.DisplayRasterStretchSymbolAsync(Constants.MAPS_DEFAULT_MAP_NAME, uri, "Flow Accumulation", "ArcGIS Colors", "Black to White", 0);
await QueuedTask.Run(() =>
{
var rasterLayer = oMap.GetLayersAsFlattenedList().OfType<RasterLayer>().Where(f =>
f.Name == "Flow Accumulation").FirstOrDefault();
CIMRasterColorizer rColorizer = rasterLayer.GetColorizer();
// Check if the colorizer is an RGB colorizer.
if (rColorizer is CIMRasterStretchColorizer stretchColorizer)
{
// Update RGB colorizer properties.
stretchColorizer.StretchType = RasterStretchType.HistogramEqualize;
stretchColorizer.StatsType = RasterStretchStatsType.AreaOfView;
// Update the raster layer with the changed colorizer.
rasterLayer.SetColorizer(stretchColorizer);
}
});
}
}
}
Expand Down

0 comments on commit 41db672

Please sign in to comment.