Skip to content

Commit

Permalink
issue #37: Updates for batch geojson export
Browse files Browse the repository at this point in the history
  • Loading branch information
lbross committed Jan 13, 2023
1 parent 249f2ef commit 9d2de40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
5 changes: 3 additions & 2 deletions bagis-pro/AnalysisTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ public static async Task<string[]> GetStationValues(string aoiFilePath)
if (oSettings == null || String.IsNullOrEmpty(Convert.ToString(oSettings.gaugeStation)))
{
Module1.Current.ModuleLogManager.LogDebug(nameof(GetStationValues),
"Unable to retrieve pourpoint settings from " + url);
MessageBox.Show("Unable to retrieve pourpoint settings. Clipping cancelled!!", "BAGIS-PRO");
"Unable to retrieve gauge station uri from " + url);
MessageBox.Show("Unable to retrieve gauge station uri. Station values cannot be retrieved!!", "BAGIS-PRO");
return null;
}
string strWsUri = oSettings.gaugeStation;
Expand Down Expand Up @@ -631,6 +631,7 @@ public static async Task<string[]> GetStationValues(string aoiFilePath)
string[] arrFound = new string[arrSearch.Length];
Module1.Current.ModuleLogManager.LogDebug(nameof(GetStationValues),
"Using awdb_id to query for the triplet from " + usgsServiceUri.ToString());

arrFound = await ws.QueryServiceForValuesAsync(usgsServiceUri, usgsServiceLayerId, arrSearch, queryFilter);
if (arrFound != null && arrFound.Length > 1)
{
Expand Down
31 changes: 8 additions & 23 deletions bagis-pro/DockBatchPdfExportViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,16 @@ private async void RunSnodasImplAsync(object param)
{
if (await GeodatabaseTools.CountFeaturesAsync(new Uri(strAoiFolder), Constants.FILE_POURPOINT) == 1)
{
string stationTriplet = await GeodatabaseTools.QueryTableForSingleValueAsync(new Uri(strAoiFolder),
Constants.FILE_POURPOINT, Constants.FIELD_STATION_TRIPLET, new QueryFilter());
// Query for station information
string stationTriplet = "";
string[] arrValues = await AnalysisTools.GetStationValues(aoiFolder);
if (arrValues.Length == 2)
{
stationTriplet = arrValues[0];
}
if (string.IsNullOrEmpty(stationTriplet))
{
strLogEntry = DateTime.Now.ToString("MM/dd/yy H:mm:ss ") + "ERROR:Pourpoint layer is missing stationTriplet. Skipping this AOI \r\n";
strLogEntry = DateTime.Now.ToString("MM/dd/yy H:mm:ss ") + "ERROR:Station triplet cannot be determined. Skipping this AOI! \r\n";
File.AppendAllText(snodasLog, strLogEntry); // append
errorCount++;
}
Expand Down Expand Up @@ -968,32 +973,12 @@ private async void RunSnodasImplAsync(object param)
string strPolyPath = strAoiFolder + "\\" + Constants.FILE_AOI_VECTOR;
if (await GeodatabaseTools.FeatureClassExistsAsync(new Uri(strAoiFolder), Constants.FILE_AOI_VECTOR))
{
int intFeatures = await GeodatabaseTools.CountFeaturesAsync(new Uri(strAoiFolder), Constants.FILE_AOI_VECTOR);
string strFcPath = strPolyPath;
string strTempAoiPath = null;
if (intFeatures > 1)
{
strLogEntry = DateTime.Now.ToString("MM/dd/yy H:mm:ss ") + "AOI boundary has > 1 polygon. Buffering ... \r\n";
File.AppendAllText(snodasLog, strLogEntry); // append
strTempAoiPath = $@"{strAoiFolder}\tmpAoi";
success = await GeoprocessingTools.BufferAsync(strPolyPath, strTempAoiPath, "0.5 Meters", "ALL");
if (success == BA_ReturnCode.Success)
{
strFcPath = strTempAoiPath;
strLogEntry = DateTime.Now.ToString("MM/dd/yy H:mm:ss ") + "Successfully buffered AOI polygon \r\n";
File.AppendAllText(snodasLog, strLogEntry); // append
}
}
success = await GeoprocessingTools.FeaturesToSnodasGeoJsonAsync(strFcPath, polygonOutputPath, true);
if (success == BA_ReturnCode.Success)
{
strLogEntry = DateTime.Now.ToString("MM/dd/yy H:mm:ss ") + "AOI polygon geoJson exported to temp directory \r\n";
File.AppendAllText(snodasLog, strLogEntry); // append
if (!String.IsNullOrEmpty(strTempAoiPath))
{
// Clean up temp buffered FC
BA_ReturnCode rCode = await GeoprocessingTools.DeleteDatasetAsync(strTempAoiPath);
}
}
else
{
Expand Down

0 comments on commit 9d2de40

Please sign in to comment.