Skip to content

Commit

Permalink
added initial interfaces and implementations for processors after the…
Browse files Browse the repository at this point in the history
… video call #23 #24 #25
  • Loading branch information
jackschonherr committed Aug 26, 2024
1 parent f8d8687 commit b8bcdd5
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Consequences/Consequences/IBBoxStreamingProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using USACE.HEC.Geography;

namespace USACE.HEC.Consequences;
public interface IBBoxStreamingProcessor
{
public void Process(BoundingBox boundingBox, Action<IConsequencesReceptor> consequenceReceptorProcess);
}
51 changes: 51 additions & 0 deletions Consequences/Consequences/NSIStreamingProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using USACE.HEC.Geography;

namespace USACE.HEC.Consequences;
public class NSIStreamingProcessor : IBBoxStreamingProcessor
{
public void Process(BoundingBox boundingBox, Action<IConsequencesReceptor> ConsequenceReceptorProcess)
{
Structure s = new Structure();
ConsequenceReceptorProcess(s);
}



/*
static async Task Test()
{
// Define the API endpoint
string apiEndpoint = "https://nsi.sec.usace.army.mil/nsiapi/structures?bbox=-81.58418,30.25165,-81.58161,30.26939,-81.55898,30.26939,-81.55281,30.24998,-81.58418,30.25165";
// Create an instance of HttpClient
using (HttpClient client = new HttpClient())
{
try
{
// Make the GET request
HttpResponseMessage response = await client.GetAsync(apiEndpoint);
// Check if the request was successful
response.EnsureSuccessStatusCode();
// Read and process the response content
string responseBody = await response.Content.ReadAsStringAsync();
// Output the response content (for demonstration purposes)
Console.WriteLine("API Response:");
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
// Handle any errors that occur during the request
Console.WriteLine($"Request error: {e.Message}");
}
}
}
*/
}
2 changes: 1 addition & 1 deletion Consequences/Consequences/Structure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace USACE.HEC.Consequences;
public class Structure : IConsequencesReceptor
{
[JsonPropertyName("fd_id")]
public string Name { get; set; }
public int Name { get; set; }

[JsonPropertyName("st_damcat")]
public string DamCat { get; set; }
Expand Down
29 changes: 29 additions & 0 deletions ConsequencesTest/NSIStreamingProcessorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization;
using USACE.HEC.Consequences;
using USACE.HEC.Geography;
using USACE.HEC.Hazards;
using USACE.HEC.Results;

namespace ConsequencesTest;
public class NSIStreamingProcessorTest
{
[Fact]
public void Test()
{
IBBoxStreamingProcessor sp = new NSIStreamingProcessor();
// int i = 0;
Location upperLeft = new Location { X = -40, Y = 50 };
IHazardProvider depthHazardProvider = new RandomDepthHazardProvider(25);
IResultsWriter consoleWriter = new ConsoleWriter();

sp.Process(depthHazardProvider.Extent(), (IConsequencesReceptor s) => {
Result r = s.Compute(depthHazardProvider.Hazard(upperLeft));
consoleWriter.Write(r);
});
}
}

0 comments on commit b8bcdd5

Please sign in to comment.