示例#1
0
        public async Task Request_SingleTAGFile_NoSmooth()
        {
            AddGridRouting();

            var tagFiles  = new[] { Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"), };
            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var request   = new TINSurfaceRequest();
            var result    = await request.ExecuteAsync(new TINSurfaceRequestArgument { ProjectID = siteModel.ID, Filters = new FilterSet(new CombinedFilter()), Tolerance = 0 });

            result.Should().NotBeNull();
            result.data.Should().NotBeNull();

            var model = new TRex.Designs.TTM.TrimbleTINModel();

            model.Read(new BinaryReader(new MemoryStream(result.data)));

            model.Vertices.Count.Should().Be(2449);
            model.Triangles.Count.Should().Be(4400);
        }
示例#2
0
        public void Test_TAGFile_DropSiteModel_WithMixedRepresentation()
        {
            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            // Build the model, assess the contents, then drop the model and verify the contents are the same when
            // re-read from the persistence layer
            var siteModel  = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _, false, false);
            var siteModel2 = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _, false, true);

            CompareSiteModels(siteModel, siteModel2, 12, 16525, 3054);

            siteModel  = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _, true, false);
            siteModel2 = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _, true, true);

            CompareSiteModels(siteModel, siteModel2, 12, 16525, 3054);
        }
示例#3
0
        public async Task FilterToFilter_TwoFilters()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var tagFiles  = Directory.GetDirectories(@"C:\Temp\Tonsasenfiles").Where(x => x.Contains("2005")).SelectMany(Directory.GetFiles).Take(500).ToArray();
            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);

            var request  = new SimpleVolumesRequest_ApplicationService();
            var response = await request.ExecuteAsync(SimpleDefaultRequestArg(siteModel.ID));

            _log.LogInformation($"Volume result = Cut:{response.Cut} CutArea:{response.CutArea} Fill:{response.Fill} FillArea:{response.FillArea}, TotalArea:{response.TotalCoverageArea}");

            //Volume result = Cut:574.1289522460937 CutArea:10256.378800000002 Fill:1017.6427069946285 FillArea:12345.848800000002, TotalArea:35238.348000000005



            CheckDefaultFilterToFilterSingleTAGFileResponse(response);
        }
示例#4
0
        public async Task ClusterCompute_DefaultFilterToFilter_Execute_SingleTAGFile()
        {
            AddClusterComputeGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);

            var request  = new ProgressiveVolumesRequest_ClusterCompute();
            var response = await request.ExecuteAsync(DefaultRequestArgFromModel(siteModel, VolumeComputationType.Between2Filters));

            response.Should().NotBeNull();

            CheckDefaultFilterToFilterSingleTAGFileResponse(response);

            response.Volumes.Length.Should().Be(10);
        }
示例#5
0
        public async Task FailWithNoDefinedBaseOrTopSurfaceDesign(VolumeComputationType volumeType)
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);

            var request  = new ProgressiveVolumesRequest_ApplicationService();
            var response = await request.ExecuteAsync(DefaultRequestArgFromModel(siteModel, volumeType));

            response.Should().NotBeNull();

            response.Volumes.Should().BeNull();
            response.ResultStatus.Should().NotBe(RequestErrorStatus.OK);
        }
示例#6
0
        public async Task Test_TileRenderRequest_SingleTAGFileSiteModel_FileExtents_WithColourPalette(DisplayMode displayMode)
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);

            var palette = PVMPaletteFactory.GetPalette(siteModel, displayMode, siteModel.SiteModelExtent);

            var request  = new TileRenderRequest();
            var response = await request.ExecuteAsync(SimpleTileRequestArgument(siteModel, displayMode, palette));

            CheckSimpleRenderTileResponse(response);

            //File.WriteAllBytes($@"c:\temp\TRexTileRender-Unit-Test-{displayMode}.bmp", ((TileRenderResponse) response).TileBitmapData);
        }
