-
Notifications
You must be signed in to change notification settings - Fork 0
Aot testing #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Aot testing #33
Changes from all commits
b497fef
5cd6fea
cbbe6f8
314eaed
783b93e
6db1c22
d3c1cc9
f640372
c6bff3f
ee34bd6
c4b26ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include="..\GeoConsequences\bin\Release\net8.0\win-x64\publish\GeoConsequences.dll" Link="GeoConsequences.dll"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
|
|
||
| <Content Include="C:\Users\HEC\Downloads\GDAL\GDAL\bin64\*.dll"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These guys will always fail because we don't have the GDAL Build. We're going to need to set up some system to check if GDAL exists. Check if it's the right GDAL (optionally) , and if we don't, download it. This is a problem FDA has to solve too. We'll solve it together.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's our GDAL build. Look into Build events to trigger this: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-specify-build-events-csharp?view=vs-2022 |
||
| <Link>%(RecursiveDir)%(FileName)%(Extension)</Link> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </Content> | ||
| <Content Include="C:\Users\HEC\Downloads\GDAL\GDAL\common\data\*.db"> | ||
| <Link>%(RecursiveDir)%(FileName)%(Extension)</Link> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </Content> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using System.Net.NetworkInformation; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| internal class Program | ||
| { | ||
| private static void Main(string[] args) | ||
| { | ||
| Console.WriteLine("===========================TESTING GEOCONSEQUENCES NATIVE LIBRARY==========================="); | ||
| TestImport.InitializeGDAL(); | ||
|
|
||
| Console.WriteLine("===========================READING FROM THE NSI============================================="); | ||
| TestImport.ReadNSI(-122.48, 37.76, -122.479, 37.759, 0); | ||
|
|
||
| Console.WriteLine("===========================READING FROM THE NSI AND WRITING TO SHAPEFILE===================="); | ||
| IntPtr path = Marshal.StringToHGlobalAnsi(@"C:\repos\consequences\AOTTest\generated"); | ||
| IntPtr driver = Marshal.StringToHGlobalAnsi("ESRI Shapefile"); | ||
| int projection = 3310; | ||
| IntPtr x = Marshal.StringToHGlobalAnsi("x"); | ||
| IntPtr y = Marshal.StringToHGlobalAnsi("y"); | ||
| TestImport.WriteNSIToShapefile(path, driver, projection, x, y, -122.48, 37.76, -122.479, 37.759); | ||
| } | ||
| } | ||
|
|
||
| public class TestImport | ||
| { | ||
| [DllImport("GeoConsequences.dll")] | ||
| public static extern int ReadNSI(double ulX, double ulY, double lrX, double lrY, int actionIndex); | ||
|
|
||
| [DllImport("GeoConsequences.dll")] | ||
| public static extern int InitializeGDAL(); | ||
|
|
||
| [DllImport("GeoConsequences.dll")] | ||
| public static extern int WriteNSIToShapefile(IntPtr outputPath, IntPtr driverName, int projection, IntPtr xField, IntPtr yField, double ulX, double ulY, double lrX, double lrY); | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "profiles": { | ||
| "AOTTest": { | ||
| "commandName": "Project", | ||
| "nativeDebugging": true | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| using USACE.HEC.Geography; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using USACE.HEC.Geography; | ||
|
|
||
| namespace USACE.HEC.Consequences; | ||
| public interface IStreamingProcessor | ||
| { | ||
| public void Process<T>(Action<IConsequencesReceptor> consequenceReceptorProcess) where T : IConsequencesReceptor, new(); | ||
| public void Process<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(Action<IConsequencesReceptor> consequenceReceptorProcess) where T : IConsequencesReceptor, new(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using System.Runtime.InteropServices; | ||
| using USACE.HEC.Consequences; | ||
| using USACE.HEC.Geography; | ||
|
|
||
| namespace USACE.HEC.ExternalMethods; | ||
|
|
||
| public class NSI | ||
| { | ||
| /// <summary> | ||
| /// Specify (x,y) coordinates for upper left and lower right corners of the bounding box, as well | ||
| /// as an index corresponding to a specific action from a preset list of actions that we define, | ||
| /// to be performed on each structure that gets read (TODO) | ||
| /// </summary> | ||
| [UnmanagedCallersOnly(EntryPoint = "ReadNSI")] | ||
| public static int Read(double ulX, double ulY, double lrX, double lrY, int actionIndex) | ||
| { | ||
| Location upperLeft = new Location { X = ulX, Y = ulY }; | ||
| Location lowerRight = new Location { X = lrX, Y = lrY }; | ||
| BoundingBox boundingBox = new BoundingBox(upperLeft, lowerRight); | ||
|
|
||
| NSIStreamingProcessor sp = new NSIStreamingProcessor(); | ||
|
|
||
| // going forward a user will be able to specify an action on the structures | ||
| int count = 0; | ||
| Task task = sp.Process(boundingBox, (IConsequencesReceptor s) => { | ||
| Console.WriteLine(((Structure)s).Name); | ||
| Console.WriteLine("hi"); | ||
| count++; | ||
| }); | ||
|
|
||
| task.Wait(); | ||
|
|
||
| return count; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ public ResultItem Fetch(string name) | |
| for (int i = 0; i < ResultItems.Length; i++) | ||
| if (ResultItems[i].ResultName == name) | ||
| return ResultItems[i]; | ||
| // return empty ResultItem if not found | ||
| return new ResultItem { ResultName = name }; | ||
| throw new ArgumentException($"{name} not found in result"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I appreciate this. We can relax this explosion later if we want, but defaulting to exploding on the error rather than hiding it is probably good practice. |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,5 @@ | |
| public struct ResultItem | ||
| { | ||
| public string ResultName; | ||
| public object Result; | ||
| public object ResultValue; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.