Skip to content

Commit

Permalink
ISSUE #50: Clip to aoi_v rather than buffered aoi
Browse files Browse the repository at this point in the history
  • Loading branch information
lbross committed Mar 22, 2024
1 parent 99180e7 commit 9bb7316
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions bagis-pro/DockAdminToolsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,18 +1864,31 @@ private async void RunFireDataImplAsync(object param)
}
}

string[] arrUnmanagedBufferInfo = await GeneralTools.QueryBufferDistanceAsync(aoiFolder, GeodatabaseTools.GetGeodatabasePath(aoiFolder, GeodatabaseNames.Aoi),
Constants.FILE_AOI_BUFFERED_VECTOR, false);
string unmanagedBufferDistance = arrUnmanagedBufferInfo[0];
string unmanagedBufferUnits = arrUnmanagedBufferInfo[1];
// Used this when clipping to aoi_b_v
//string[] arrUnmanagedBufferInfo = await GeneralTools.QueryBufferDistanceAsync(aoiFolder, GeodatabaseTools.GetGeodatabasePath(aoiFolder, GeodatabaseNames.Aoi),
// Constants.FILE_AOI_BUFFERED_VECTOR, false);
//string unmanagedBufferDistance = arrUnmanagedBufferInfo[0];
//string unmanagedBufferUnits = arrUnmanagedBufferInfo[1];

//Clip fire layers
Webservices ws = new Webservices();
Module1.Current.ModuleLogManager.LogDebug(nameof(RunFireDataImplAsync),
"Contacting webservices server to retrieve layer metadata");
IDictionary<string, dynamic> dictDataSources = await ws.QueryDataSourcesAsync();
string strWsUri = dictDataSources[Constants.DATA_TYPE_FIRE_HISTORY].uri;

FeatureLayer lyrHistory = null;
string strOutputFc = GeodatabaseTools.GetGeodatabasePath(aoiFolder, GeodatabaseNames.Layers, true)
+ Constants.FILE_FIRE_HISTORY;
success = await AnalysisTools.ClipFeatureLayerAsync(aoiFolder, strOutputFc, Constants.DATA_TYPE_FIRE_HISTORY,
unmanagedBufferDistance, unmanagedBufferUnits);
if (success == BA_ReturnCode.Success)
string strClipFile = GeodatabaseTools.GetGeodatabasePath(aoiFolder, GeodatabaseNames.Aoi, true)
+ Constants.FILE_AOI_VECTOR;
//success = await AnalysisTools.ClipFeatureLayerAsync(aoiFolder, strOutputFc, Constants.DATA_TYPE_FIRE_HISTORY,
// "0", "Meters");
var environmentsClip = Geoprocessing.MakeEnvironmentArray(workspace: aoiFolder);
var parametersClip = Geoprocessing.MakeValueArray(strWsUri, strClipFile, strOutputFc, "");
var gpResultClip = await Geoprocessing.ExecuteToolAsync("Clip_analysis", parametersClip, environmentsClip,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (!gpResultClip.IsFailed)
{
success = await GeoprocessingTools.AddFieldAsync(strOutputFc, Constants.FIELD_YEAR, "SHORT");
if (success == BA_ReturnCode.Success)
Expand Down Expand Up @@ -1907,12 +1920,13 @@ await QueuedTask.Run(() =>
}
}
}

strWsUri = dictDataSources[Constants.DATA_TYPE_FIRE_CURRENT].uri;
strOutputFc = GeodatabaseTools.GetGeodatabasePath(aoiFolder, GeodatabaseNames.Layers, true)
+ Constants.FILE_FIRE_CURRENT;
success = await AnalysisTools.ClipFeatureLayerAsync(aoiFolder, strOutputFc, Constants.DATA_TYPE_FIRE_CURRENT,
unmanagedBufferDistance, unmanagedBufferUnits);
if (success == BA_ReturnCode.Success)
parametersClip = Geoprocessing.MakeValueArray(strWsUri, strClipFile, strOutputFc, "");
gpResultClip = await Geoprocessing.ExecuteToolAsync("Clip_analysis", parametersClip, environmentsClip,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
if (! gpResultClip.IsFailed)
{
success = await GeoprocessingTools.AddFieldAsync(strOutputFc, Constants.FIELD_YEAR, "SHORT");
if (success == BA_ReturnCode.Success)
Expand Down

0 comments on commit 9bb7316

Please sign in to comment.