示例#7
0
        public async Task CalculateFromTAGFileDerivedModel_NoPoints()
        {
            var tagFiles  = Directory.GetFiles(Path.Combine("TestData", "TAGFiles", "ElevationMappingMode-KettlewellDrive"), "*.tag").ToArray();
            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out var processedTasks);

            // Ask for a point that does not exist in the model the response should be a row with null values (???)
            var executor = new ComputeStationOffsetReportExecutor_ClusterCompute
                               (new StationOffsetReportRequestArgument_ClusterCompute
            {
                ProjectID       = siteModel.ID,
                Filters         = new FilterSet(new CombinedFilter()),
                Points          = new List <StationOffsetPoint>(),
                ReportElevation = true
            });

            var result = await executor.ExecuteAsync();

            result.ResultStatus.Should().Be(RequestErrorStatus.OK);
            result.ReturnCode.Should().Be(ReportReturnCode.NoData);
            result.StationOffsetRows.Count.Should().Be(0);
        }
示例#8
0
        public async Task Test_PatchRequest_ExecuteAndConvert_SingleTAGFileSiteModel()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var request   = new PatchRequest();
            var result    = await request.ExecuteAndConvertToResult(SimplePatchRequestArgument(siteModel.ID));

            result.Should().NotBeNull();
            result.Patch.Should().NotBeNull();
            result.Patch.Length.Should().Be(12);
            Math.Round(result.Patch[0].SubGridOriginX, 4).Should().Be(537667.84);
            Math.Round(result.Patch[0].SubGridOriginY, 4).Should().Be(5427390.08);
            Math.Round(result.Patch[0].ElevationOrigin, 4).Should().Be(41.397);
            result.Patch[0].TimeOrigin.Should().Be(1361929472);

            result.Patch[0].Data[13, 26].ElevationOffset.Should().Be(uint.MaxValue);
            result.Patch[0].Data[13, 26].TimeOffset.Should().Be(uint.MaxValue);
            result.Patch[0].Data[13, 27].ElevationOffset.Should().Be(59);
            result.Patch[0].Data[13, 27].TimeOffset.Should().Be(48000000);
            result.Patch[0].Data[13, 28].ElevationOffset.Should().Be(63);
            result.Patch[0].Data[13, 28].TimeOffset.Should().Be(50000000);

            Math.Round(result.Patch[1].SubGridOriginX, 4).Should().Be(537667.84);
            Math.Round(result.Patch[1].SubGridOriginY, 4).Should().Be(5427400.96);
            Math.Round(result.Patch[1].ElevationOrigin, 4).Should().Be(41.451);
            result.Patch[1].TimeOrigin.Should().Be(4237436768);

            Math.Round(result.Patch[2].SubGridOriginX, 4).Should().Be(537667.84);
            Math.Round(result.Patch[2].SubGridOriginY, 4).Should().Be(5427411.84);
            Math.Round(result.Patch[2].ElevationOrigin, 4).Should().Be(41.505);
            result.Patch[2].TimeOrigin.Should().Be(7369472);
        }
示例#9
0
        public void Notify_TAGFileDerivedChangeMap_DirectNotify()
        {
            // Build a site model from a TAG file and verify there is a change map written to the queue that matches the existence map
            // for the newly created model
            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var notifier  = new SiteModelChangeMapDeltaNotifier();

            // The notifier uses the non-transacted storage proxy:
            var proxy = DIContext.Obtain <Func <IStorageProxyCache <ISiteModelChangeBufferQueueKey, ISiteModelChangeBufferQueueItem> > >()();

            proxy.Should().NotBeNull();
            proxy.Clear();

            var insertUtc = DateTime.UtcNow;

            // Ask the notifier to notify a new item
            notifier.Notify(siteModel.ID, insertUtc, siteModel.ExistenceMap, SiteModelChangeMapOrigin.Ingest, SiteModelChangeMapOperation.AddSpatialChanges);

            // Check the new item was placed into the cache
            var cachedItem = proxy.Get(new SiteModelChangeBufferQueueKey(siteModel.ID, insertUtc));

            cachedItem.Should().NotBeNull();
            cachedItem.ProjectUID.Should().Be(siteModel.ID);
            cachedItem.Operation.Should().Be(SiteModelChangeMapOperation.AddSpatialChanges);
            cachedItem.Origin.Should().Be(SiteModelChangeMapOrigin.Ingest);

            var readMap = new SubGridTreeSubGridExistenceBitMask();

            readMap.FromBytes(cachedItem.Content);

            readMap.CountBits().Should().Be(12);
            readMap.CountBits().Should().Be(siteModel.ExistenceMap.CountBits());
            readMap.ScanAllSetBitsAsSubGridAddresses(x => siteModel.ExistenceMap[x.X >> SubGridTreeConsts.SubGridIndexBitsPerLevel, x.Y >> SubGridTreeConsts.SubGridIndexBitsPerLevel].Should().BeTrue());
        }
