From e4045570b0da38319ddccc280118c0a332cce4db Mon Sep 17 00:00:00 2001 From: lbross Date: Fri, 21 Apr 2023 14:43:57 -0700 Subject: [PATCH] issue #40: Fix bug with creating merged_sites layer where Alaska basins were using wrong DEM; Found another manifestation of the 3.x image service clip error and added extent; Need to verify correct extent --- bagis-pro/AnalysisTools.cs | 6 +++-- bagis-pro/DockBatchToolsViewModel.cs | 1 - bagis-pro/Module1.cs | 1 - bagis-pro/Webservices.cs | 36 ++++++++++++++++++---------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/bagis-pro/AnalysisTools.cs b/bagis-pro/AnalysisTools.cs index 55c86f9..89072ec 100644 --- a/bagis-pro/AnalysisTools.cs +++ b/bagis-pro/AnalysisTools.cs @@ -4766,7 +4766,8 @@ await QueuedTask.Run(() => { // Assign the site id by elevation success = await UpdateSiteIdsAsync(analysisPath, gdbUri, arrHasSites, arrSiteFiles); - var environments = Geoprocessing.MakeEnvironmentArray(workspace: strAoiPath, snapRaster: BA_Objects.Aoi.SnapRasterPath(strAoiPath)); + var environments = Geoprocessing.MakeEnvironmentArray(workspace: strAoiPath, snapRaster: BA_Objects.Aoi.SnapRasterPath(strAoiPath), + extent: BA_Objects.Aoi.SnapRasterPath(strAoiPath)); string fileExtract = "tmpExtract"; string[] arrFields = { Constants.FIELD_PRECIP, Constants.FIELD_ASPECT, Constants.FIELD_SLOPE}; string[] arrFieldDataTypes = { "DOUBLE", "DOUBLE", "DOUBLE" }; @@ -4814,7 +4815,8 @@ await QueuedTask.Run(() => { if (arrIsImageService[i] == true || await GeodatabaseTools.RasterDatasetExistsAsync(new Uri(arrUri[i]), arrInputRasters[i])) { var parameters = Geoprocessing.MakeValueArray(returnPath, inputRaster, analysisPath + "\\" + fileExtract, "NONE", "VALUE_ONLY"); - var gpResult = await Geoprocessing.ExecuteToolAsync("ExtractValuesToPoints_sa", parameters, environments, + + var gpResult = await Geoprocessing.ExecuteToolAsync("ExtractValuesToPoints_sa", parameters, environments, CancelableProgressor.None, GPExecuteToolFlags.AddToHistory); if (gpResult.IsFailed) { diff --git a/bagis-pro/DockBatchToolsViewModel.cs b/bagis-pro/DockBatchToolsViewModel.cs index 093de05..142997e 100644 --- a/bagis-pro/DockBatchToolsViewModel.cs +++ b/bagis-pro/DockBatchToolsViewModel.cs @@ -1105,7 +1105,6 @@ private async void RunForecastImplAsync(object param) string strTriplet = ""; string strStationName = ""; string strAwdbId = ""; - string strHuc2 = ""; string strNearTriplet = ""; string strNearStationName = ""; string strNearAwdbId = ""; diff --git a/bagis-pro/Module1.cs b/bagis-pro/Module1.cs index 2860c3d..86d2d4b 100644 --- a/bagis-pro/Module1.cs +++ b/bagis-pro/Module1.cs @@ -116,7 +116,6 @@ protected override bool Initialize() internal dynamic BatchToolSettings { get; set; } = ""; internal double PrismZonesInterval { get; set; } = 999; internal string WesternStateBoundariesUri { get; } = ""; - internal string Dem30Uri { get; } = ""; internal string RoadsBufferDistance { get; set; } = ""; internal string DataSourceGroup { get; set; } = Constants.DATA_SOURCES_DEFAULT; internal string ChromePath { get; set; } = ""; diff --git a/bagis-pro/Webservices.cs b/bagis-pro/Webservices.cs index 3629b68..dccf521 100644 --- a/bagis-pro/Webservices.cs +++ b/bagis-pro/Webservices.cs @@ -331,26 +331,36 @@ public async Task GetWesternStateBoundariesUriAsync() public async Task GetDem30UriAsync() { - if (!string.IsNullOrEmpty(Module1.Current.Dem30Uri)) + IDictionary dictLocalDataSources = GeneralTools.QueryLocalDataSources(); + if (!dictLocalDataSources.ContainsKey(BA_Objects.DataSource.GetDemKey)) { - return Module1.Current.Dem30Uri; - } - else - { - var response = new EsriHttpClient().Get(Constants.URI_DESKTOP_SETTINGS); - var json = await response.Content.ReadAsStringAsync(); - dynamic oSettings = JObject.Parse(json); - if (oSettings == null || String.IsNullOrEmpty(Convert.ToString(oSettings.dem30))) + IDictionary dictDatasources = await this.QueryDataSourcesAsync((string)Module1.Current.BatchToolSettings.EBagisServer); + if (dictDatasources != null) { - Module1.Current.ModuleLogManager.LogError(nameof(GetDem30UriAsync), - "Unable to retrieve settings from " + Constants.URI_DESKTOP_SETTINGS); - return ""; + BA_Objects.DataSource dsDem = new BA_Objects.DataSource(dictDatasources[BA_Objects.DataSource.GetDemKey]); + if (dsDem != null) + { + return dsDem.uri; + } + else + { + Module1.Current.ModuleLogManager.LogError(nameof(GetDem30UriAsync), + $@"Unable to find element 30m DEM in server data sources"); + return ""; + } } else { - return Convert.ToString(oSettings.dem30); + Module1.Current.ModuleLogManager.LogError(nameof(GetDem30UriAsync), + $@"Unable to retrieve data sources from server!"); + return ""; } } + else + { + BA_Objects.DataSource dsDem = new BA_Objects.DataSource(dictLocalDataSources[BA_Objects.DataSource.GetDemKey]); + return dsDem.uri; + } } public async Task UpdateAoiItemsAsync(string stationTriplet)