diff --git a/Examples/Examples.csproj b/Examples/Examples.csproj
new file mode 100644
index 0000000..5050edb
--- /dev/null
+++ b/Examples/Examples.csproj
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/Examples/Program.cs b/Examples/Program.cs
new file mode 100644
index 0000000..f4d0a02
--- /dev/null
+++ b/Examples/Program.cs
@@ -0,0 +1,2 @@
+//Currently one 1 example
+RasterPrescriptions.ExportExamplePrescription();
\ No newline at end of file
diff --git a/Examples/RasterPrescriptions.cs b/Examples/RasterPrescriptions.cs
new file mode 100644
index 0000000..7301d59
--- /dev/null
+++ b/Examples/RasterPrescriptions.cs
@@ -0,0 +1,81 @@
+//While ISO1173-10 (and this plugin) supports vector prescriptions, industry adoption is limited.
+//Raster prescriptions are commonly used.
+
+using AgGateway.ADAPT.ApplicationDataModel;
+using AgGateway.ADAPT.ApplicationDataModel.Common;
+using AgGateway.ADAPT.ApplicationDataModel.Products;
+using AgGateway.ADAPT.ApplicationDataModel.Prescriptions;
+using AgGateway.ADAPT.ApplicationDataModel.Representations;
+using AgGateway.ADAPT.ApplicationDataModel.ADM;
+using AgGateway.ADAPT.ApplicationDataModel.Shapes;
+using AgGateway.ADAPT.ApplicationDataModel.Documents;
+
+class RasterPrescriptions
+{
+ public static void ExportExamplePrescription()
+ {
+ var adm = new ApplicationDataModel
+ {
+ Catalog = new Catalog
+ {
+ Products = new List
+ {
+ new GenericProduct { Description = "Product 1", Category = CategoryEnum.Fertilizer, ProductType = ProductTypeEnum.Fertilizer, Form = ProductFormEnum.Solid, Status = ProductStatusEnum.Active },
+ new GenericProduct { Description = "Product 2", Category = CategoryEnum.Fungicide, ProductType = ProductTypeEnum.Chemical, Form = ProductFormEnum.Liquid, Status = ProductStatusEnum.Active },
+ new GenericProduct { Description = "Product 3", Category = CategoryEnum.Herbicide, ProductType = ProductTypeEnum.Chemical, Form = ProductFormEnum.Liquid, Status = ProductStatusEnum.Active },
+ new GenericProduct { Description = "Product 4", Category = CategoryEnum.Insecticide, ProductType = ProductTypeEnum.Chemical, Form = ProductFormEnum.Liquid, Status = ProductStatusEnum.Active }
+ },
+ },
+ Documents = new Documents()
+ };
+
+ var rx = new RasterGridPrescription
+ {
+ CellHeight = new NumericRepresentationValue { Value = new NumericValue(new UnitOfMeasure(), 0.001) }, //In ISO1173-10, cell size is listed in degrees of lat/lon
+ CellWidth = new NumericRepresentationValue { Value = new NumericValue(new UnitOfMeasure(), 0.002) },
+ ColumnCount = 10,
+ RowCount = 5,
+ OperationType = OperationTypeEnum.SowingAndPlanting,
+ Origin = new Point { X = -87.60, Y = 41.88 }, //SW Corner
+ RxProductLookups = adm.Catalog.Products.Select(x => new RxProductLookup { ProductId = x.Id.ReferenceId, UnitOfMeasure = new UnitOfMeasure { } }).ToList(),
+ ProductIds = adm.Catalog.Products.Select(x => x.Id.ReferenceId).ToList(),
+ Rates = new List(),
+ Description = "RasterRx"
+ };
+
+ for (int h = 0; h < rx.RowCount; h++) //Rates in ADAPT/ISOXML Raster prescriptions are in a simple list, starting at the SW cell and going row-by-row left to right
+ {
+ for (int w = 0; w < rx.ColumnCount; w++)
+ {
+ var rates = rx.RxProductLookups.Select((x, i) => new RxRate
+ {
+ Rate = h * rx.ColumnCount + w + i * 100, //Dummy rates for the example for illustrative purposes
+ RxProductLookupId = x.Id.ReferenceId
+ }).ToList();
+ rx.Rates.Add(new RxCellLookup { RxRates = rates });
+ }
+ }
+
+ adm.Catalog.Prescriptions = new List { rx };
+
+ //The plugin is currently only recognizes Prescriptions mapped through Work Items and Work Item Operations
+ //See TaskDataMapper.cs at "Tasks" export
+ var workItemOperation = new WorkItemOperation
+ {
+ PrescriptionId = rx.Id.ReferenceId
+ };
+ adm.Documents.WorkItemOperations = new List { workItemOperation };
+
+ var workItem = new WorkItem
+ {
+ WorkItemOperationIds = new List() { workItemOperation.Id.ReferenceId }
+ };
+ adm.Documents.WorkItems = new List { workItem };
+
+
+ var plugin = new AgGateway.ADAPT.ISOv4Plugin.Plugin();
+ var properties = new AgGateway.ADAPT.ApplicationDataModel.ADM.Properties();
+ properties.SetProperty("GridType", "2"); //ISOXML has 2 formats of grid prescriptions. 2 is the default if this property is omitted.
+ plugin.Export(adm, System.IO.Directory.GetCurrentDirectory(), properties); //Exports to location of the Examples binary
+ }
+}
\ No newline at end of file
diff --git a/ISOv4Plugin.sln b/ISOv4Plugin.sln
index a62c40b..5b18ea9 100644
--- a/ISOv4Plugin.sln
+++ b/ISOv4Plugin.sln
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ISOv4Plugin", "ISOv4Plugin\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "TestUtilities\TestUtilities.csproj", "{98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{22ECC922-F80E-4142-9835-455B02A70B63}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
{98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98DBD0C7-5677-4B64-8DDA-BDA1E3B3DFCB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {22ECC922-F80E-4142-9835-455B02A70B63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {22ECC922-F80E-4142-9835-455B02A70B63}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {22ECC922-F80E-4142-9835-455B02A70B63}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {22ECC922-F80E-4142-9835-455B02A70B63}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ISOv4Plugin/Mappers/PrescriptionMapper.cs b/ISOv4Plugin/Mappers/PrescriptionMapper.cs
index f39502b..d972e47 100644
--- a/ISOv4Plugin/Mappers/PrescriptionMapper.cs
+++ b/ISOv4Plugin/Mappers/PrescriptionMapper.cs
@@ -285,7 +285,7 @@ private ISOTreatmentZone ExportTreatmentZonesForType2(ISOTask task, RasterGridPr
outOfFieldTreatmentZone.ProcessDataVariables.Add(oofPDV);
}
- NumericRepresentation defaultRepresentation = productLookup?.LossOfGpsRate.Representation; //We can reuse the loss of gps representation here if it exists
+ NumericRepresentation defaultRepresentation = productLookup?.LossOfGpsRate?.Representation; //We can reuse the loss of gps representation here if it exists
if (defaultRepresentation == null)
{
//Determine the representation based on the unit of the product to be applied