示例#10
0
        public async Task Test_SimpleVolumesRequest_ApplicationService_FilterToFilterWithIntermediary_Execute_SingleTAGFile()
        {
            void CheckVolumesResponse(SimpleVolumesResponse response)
            {
                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);
            }

            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);

            var request = new SimpleVolumesRequest_ApplicationService();

            var(startUtc, endUtc) = siteModel.GetDateRange();
            var response = await request.ExecuteAsync(RequestArgForSimpleRequestsWithIntermediaryFilter(siteModel, startUtc, endUtc));

            CheckVolumesResponse(response);
        }
示例#11
0
        public async Task Test_TileRenderRequest_TAGFile_And_SurveyedSurface_ElevationOnly()
        {
            // Render a surveyed surface across a processed TAG file extent
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();
            AddDesignProfilerGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var extents   = siteModel.SiteModelExtent;

            extents.Expand(5, 5);

            var(startDate, _) = siteModel.GetDateRange();

            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSurveyedSurfaceEncompassingExtent(ref siteModel,
                                                                                                    extents, startDate, new[] { extents.MinZ - 1.0, extents.MinZ - 1.0, extents.MaxZ + 1.0, extents.MaxZ + 1.0 });
            var palette = PVMPaletteFactory.GetPalette(siteModel, DisplayMode.Height, siteModel.SiteModelExtent);

            var request = new TileRenderRequest();
            var arg     = SimpleTileRequestArgument(siteModel, DisplayMode.Height, palette);

            extents.Expand(1, 1);
            arg.Extents = extents;

            var response = await request.ExecuteAsync(arg);

            const string FILE_NAME = "SimpleSurveyedSurfaceWithTAGFile.bmp";
            var          path      = Path.Combine("TestData", "RenderedTiles", "SurveyedSurface", FILE_NAME);

            var saveFileName = ""; //@$"c:\temp\{FILE_NAME}";

            CheckSimpleRenderTileResponse(response, DisplayMode.Height, saveFileName, path);
        }
示例#12
0
        public async Task Test_DetailedTemperatureStatistics_SiteModelWithSingleTAGFile_FullExtents
            (ushort minTarget, ushort maxTarget, double percentBelow, double percentWithin, double percentAbove)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var operation = new TemperatureStatisticsOperation();

            var arg = SimpleTemperatureStatisticsArgument(siteModel, minTarget, maxTarget);

            arg.TemperatureDetailValues = new[] { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500 };
            var temperatureDetailResult = await operation.ExecuteAsync(arg);

            temperatureDetailResult.Should().NotBeNull();

            // Checks counts and percentages
            long[] expectedCounts    = { 0, 0, 231, 10, 7, 0, 8, 105, 275, 957, 1461, 0, 0, 0, 0 };
            long   expectedCountsSum = 0;

            for (int i = 0; i < expectedCounts.Length; i++)
            {
                expectedCountsSum += (i + 1) * expectedCounts[i];
            }

            // Is sum of counts the same?
            long TemperatureDetailResultSum = 0;

            for (int i = 0; i < temperatureDetailResult.Counts.Length; i++)
            {
                TemperatureDetailResultSum += (i + 1) * temperatureDetailResult.Counts[i];
            }

            TemperatureDetailResultSum.Should().Be(expectedCountsSum);

            // Are all counts the same and do percentages match?

            long totalCount = temperatureDetailResult.Counts.Sum();

            for (int i = 0; i < expectedCounts.Length; i++)
            {
                expectedCounts[i].Should().Be(temperatureDetailResult.Counts[i]);
                temperatureDetailResult.Percents[i].Should().BeApproximately(100.0 * expectedCounts[i] / (1.0 * totalCount), 0.001);
            }

            // Check summary related fields are zero
            temperatureDetailResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            temperatureDetailResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoProblems);
            temperatureDetailResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            temperatureDetailResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            temperatureDetailResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            temperatureDetailResult.TotalAreaCoveredSqMeters.Should().BeApproximately(3054 * SubGridTreeConsts.DefaultCellSize * SubGridTreeConsts.DefaultCellSize, 0.000001);
            temperatureDetailResult.MinimumTemperature.Should().Be(MACHINE_TARGET_MIN);
            temperatureDetailResult.MaximumTemperature.Should().Be(MACHINE_TARGET_MAX);
            temperatureDetailResult.IsTargetTemperatureConstant.Should().BeTrue();
        }
