From 0d2983130f6837a49ce09941da7da31e59b7bd1f Mon Sep 17 00:00:00 2001 From: Kelly Nelson Date: Tue, 4 Aug 2026 16:10:26 -0500 Subject: [PATCH 1/3] Fixing 0 widths, bad product key and sparse columns --- StandardPlugin/Extensions.cs | 2 +- StandardPlugin/WorkRecordExporter.cs | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/StandardPlugin/Extensions.cs b/StandardPlugin/Extensions.cs index 3d96f1d..013aa6f 100644 --- a/StandardPlugin/Extensions.cs +++ b/StandardPlugin/Extensions.cs @@ -251,7 +251,7 @@ public static Polygon AsCoveragePolygon(this Point leadingPoint, double width, r { //We only consider distance when we don't have a prior point to map from double distance = 1; //1m as default without any other information (at start of data) - if (reportedDistance != null) + if (reportedDistance != null && reportedDistance.Value > 0) { distance = reportedDistance.Value; } diff --git a/StandardPlugin/WorkRecordExporter.cs b/StandardPlugin/WorkRecordExporter.cs index 121778a..39a8430 100644 --- a/StandardPlugin/WorkRecordExporter.cs +++ b/StandardPlugin/WorkRecordExporter.cs @@ -513,9 +513,9 @@ private void ExportOperationSpatialRecords(ADAPTParquetColumnData runningOutput, { if (dataColumn.ProductId != null && section.ProductIndexWorkingData != null) { - if (section.FactoredDefinitionsBySourceCodeByProduct.ContainsKey(dataColumn.ProductId)) + if (section.FactoredDefinitionsBySourceCodeByProduct.TryGetValue(dataColumn.ProductId, out var factoredDefinitionsForProduct) && + factoredDefinitionsForProduct.TryGetValue(dataColumn.SrcName, out var factoredDefinition)) { - var factoredDefinition = section.FactoredDefinitionsBySourceCodeByProduct[dataColumn.ProductId][dataColumn.SrcName]; NumericRepresentationValue value = record.GetMeterValue(factoredDefinition.WorkingData) as NumericRepresentationValue; var doubleVal = value.AsConvertedDouble(dataColumn.TargetUOMCode) * factoredDefinition.Factor; @@ -532,15 +532,22 @@ private void ExportOperationSpatialRecords(ADAPTParquetColumnData runningOutput, } else { - dataColumn.Values.Add(0d); //We've grouped operations together and this doesn't apply. + dataColumn.Values.Add(0d); //This section doesn't report this working data for this product (e.g. grouped operations, or not every section reports every column) } } else { - var factoredDefinition = section.FactoredDefinitionsBySourceCodeByProduct[string.Empty][dataColumn.SrcName]; - NumericRepresentationValue value = record.GetMeterValue(factoredDefinition.WorkingData) as NumericRepresentationValue; - var doubleVal = value.AsConvertedDouble(dataColumn.TargetUOMCode) * factoredDefinition.Factor; - dataColumn.Values.Add(doubleVal); + if (section.FactoredDefinitionsBySourceCodeByProduct.TryGetValue(string.Empty, out var factoredDefinitionsForSection) && + factoredDefinitionsForSection.TryGetValue(dataColumn.SrcName, out var factoredDefinition)) + { + NumericRepresentationValue value = record.GetMeterValue(factoredDefinition.WorkingData) as NumericRepresentationValue; + var doubleVal = value.AsConvertedDouble(dataColumn.TargetUOMCode) * factoredDefinition.Factor; + dataColumn.Values.Add(doubleVal); + } + else + { + dataColumn.Values.Add(0d); //This section doesn't report this working data + } } } } @@ -592,7 +599,7 @@ internal string Key() } internal string ProductKey() { - return string.Join(";", ProductIds.OrderBy(x => x).ToString()); + return string.Join(";", ProductIds.OrderBy(x => x)); } internal bool IsMatchingOperation(OperationDefinition other) From 968d12d673033e46b080bc3cc937ccfce5e5e5c0 Mon Sep 17 00:00:00 2001 From: Kelly Nelson Date: Tue, 11 Aug 2026 13:14:20 -0500 Subject: [PATCH 2/3] Cosmetic change on row group size; snapping to gdal default. --- StandardPlugin/ADAPTParquet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StandardPlugin/ADAPTParquet.cs b/StandardPlugin/ADAPTParquet.cs index 5571187..74d19f7 100644 --- a/StandardPlugin/ADAPTParquet.cs +++ b/StandardPlugin/ADAPTParquet.cs @@ -14,7 +14,7 @@ namespace AgGateway.ADAPT.StandardPlugin { internal class ADAPTParquetWriter { - const int RowGroupSize = 65535; + const int RowGroupSize = 65536; public ADAPTParquetWriter(ADAPTParquetColumnData columnData) { From dde2d804c6d1360043bc254f7c8cb8be731fa276 Mon Sep 17 00:00:00 2001 From: Kelly Nelson Date: Tue, 11 Aug 2026 13:58:10 -0500 Subject: [PATCH 3/3] Further cleanup of distance and sparse values. --- StandardPlugin/Extensions.cs | 9 +++++---- StandardPlugin/ImplementSection.cs | 16 +++++++++------- StandardPlugin/WorkRecordExporter.cs | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/StandardPlugin/Extensions.cs b/StandardPlugin/Extensions.cs index 013aa6f..b6adfcb 100644 --- a/StandardPlugin/Extensions.cs +++ b/StandardPlugin/Extensions.cs @@ -239,7 +239,7 @@ public static double HeadingRight(this double heading) public static Polygon AsCoveragePolygon(this Point leadingPoint, double width, ref LeadingEdge latestLeadingEdge, double heading, double? reportedDistance, double? calculatedDistance) { LeadingEdge priorLeadingEdge = latestLeadingEdge; - latestLeadingEdge = new LeadingEdge(leadingPoint, width, priorLeadingEdge, heading, reportedDistance); + latestLeadingEdge = new LeadingEdge(leadingPoint, width, priorLeadingEdge, heading); Point backRight; Point backLeft; if (priorLeadingEdge != null) @@ -251,15 +251,16 @@ public static Polygon AsCoveragePolygon(this Point leadingPoint, double width, r { //We only consider distance when we don't have a prior point to map from double distance = 1; //1m as default without any other information (at start of data) - if (reportedDistance != null && reportedDistance.Value > 0) + if (reportedDistance > 0d) { distance = reportedDistance.Value; } - else if (calculatedDistance != null) + else if (calculatedDistance > 0d) { distance = calculatedDistance.Value; } - distance = distance > 4 ? 4 : distance; //keep distances sane + //Clamp both ends: the floor keeps the back edge off the leading edge, which would make the polygon invalid + distance = Math.Clamp(distance, 0.1d, 4d); backRight = latestLeadingEdge.Right.Destination(distance, HeadingBack(heading)); backLeft = backRight.Destination(width, HeadingLeft(heading)); diff --git a/StandardPlugin/ImplementSection.cs b/StandardPlugin/ImplementSection.cs index a939446..08dbf3f 100644 --- a/StandardPlugin/ImplementSection.cs +++ b/StandardPlugin/ImplementSection.cs @@ -172,10 +172,12 @@ public bool TryGetCoveragePolygon(SpatialRecord record, SpatialRecord previousRe priorPoint = new Point(priorADAPTPoint.X, priorADAPTPoint.Y); } + var sectionDefinitions = FactoredDefinitionsBySourceCodeByProduct[string.Empty]; + double bearing = 0d; - if (FactoredDefinitionsBySourceCodeByProduct[string.Empty].ContainsKey("vrHeading")) + if (sectionDefinitions.TryGetValue("vrHeading", out var headingDefinition)) { - var headingValue = ((NumericRepresentationValue)record.GetMeterValue(FactoredDefinitionsBySourceCodeByProduct[string.Empty]["vrHeading"].WorkingData))?.Value?.Value; + var headingValue = ((NumericRepresentationValue)record.GetMeterValue(headingDefinition.WorkingData))?.Value?.Value; if (headingValue != null) { bearing = headingValue.Value; @@ -194,13 +196,13 @@ public bool TryGetCoveragePolygon(SpatialRecord record, SpatialRecord previousRe var xy = x.Destination(Offset.Y ?? 0d, bearing + 90d % 360d); double? reportedDistance = null; - if (FactoredDefinitionsBySourceCodeByProduct[string.Empty].ContainsKey("vrDistanceTraveled") && - record.GetMeterValue(FactoredDefinitionsBySourceCodeByProduct[string.Empty]["vrDistanceTraveled"].WorkingData) is NumericRepresentationValue distanceData) + if (sectionDefinitions.TryGetValue("vrDistanceTraveled", out var distanceDefinition) && + record.GetMeterValue(distanceDefinition.WorkingData) is NumericRepresentationValue distanceData) { reportedDistance = distanceData?.Value?.Value; } - double? calculatedDistance = null; - if (reportedDistance == null && priorPoint != null) + double? calculatedDistance = null; + if (!(reportedDistance > 0d) && priorPoint != null) { calculatedDistance = GeometryExporter.HaversineDistance(priorPoint, point); } @@ -220,7 +222,7 @@ public void ClearLeadingEdge() internal class LeadingEdge { - public LeadingEdge(Point leadingPoint, double width, LeadingEdge priorLeadingEdge, double heading, double? reportedDistance) + public LeadingEdge(Point leadingPoint, double width, LeadingEdge priorLeadingEdge, double heading) { Heading = heading; double wh = width / 2d; diff --git a/StandardPlugin/WorkRecordExporter.cs b/StandardPlugin/WorkRecordExporter.cs index 1431ca3..f2f846b 100644 --- a/StandardPlugin/WorkRecordExporter.cs +++ b/StandardPlugin/WorkRecordExporter.cs @@ -554,7 +554,7 @@ private void ExportOperationSpatialRecords(ADAPTParquetColumnData runningOutput, } else { - dataColumn.Values.Add(0d); //This section doesn't report this working data + dataColumn.Values.Add(null); //This section doesn't report this working data; missing is not zero } } }