/// <summary> /// Converts SimpleVolumesResponse data into SummaryVolumesResult data. /// </summary> private SummaryVolumesResult ConvertResult(SimpleVolumesResponse result) { return(SummaryVolumesResult.Create( BoundingBox3DGridHelper.ConvertExtents(result.BoundingExtentGrid), result.Cut ?? 0.0, result.Fill ?? 0.0, result.TotalCoverageArea ?? 0.0, result.CutArea ?? 0.0, result.FillArea ?? 0.0)); }
private void CheckResponseContainsNullValues(SimpleVolumesResponse response) { response.Should().NotBeNull(); response.Cut.Should().BeNull(); response.Fill.Should().BeNull(); response.CutArea.Should().BeNull(); response.FillArea.Should().BeNull(); response.TotalCoverageArea.Should().BeNull(); response.BoundingExtentGrid.Should().BeEquivalentTo(BoundingWorldExtent3D.Null()); }
private void CheckDefaultFilterToFilterSingleTAGFileResponse(SimpleVolumesResponse response) { //Was, response = {Cut:1.00113831634521, Fill:2.48526947021484, Cut Area:117.5652, FillArea: 202.9936, Total Area:353.0424, BoundingGrid:MinX: 537669.2, MaxX:537676.34, MinY:5427391.44, MaxY:5427514.52, MinZ: 1E+308, MaxZ:1E+308, BoundingLLH:MinX: 1E+308, MaxX:1E+308, MinY:1... const double EPSILON = 0.000001; response.Should().NotBeNull(); response.Cut.Should().BeApproximately(574.1289522460937, EPSILON); response.Fill.Should().BeApproximately(1017.6427069946285, EPSILON); response.CutArea.Should().BeApproximately(10256.378800000002, EPSILON); response.FillArea.Should().BeApproximately(12345.848800000002, EPSILON); response.TotalCoverageArea.Should().BeApproximately(35238.348000000005, EPSILON); }
private void CheckDefaultFilterToFilterSingleCutCellAtOriginResponse(SimpleVolumesResponse response) { const double EPSILON = 0.000001; response.Should().NotBeNull(); response.Cut.Should().BeApproximately(4.50 * SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, EPSILON); response.Fill.Should().BeApproximately(0, EPSILON); response.CutArea.Should().BeApproximately(SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, EPSILON); response.FillArea.Should().BeApproximately(0, EPSILON); response.TotalCoverageArea.Should().BeApproximately(SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, EPSILON); response.BoundingExtentGrid.MinX.Should().BeApproximately(0, EPSILON); response.BoundingExtentGrid.MinY.Should().BeApproximately(0, EPSILON); response.BoundingExtentGrid.MaxX.Should().BeApproximately(SubGridTreeConsts.DefaultCellSize, EPSILON); response.BoundingExtentGrid.MaxY.Should().BeApproximately(SubGridTreeConsts.DefaultCellSize, EPSILON); response.BoundingExtentGrid.MinZ.Should().Be(Consts.NullDouble); response.BoundingExtentGrid.MaxZ.Should().Be(Consts.NullDouble); }
private void CheckDefaultFilterToFilterSingleTAGFileResponse(SimpleVolumesResponse response) { //Was, response = {Cut:1.00113831634521, Fill:2.48526947021484, Cut Area:117.5652, FillArea: 202.9936, Total Area:353.0424, BoundingGrid:MinX: 537669.2, MaxX:537676.34, MinY:5427391.44, MaxY:5427514.52, MinZ: 1E+308, MaxZ:1E+308, BoundingLLH:MinX: 1E+308, MaxX:1E+308, MinY:1... const double EPSILON = 0.000001; response.Should().NotBeNull(); response.Cut.Should().BeApproximately(0.99982155303955178, EPSILON); response.Fill.Should().BeApproximately(2.4776475891113323, EPSILON); response.CutArea.Should().BeApproximately(113.86600000000001, EPSILON); response.FillArea.Should().BeApproximately(200.56600000000006, EPSILON); response.TotalCoverageArea.Should().BeApproximately(353.0424, EPSILON); response.BoundingExtentGrid.MinX.Should().BeApproximately(537669.2, EPSILON); response.BoundingExtentGrid.MinY.Should().BeApproximately(5427391.44, EPSILON); response.BoundingExtentGrid.MaxX.Should().BeApproximately(537676.34, EPSILON); response.BoundingExtentGrid.MaxY.Should().BeApproximately(5427514.52, EPSILON); response.BoundingExtentGrid.MinZ.Should().Be(Consts.NullDouble); response.BoundingExtentGrid.MaxZ.Should().Be(Consts.NullDouble); }
public void Test_CMVStatisticsResponse() { var response = new SimpleVolumesResponse() { ResponseCode = SubGridRequestsResponseResult.OK, ClusterNode = CLUSTER_NODE, NumSubgridsProcessed = NUMBER_SUBGRIDS, NumSubgridsExamined = NUMBER_SUBGRIDS, NumProdDataSubGridsProcessed = NUMBER_PROD_DATA_SUBGRIDS, NumProdDataSubGridsExamined = NUMBER_PROD_DATA_SUBGRIDS, NumSurveyedSurfaceSubGridsProcessed = NUMBER_SS_SUBGRIDS, NumSurveyedSurfaceSubGridsExamined = NUMBER_SS_SUBGRIDS, Cut = 10.0, Fill = 20.0, BoundingExtentGrid = new BoundingWorldExtent3D(1.0, 2.0, 3.0, 4.0, 5.0, 6.0), CutArea = 30.0, FillArea = 40.0, TotalCoverageArea = 100.0 }; SimpleBinarizableInstanceTester.TestClass(response, "Custom SimpleVolumesResponse not same after round trip serialisation"); }
public void Test_SimpleVolumesResponseTests_AggregateWith() { // Allow this to be null, it will receive all the aggregations SimpleVolumesResponse response1 = new SimpleVolumesResponse(); SimpleVolumesResponse response2 = new SimpleVolumesResponse() { Cut = 10.0, Fill = 20.0, BoundingExtentGrid = new TRex.Geometry.BoundingWorldExtent3D(1.0, 2.0, 3.0, 4.0, 5.0, 6.0), CutArea = 30.0, FillArea = 40.0, TotalCoverageArea = 100.0 }; response1.AggregateWith(response2); Assert.Equal(10.0, response1.Cut); Assert.Equal(20.0, response1.Fill); Assert.True(response1.BoundingExtentGrid.Equals(response2.BoundingExtentGrid), "BoundingExtentGrid value incorrect after aggregatewith"); Assert.Equal(30.0, response1.CutArea); Assert.Equal(40.0, response1.FillArea); Assert.Equal(100.0, response1.TotalCoverageArea); }
public void Test_SimpleVolumesResponseTests_Creation() { SimpleVolumesResponse response = new SimpleVolumesResponse(); Assert.NotNull(response); }
public void Test_ToString() { var response = new SimpleVolumesResponse(); response.ToString().Should().Match("Cut:*, Fill*, Cut Area:*, FillArea:*, Total Area:*, BoundingGrid:*, BoundingLLH:*"); }
private static SimpleVolumesResponse ConvertBoundaryFromGridToWGS84(Guid projectUid, SimpleVolumesResponse response) { if (!response.BoundingExtentGrid.IsValidPlanExtent) { return(response); // No conversion possible } var neeCoords = new[] { // ReSharper disable once CompareOfFloatsByEqualityOperator new XYZ(response.BoundingExtentGrid.MinX, response.BoundingExtentGrid.MinY, response.BoundingExtentGrid.MinZ == Consts.NullDouble ? 0.0 : response.BoundingExtentGrid.MinZ), // ReSharper disable once CompareOfFloatsByEqualityOperator new XYZ(response.BoundingExtentGrid.MaxX, response.BoundingExtentGrid.MaxY, response.BoundingExtentGrid.MaxZ == Consts.NullDouble ? 0.0 : response.BoundingExtentGrid.MaxZ) }; var csib = DIContext.Obtain <ISiteModels>().GetSiteModel(projectUid).CSIB(); if (string.IsNullOrEmpty(csib)) { response.ResponseCode = SubGridRequestsResponseResult.Failure; } else { var llhCoords = DIContext .Obtain <ICoreXWrapper>() .NEEToLLH(csib, neeCoords.ToCoreX_XYZ()) .ToTRex_XYZ(); response.BoundingExtentLLH = new BoundingWorldExtent3D { MinX = MathUtilities.RadiansToDegrees(llhCoords[0].X), MinY = MathUtilities.RadiansToDegrees(llhCoords[0].Y), MaxX = MathUtilities.RadiansToDegrees(llhCoords[1].X), MaxY = MathUtilities.RadiansToDegrees(llhCoords[1].Y) }; } return(response); }
/// <summary> /// Executes the simple volumes computation returning a SimpleVolumesResponse with the results /// </summary> public SimpleVolumesResponse Execute() { var volumesResult = new SimpleVolumesResponse(); var resultBoundingExtents = BoundingWorldExtent3D.Null(); var requestDescriptor = Guid.NewGuid(); // TODO ASNodeImplInstance.NextDescriptor; Log.LogInformation($"#In# Performing {nameof(ComputeSimpleVolumes_Coordinator)}.Execute for DataModel:{SiteModelID}"); try { try { ApplicationServiceRequestStatistics.Instance.NumSimpleVolumeRequests.Increment(); // Prepare filters for use in the request var resultStatus = FilterUtilities.PrepareFiltersForUse(new[] { BaseFilter, TopFilter, AdditionalSpatialFilter }, SiteModelID); if (resultStatus != RequestErrorStatus.OK) { return(volumesResult); } // Obtain the site model context for the request siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(SiteModelID); if (siteModel == null) { return(volumesResult); } // Create and configure the aggregator that contains the business logic for the // underlying volume calculation Aggregator = new SimpleVolumesCalculationsAggregator { SiteModel = siteModel, LiftParams = LiftParams, CellSize = siteModel.CellSize, VolumeType = VolumeType, CutTolerance = CutTolerance, FillTolerance = FillTolerance }; // Create and configure the volumes calculation engine var computeVolumes = new VolumesCalculator { RequestDescriptor = requestDescriptor, SiteModel = siteModel, Aggregator = Aggregator, BaseFilter = BaseFilter, TopFilter = TopFilter, VolumeType = VolumeType, LiftParams = LiftParams }; InitialiseVolumesCalculator(computeVolumes); // Perform the volume computation if (computeVolumes.ComputeVolumeInformation()) { resultStatus = RequestErrorStatus.OK; } else if (computeVolumes.AbortedDueToTimeout) { resultStatus = RequestErrorStatus.AbortedDueToPipelineTimeout; } else { resultStatus = RequestErrorStatus.Unknown; } if (resultStatus != RequestErrorStatus.OK) { Log.LogInformation($"Summary volume result: Failure, error = {resultStatus}"); // Send the (empty) results back to the caller return(volumesResult); } // Instruct the Aggregator to perform any finalization logic before reading out the results Aggregator.Finalise(); Log.LogInformation($"#Result# Summary volume result: Cut={Aggregator.CutFillVolume.CutVolume:F3}, Fill={Aggregator.CutFillVolume.FillVolume:F3}, Area={Aggregator.CoverageArea:F3}"); if (!Aggregator.BoundingExtents.IsValidPlanExtent) { if (Aggregator.CoverageArea == 0 && Aggregator.CutFillVolume.CutVolume == 0 && Aggregator.CutFillVolume.FillVolume == 0) { resultStatus = RequestErrorStatus.NoProductionDataFound; } else { resultStatus = RequestErrorStatus.InvalidPlanExtents; } Log.LogInformation($"Summary volume invalid PlanExtents or no data found: {resultStatus}"); return(volumesResult); } // Fill in the result object to pass back to the caller volumesResult.Cut = Aggregator.CutFillVolume.CutVolume; volumesResult.Fill = Aggregator.CutFillVolume.FillVolume; volumesResult.TotalCoverageArea = Aggregator.CoverageArea; volumesResult.CutArea = Aggregator.CutArea; volumesResult.FillArea = Aggregator.FillArea; volumesResult.BoundingExtentGrid = Aggregator.BoundingExtents; volumesResult.BoundingExtentLLH = resultBoundingExtents; } finally { ApplicationServiceRequestStatistics.Instance.NumSimpleVolumeRequestsCompleted.Increment(); if (volumesResult.ResponseCode != SubGridRequestsResponseResult.OK) { ApplicationServiceRequestStatistics.Instance.NumSimpleVolumeRequestsFailed.Increment(); } } } catch (Exception e) { Log.LogError(e, $"Failed to compute the simple volumes. Site Model ID: {SiteModelID}"); } return(volumesResult); }