示例#13
0
        public async void ExecuteAsync_SingleTAGFile(bool treatMachineAsJohnDoe)
        {
            var testGuid = Guid.NewGuid();

            var mutableIgniteMock = IgniteMock.Mutable;

            AddApplicationGridRouting();

            // Construct a site model from a single TAG file
            var tagFiles  = new[] { Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag") };
            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _, true, false, treatMachineAsJohnDoe);

            // Push the tag file into the S3 bucket

            var uidForArchiveRepresentation = treatMachineAsJohnDoe ? Guid.Empty : siteModel.Machines[0].ID;

            var s3Proxy = DIContext.Obtain <Func <TransferProxyType, IS3FileTransfer> >()(TransferProxyType.TAGFiles);

            s3Proxy.WriteFile(tagFiles[0], $"{siteModel.ID}/{uidForArchiveRepresentation}/{Path.GetFileName(tagFiles[0])}");

            var rebuilder = CreateBuilder(siteModel.ID, false, TransferProxyType.TAGFiles);

            // Add the rebuilder to the manager in a 'hands-off' mode to allow notification routing to it.
            var manager = DIContext.Obtain <ISiteModelRebuilderManager>();

            manager.AddRebuilder(rebuilder).Should().BeTrue();

            // Start the rebuild executing
            var rebuilderTask = rebuilder.ExecuteAsync();

            // Wait until the rebuilder is in the monitoring state and then inject the contents of the tag file buffer queue cache into the handler
            while (rebuilder.Metadata.Phase != RebuildSiteModelPhase.Monitoring)
            {
                await Task.Delay(1000);
            }

            var mockQueueCacheDictionary = mutableIgniteMock.MockedCacheDictionaries[TRexCaches.TAGFileBufferQueueCacheName()] as Dictionary <ITAGFileBufferQueueKey, TAGFileBufferQueueItem>;

            var handler = new TAGFileBufferQueueItemHandler();

            handler.Should().NotBeNull();

            // Inject the keys for the handler to use to extract the TAG file content to be processed.
            mockQueueCacheDictionary.ForEach(kv => handler.Add(kv.Key));

            // Now wait for the rebuilder task to complete
            var result = await rebuilderTask;

            result.Should().NotBeNull();
            result.DeletionResult.Should().Be(DeleteSiteModelResult.OK);
            result.RebuildResult.Should().Be(RebuildSiteModelResult.OK);

            result.NumberOfTAGFileKeyCollections.Should().Be(1);
            result.NumberOfTAGFilesProcessed.Should().Be(1);
            result.NumberOfTAGFilesFromS3.Should().Be(1);

            result.LastProcessedTagFile.Should().Be(Path.GetFileName(tagFiles[0]));

            // Get the site model again and validate that there is still a single machine with the expected John Doe status
            siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(siteModel.ID);
            siteModel.Machines.Count.Should().Be(1);
            siteModel.Machines[0].IsJohnDoeMachine.Should().Be(treatMachineAsJohnDoe);

            // Belt and braces - clean the mocked TAG file buffer queue
            mockQueueCacheDictionary.Clear();
        }
示例#14
0
        public async Task FilterToFilter_TwoFilters_WithIntermediary_SingleCellFromDataWithTwoPasses()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            const double CENTERX = 534043.612;
            const double CENTERY = 6746939.126;
            const double DELTA   = 0.2d;

            var tagFiles  = Directory.GetDirectories(@"C:\Temp\Tonsasenfiles").Where(x => x.Contains("2005")).SelectMany(Directory.GetFiles).Take(500).ToArray();
            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);

            var request = new SimpleVolumesRequest_ApplicationService();

            var arg = new SimpleVolumesRequestArgument
            {
                ProjectID  = siteModel.ID,
                VolumeType = VolumeComputationType.Between2Filters,
                BaseFilter = new CombinedFilter
                {
                    AttributeFilter =
                    {
                        ReturnEarliestFilteredCellPass = false,
                        HasTimeFilter = true,
                        StartTime     = Consts.MIN_DATETIME_AS_UTC,
                        EndTime       = DateTime.SpecifyKind(new DateTime(2020, 5, 3, 0, 0, 0), DateTimeKind.Utc)
                    },
                    SpatialFilter =
                    {
                        CoordsAreGrid = true,
                        IsSpatial     = true,
                        Fence         = new TRex.Geometry.Fence(CENTERX - DELTA, CENTERY - DELTA, CENTERX + DELTA, CENTERY + DELTA)
                    }
                },
                TopFilter = new CombinedFilter
                {
                    AttributeFilter =
                    {
                        ReturnEarliestFilteredCellPass = false,
                        HasTimeFilter = true,
                        StartTime     = DateTime.SpecifyKind(new DateTime(2020, 5, 3,  0,  0,  0), DateTimeKind.Utc),
                        EndTime       = DateTime.SpecifyKind(new DateTime(2020, 5, 9, 23, 59, 59), DateTimeKind.Utc)
                    },
                    SpatialFilter =
                    {
                        CoordsAreGrid = true,
                        IsSpatial     = true,
                        Fence         = new TRex.Geometry.Fence(CENTERX - DELTA, CENTERY - DELTA, CENTERX + DELTA, CENTERY + DELTA)
                    }
                },
                BaseDesign    = new DesignOffset(),
                TopDesign     = new DesignOffset(),
                CutTolerance  = 0.001,
                FillTolerance = 0.001,
            };

            var response = await request.ExecuteAsync(arg);

            _log.LogInformation($"Volume result = Cut:{response.Cut} CutArea:{response.CutArea} Fill:{response.Fill} FillArea:{response.FillArea}, TotalArea:{response.TotalCoverageArea}");

            // Volume result = Cut:574.2604204345703 CutArea: 10261.9276 Fill: 1016.5434415893552 FillArea: 12337.410000000002, TotalArea: 35233.3772

            //CheckDefaultFilterToFilterSingleTAGFileResponse(response);
        }
示例#15
0
        public async Task Test_DetailedPassCountStatistics_WithPassCountRangeFilter
            (ushort minTarget, ushort maxTarget, double percentBelow, double percentWithin, double percentAbove, double totalArea)
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var tagFiles = new[]
            {
                Path.Combine(TestHelper.CommonTestDataPath, "TestTAGFile.tag"),
            };

            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var operation = new PassCountStatisticsOperation();

            var arg = SimplePassCountStatisticsArgument(siteModel, minTarget, maxTarget);

            arg.Filters = new FilterSet(new CombinedFilter(new CellPassAttributeFilter {
                PassCountRangeMin = 2, PassCountRangeMax = 3, HasPassCountRangeFilter = true
            }, new CellSpatialFilter()));
            arg.PassCountDetailValues = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
            var passCountDetailResult = await operation.ExecuteAsync(arg);

            passCountDetailResult.Should().NotBeNull();

            // Checks counts and percentages
            long[] expectedCounts    = { 0, 442, 1764, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            long   expectedCountsSum = 0;

            for (int i = 0; i < expectedCounts.Length; i++)
            {
                expectedCountsSum += (i + 1) * expectedCounts[i];
            }

            // Is sum of counts the same?
            long passCountDetailResultSum = 0;

            for (int i = 0; i < passCountDetailResult.Counts.Length; i++)
            {
                passCountDetailResultSum += (i + 1) * passCountDetailResult.Counts[i];
            }

            passCountDetailResultSum.Should().Be(expectedCountsSum);

            // Are all counts the same and do percentages match?

            long totalCount = passCountDetailResult.Counts.Sum();

            for (int i = 0; i < expectedCounts.Length; i++)
            {
                expectedCounts[i].Should().Be(passCountDetailResult.Counts[i]);
                passCountDetailResult.Percents[i].Should().BeApproximately(100.0 * expectedCounts[i] / (1.0 * totalCount), 0.001);
            }

            // Check summary related fields are zero
            passCountDetailResult.ResultStatus.Should().Be(RequestErrorStatus.OK);
            passCountDetailResult.ReturnCode.Should().Be(MissingTargetDataResultType.NoResult);
            passCountDetailResult.BelowTargetPercent.Should().BeApproximately(percentBelow, 0.001);
            passCountDetailResult.AboveTargetPercent.Should().BeApproximately(percentAbove, 0.001);
            passCountDetailResult.WithinTargetPercent.Should().BeApproximately(percentWithin, 0.001);
            passCountDetailResult.TotalAreaCoveredSqMeters.Should().BeApproximately(totalArea, 0.000001);
            passCountDetailResult.IsTargetPassCountConstant.Should().BeTrue();
        }
示例#16
0
        public async Task CalculateFromTAGFileDerivedModel()
        {
            var tagFiles  = Directory.GetFiles(Path.Combine("TestData", "TAGFiles", "ElevationMappingMode-KettlewellDrive"), "*.tag").ToArray();
            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out var _);

            // For test purposes, create an imaginary 'road' that passes through at least 100 of the
            //  on-null cells in the site model, which also have passCount data
            var    points  = new List <StationOffsetPoint>();
            double station = 0;

            siteModel.ExistenceMap.ScanAllSetBitsAsSubGridAddresses(addr =>
            {
                if (points.Count > 100)
                {
                    return;
                }

                var subGrid = TRex.SubGridTrees.Server.Utilities.SubGridUtilities.LocateSubGridContaining(
                    siteModel.PrimaryStorageProxy, siteModel.Grid,
                    addr.X, addr.Y, siteModel.Grid.NumLevels, false, false);

                subGrid.CalculateWorldOrigin(out var originX, out var originY);

                ((IServerLeafSubGrid)subGrid).Directory.GlobalLatestCells.PassDataExistenceMap.ForEachSetBit(
                    (x, y) =>
                {
                    points.Add(new StationOffsetPoint(station += 1, 0,
                                                      originY + y * siteModel.CellSize + siteModel.CellSize / 2,
                                                      originX + x * siteModel.CellSize + siteModel.CellSize / 2));
                });
            });

            var executor = new ComputeStationOffsetReportExecutor_ClusterCompute
                               (new StationOffsetReportRequestArgument_ClusterCompute
            {
                ProjectID         = siteModel.ID,
                Filters           = new FilterSet(new CombinedFilter()),
                Points            = points,
                ReportElevation   = true,
                ReportCmv         = true,
                ReportMdp         = true,
                ReportPassCount   = true,
                ReportTemperature = true
            });

            var result = await executor.ExecuteAsync();

            result.ResultStatus.Should().Be(RequestErrorStatus.OK);
            result.ReturnCode.Should().Be(ReportReturnCode.NoError);
            result.StationOffsetRows.Count.Should().Be(points.Count);
            result.StationOffsetRows[0].Northing.Should().Be(808525.44000000006);
            result.StationOffsetRows[0].Easting.Should().Be(376730.88);
            result.StationOffsetRows[0].Elevation.Should().Be(68.630996704101562);// Mutable representation result ==> (68.6305160522461);
            result.StationOffsetRows[0].CutFill.Should().Be(Consts.NullHeight);
            result.StationOffsetRows[0].Cmv.Should().Be(CellPassConsts.NullCCV);
            result.StationOffsetRows[0].Mdp.Should().Be(CellPassConsts.NullMDP);
            result.StationOffsetRows[0].PassCount.Should().Be(1);
            result.StationOffsetRows[0].Temperature.Should().Be((short)CellPassConsts.NullMaterialTemperatureValue);

            result.StationOffsetRows.FirstOrDefault(x => x.CutFill != Consts.NullHeight).Should().Be(null);
            result.StationOffsetRows.FirstOrDefault(x => x.Cmv != CellPassConsts.NullCCV).Should().Be(null);
            result.StationOffsetRows.FirstOrDefault(x => x.Mdp != CellPassConsts.NullMDP).Should().Be(null);
            result.StationOffsetRows.FirstOrDefault(x => x.Temperature != (short)CellPassConsts.NullMaterialTemperatureValue).Should().Be(null);
        }