Exemplo n.º 1
0
        protected ISiteModel BuildModelForSingleCellTileRender(float heightIncrement, int cellX = SubGridTreeConsts.DefaultIndexOriginOffset, int cellY = SubGridTreeConsts.DefaultIndexOriginOffset)
        {
            var baseTime   = DateTime.UtcNow;
            var baseHeight = 1.0f;

            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

            siteModel.MachinesTargetValues[bulldozerMachineIndex].TargetCCAStateEvents.PutValueAtDate(VSS.TRex.Common.Consts.MIN_DATETIME_AS_UTC, 5);

            var referenceDate      = DateTime.UtcNow;
            var startReportPeriod1 = referenceDate.AddMinutes(-60);
            var endReportPeriod1   = referenceDate.AddMinutes(-30);

            siteModel.MachinesTargetValues[bulldozerMachineIndex].StartEndRecordedDataEvents.PutValueAtDate(startReportPeriod1, ProductionEventType.StartEvent);
            siteModel.MachinesTargetValues[bulldozerMachineIndex].StartEndRecordedDataEvents.PutValueAtDate(endReportPeriod1, ProductionEventType.EndEvent);
            siteModel.MachinesTargetValues[bulldozerMachineIndex].LayerIDStateEvents.PutValueAtDate(endReportPeriod1, 1);

            var cellPasses = Enumerable.Range(0, 10).Select(x =>
                                                            new CellPass
            {
                InternalSiteModelMachineIndex = bulldozerMachineIndex,
                Time     = baseTime.AddMinutes(x),
                Height   = baseHeight + x * heightIncrement,
                PassType = PassType.Front
            }).ToArray();

            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses(siteModel, cellX, cellY, cellPasses, 1, cellPasses.Length);
            DITAGFileAndSubGridRequestsFixture.ConvertSiteModelToImmutable(siteModel);

            return(siteModel);
        }
Exemplo n.º 2
0
        private ISiteModel BuildModelForSingleCellCMV(short cmvIncrement, short targetCMV = CellPassConsts.NullCCV)
        {
            var   baseTime = DateTime.UtcNow;
            short baseCMV  = 10;

            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

            if (targetCMV != CellPassConsts.NullCCV)
            {
                siteModel.MachinesTargetValues[bulldozerMachineIndex].TargetCCVStateEvents.PutValueAtDate(TRex.Common.Consts.MIN_DATETIME_AS_UTC, targetCMV);
            }

            var cellPasses = Enumerable.Range(0, 10).Select(x =>
                                                            new CellPass
            {
                InternalSiteModelMachineIndex = bulldozerMachineIndex,
                Time     = baseTime.AddMinutes(x),
                CCV      = (short)(baseCMV + x * cmvIncrement),
                PassType = PassType.Front
            }).ToArray();

            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses, 1, cellPasses.Length);
            DITAGFileAndSubGridRequestsFixture.ConvertSiteModelToImmutable(siteModel);

            return(siteModel);
        }
Exemplo n.º 3
0
        private ISiteModel BuildModelForCellsElevation(float elevationIncrement)
        {
            var baseTime      = DateTime.UtcNow;
            var baseElevation = 1.0F;

            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

            CellPass[, ][] cellPasses = new CellPass[32, 32][];

            SubGridUtilities.SubGridDimensionalIterator((x, y) =>
            {
                cellPasses[x, y] = Enumerable.Range(0, 1).Select(p =>
                                                                 new CellPass
                {
                    InternalSiteModelMachineIndex = bulldozerMachineIndex,
                    Time     = baseTime.AddMinutes(p),
                    Height   = baseElevation + (x + y) * elevationIncrement, // incrementally increase height across the sub grid
                    PassType = PassType.Front
                }).ToArray();
            });

            DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);

            return(siteModel);
        }
Exemplo n.º 4
0
        public async Task SiteModelWithSingleSubGrid_FullExtents_WithSingleFlatTriangleDesignAboutOrigin()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();
            AddDesignProfilerGridRouting();

            var siteModel = BuildModelForSingleSubGridCutFill(0.1f);
            var designUid = DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleDesignAboutOrigin(ref siteModel, 2.0f);

            var operation = new CutFillStatisticsOperation();
            var argument  = SimpleCutFillStatisticsArgument(siteModel, designUid, 0);

            argument.Offsets = new[] { 1.0, 0.4, 0.2, 0.0, -0.2, -0.4, -1.0 };

            var result = await operation.ExecuteAsync(argument);

            result.Should().NotBeNull();
            result.ResultStatus.Should().Be(RequestErrorStatus.OK);

            result.Counts[0].Should().Be(693);
            result.Counts[1].Should().Be(105);
            result.Counts[2].Should().Be(27);
            result.Counts[3].Should().Be(33);
            result.Counts[4].Should().Be(24);
            result.Counts[5].Should().Be(20);
            result.Counts[6].Should().Be(1);

            long sum = result.Counts.Sum();

            for (int i = 0; i < result.Counts.Length; i++)
            {
                result.Percents[i].Should().Be((double)result.Counts[i] / sum * 100);
            }
        }
Exemplo n.º 5
0
        private ISiteModel BuildModelForSubGridRequest()
        {
            var baseTime = DateTime.UtcNow;

            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

            CellPass[, ][] cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][];

            SubGridUtilities.SubGridDimensionalIterator((x, y) =>
            {
                cellPasses[x, y] = Enumerable.Range(0, 1).Select(p =>
                                                                 new CellPass
                {
                    Height = 1 + x + y,
                    InternalSiteModelMachineIndex = bulldozerMachineIndex,
                    Time     = baseTime.AddMinutes(p),
                    PassType = PassType.Front
                }).ToArray();
            });

            DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);

            return(siteModel);
        }
Exemplo n.º 6
0
        private ISiteModel CreateSiteModelWithMachines()
        {
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();//creates machine "Bulldozer"

            siteModel.Machines.CreateNew("Excavator", "", MachineType.Excavator, DeviceTypeEnum.SNM940, false, Guid.NewGuid());
            return(siteModel);
        }
Exemplo n.º 7
0
        private ISiteModel BuildModelForCellsCMV(short cmvIncrement, short targetCMV = CellPassConsts.NullCCV)
        {
            var   baseTime = DateTime.UtcNow;
            short baseCMV  = 10;

            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

            if (targetCMV != CellPassConsts.NullCCV)
            {
                siteModel.MachinesTargetValues[bulldozerMachineIndex].TargetCCVStateEvents.PutValueAtDate(TRex.Common.Consts.MIN_DATETIME_AS_UTC, targetCMV);
            }

            CellPass[, ][] cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][];

            SubGridUtilities.SubGridDimensionalIterator((x, y) =>
            {
                cellPasses[x, y] = Enumerable.Range(0, 1).Select(p =>
                                                                 new CellPass
                {
                    InternalSiteModelMachineIndex = bulldozerMachineIndex,
                    Time     = baseTime.AddMinutes(p),
                    CCV      = (short)(baseCMV + x * cmvIncrement), // incrementally increase CCV across the sub grid
                    PassType = PassType.Front
                }).ToArray();
            });

            DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);

            return(siteModel);
        }
Exemplo n.º 8
0
        public void ProcessChangeMapUpdateItems_EmptyMap()
        {
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var changeMap = new SubGridTreeSubGridExistenceBitMask();

            TestSiteModelAndChangeMap_Ingest(siteModel, changeMap, 0);
        }
Exemplo n.º 9
0
        public async Task Test_TileRenderRequest_NoSubGridData_EmptyTile(DisplayMode displayMode)
        {
            // See BUG# 86870
            // Test setup: Setup some production data in different sub grids
            // Request a tile in a sub grid with no data
            // Tile should return quickly, with an empty tile (previously it would sit for 2 minutes to timeout, and return null).
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var  baseTime   = DateTime.UtcNow;
            var  baseHeight = 1.0f;
            byte baseCCA    = 1;
            byte baseCCV    = 0;

            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

            siteModel.MachinesTargetValues[bulldozerMachineIndex].TargetCCAStateEvents.PutValueAtDate(VSS.TRex.Common.Consts.MIN_DATETIME_AS_UTC, 5);

            var cellPasses = Enumerable.Range(0, 10).Select(x =>
                                                            new CellPass
            {
                InternalSiteModelMachineIndex = bulldozerMachineIndex,
                Time     = baseTime.AddMinutes(x),
                Height   = baseHeight + x * HEIGHT_INCREMENT_0_5,
                CCA      = (byte)(baseCCA + x),
                CCV      = (short)(baseCCV + x * CCV_INCREMENT),
                PassType = PassType.Front
            }).ToArray();

            // And offset to make sure we span multiple sub grids (if the tile request is in the same sub grid, even if empty, the bug was not applicable)
            const int offset = (2 * SubGridTreeConsts.CellsPerSubGrid) + 1;

            // Create some cell passes in 4 corners, but in separate sub grids
            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset + offset, SubGridTreeConsts.DefaultIndexOriginOffset + offset, cellPasses);
            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset + offset, SubGridTreeConsts.DefaultIndexOriginOffset - offset, cellPasses);
            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset - offset, SubGridTreeConsts.DefaultIndexOriginOffset - offset, cellPasses);
            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset - offset, SubGridTreeConsts.DefaultIndexOriginOffset + offset, cellPasses);
            DITAGFileAndSubGridRequestsFixture.ConvertSiteModelToImmutable(siteModel);

            // Now if we get a single cell pass in the center, which has no data we should get an empty tile (not a null tile)
            var tileExtents = siteModel.Grid.GetCellExtents(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset);

            var request = new TileRenderRequest();
            var arg     = new TileRenderRequestArgument(siteModel.ID, displayMode, null, tileExtents, true, 256, 256, new FilterSet(new CombinedFilter(), new CombinedFilter()), new DesignOffset(), VolumeComputationType.None);

            var startTime = DateTime.UtcNow;
            var response  = await request.ExecuteAsync(arg);

            var duration = (DateTime.UtcNow - startTime).TotalMilliseconds;

            // 30 seconds should be ample time, even on a slow computer - but well under the 2 minute timeout which is enforced by the pipeline processor.
            duration.Should().BeLessThan(30 * 1000, "Empty tile should return quickly - see BUG# 86870");

            // And the tile should NOT be null
            CheckSimpleRenderTileResponse(response, displayMode);

            //      File.WriteAllBytes($@"c:\temp\TRexTileRender-Unit-Test-{displayMode}.bmp", ((TileRenderResponse) response).TileBitmapData);
        }
Exemplo n.º 10
0
        public void Execute()
        {
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var projectGuid = siteModel.ID;
            var insertUtc   = DateTime.UtcNow;
            var changeMap   = new SubGridTreeSubGridExistenceBitMask
            {
Exemplo n.º 11
0
        public async Task Request_EmptyModel_ZeroTolerance()
        {
            AddGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            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().BeNull();
        }
Exemplo n.º 12
0
        public void Test_ProjectImmutableDataEventsTests_MergingOverrides(int startMins, int endMins)
        {
            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); //Mutable context
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;
            var events = siteModel.MachinesTargetValues[bulldozerMachineIndex];

            var layerIds        = new[] { (ushort)1, (ushort)2, (ushort)3 };
            var layerOverrideId = (ushort)4;

            var designIds        = new[] { 1, 2, 3 };
            var designOverrideId = 4;

            var referenceDate = DateTime.UtcNow;
            var dateTimes     = new[] { referenceDate.AddMinutes(-90), referenceDate.AddMinutes(-60), referenceDate.AddMinutes(-30) };

            for (var i = 0; i < 3; i++)
            {
                events.MachineDesignNameIDStateEvents.PutValueAtDate(dateTimes[i], designIds[i]);
                events.LayerIDStateEvents.PutValueAtDate(dateTimes[i], layerIds[i]);
            }

            var overrideStartDate = referenceDate.AddMinutes(startMins);
            var overrideEndDate   = referenceDate.AddMinutes(endMins);

            events.DesignOverrideEvents.PutValueAtDate(overrideStartDate, new OverrideEvent <int>(overrideEndDate, designOverrideId));
            events.LayerOverrideEvents.PutValueAtDate(overrideStartDate, new OverrideEvent <ushort>(overrideEndDate, layerOverrideId));
            //Now save added events
            events.SaveMachineEventsToPersistentStore(siteModel.PrimaryStorageProxy);
            var evt = new SiteModelAttributesChangedEvent
            {
                SiteModelID                 = siteModel.ID,
                AlignmentsModified          = false,
                CsibModified                = false,
                DesignsModified             = false,
                ExistenceMapModified        = false,
                MachineDesignsModified      = false,
                MachineTargetValuesModified = true,
                MachinesModified            = false,
                ProofingRunsModified        = false,
                SurveyedSurfacesModified    = false
            };
            var siteModels = DIContext.Obtain <ISiteModels>();

            siteModels.SiteModelAttributesHaveChanged(evt);
            //Re-get site model to get newly created one
            siteModel = siteModels.GetSiteModel(siteModel.ID, false);
            siteModel.SetStorageRepresentationToSupply(StorageMutability.Immutable);//so that merge will occur
            events = siteModel.MachinesTargetValues[bulldozerMachineIndex];

            CheckMergedList(startMins, endMins, events.MachineDesignNameIDStateEvents, designOverrideId, designIds, dateTimes, overrideStartDate, overrideEndDate);
            CheckMergedList(startMins, endMins, events.LayerIDStateEvents, layerOverrideId, layerIds, dateTimes, overrideStartDate, overrideEndDate);
        }
Exemplo n.º 13
0
        public async Task Test_SummarySpeedStatistics_EmptySiteModel_FullExtents_NoSpeedTargetOverride()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var operation = new SpeedStatisticsOperation();

            var mdpSummaryResult = await operation.ExecuteAsync(SimpleSpeedStatisticsArgument(siteModel, 0, 0));

            mdpSummaryResult.Should().NotBeNull();
            mdpSummaryResult.ResultStatus.Should().Be(RequestErrorStatus.FailedToRequestDatamodelStatistics);
        }
Exemplo n.º 14
0
        public async Task Test_CMVChangeStatisticsRequest_EmptySiteModel_FullExtents()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var operation = new CMVChangeStatisticsOperation();

            var cmvChangeStatisticsResult = await operation.ExecuteAsync(SimpleCMVChangeStatisticsArgument(siteModel, new [] { -50.0, -20.0, -10.0, 0.0, 10.0, 20.0, 50.0 }));

            cmvChangeStatisticsResult.Should().NotBeNull();
            cmvChangeStatisticsResult.ResultStatus.Should().Be(RequestErrorStatus.FailedToRequestDatamodelStatistics);
        }
Exemplo n.º 15
0
        public async Task EmptySiteModel_FullExtents_NoDesign()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var operation = new CutFillStatisticsOperation();

            var argument = SimpleCutFillStatisticsArgument(siteModel, Guid.NewGuid(), 1.5);
            var result   = await operation.ExecuteAsync(argument);

            result.Should().NotBeNull();
            result.ResultStatus.Should().Be(RequestErrorStatus.FailedToRequestDatamodelStatistics);
        }
Exemplo n.º 16
0
        public async Task DebugCutFillStatistics()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();
            AddDesignProfilerGridRouting();
            var tagFiles  = Directory.GetFiles(Path.Combine("TestData", "TAGFiles", "Dimensions-Machine 4250986182719752"), "*.tag").ToArray();
            var siteModel = DITAGFileAndSubGridRequestsFixture.BuildModel(tagFiles, out _);
            var designUid = DITAGFileAndSubGridRequestsWithIgniteFixture.AddDesignToSiteModel(ref siteModel, Path.Combine("TestData", "Common"), "Large Sites Road - Trimble Road.ttm", false);

            var operation = new CutFillStatisticsOperation();
            var argument  = SimpleCutFillStatisticsArgument(siteModel, designUid, 0);

            argument.Offsets = new[] { 0.5, 0.2, 0.1, 0.0, -0.1, -0.2, -0.5 };
            var result = await operation.ExecuteAsync(argument);
        }
Exemplo n.º 17
0
        public async Task Test_TileRenderRequest_EmptySiteModel_FullExtents(DisplayMode displayMode)
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var request   = new TileRenderRequest();

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

            response.Should().NotBeNull();
            response.ResultStatus.Should().Be(RequestErrorStatus.InvalidCoordinateRange);
            response.Should().BeOfType <TileRenderResponse>();
            ((TileRenderResponse)response).TileBitmapData.Should().NotBeNull();
        }
Exemplo n.º 18
0
        public async Task Test_CutFillTile_TAGFile_FlatDesign(ElevationSource elevationSource, bool useSmoothing, ConvolutionMaskSize maskSize, NullInfillMode nullInfillMode)
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();
            AddDesignProfilerGridRouting();

            _fixture.smoothingActive        = useSmoothing;
            _fixture.smootherMaskSize       = maskSize;
            _fixture.smootherNullInfillMode = nullInfillMode;

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

            // Add a flat design to the site model at the minimum elevation in the site model

            var elevation = elevationSource switch
            {
                ElevationSource.MinimumElevation => (float)siteModel.SiteModelExtent.MinZ,
                ElevationSource.MaximumElevation => (float)siteModel.SiteModelExtent.MaxZ,
                _ => (float)siteModel.SiteModelExtent.MinZ
            };

            var designUid       = DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructFlatTTMDesignEncompassingSiteModel(ref siteModel, elevation);
            var referenceDesign = new DesignOffset(designUid, 0.0);
            var palette         = PVMPaletteFactory.GetPalette(siteModel, DisplayMode.CutFill, siteModel.SiteModelExtent);
            var request         = new TileRenderRequest();
            var arg             = SimpleTileRequestArgument(siteModel, DisplayMode.CutFill, palette, volumeType: VolumeComputationType.BetweenFilterAndDesign);

            // Add the cut/fill design reference to the request, and set the rendering extents to the cell in question,
            // with an additional 1 meter border around the cell
            arg.ReferenceDesign = referenceDesign;
            arg.Extents         = siteModel.SiteModelExtent;
            arg.Extents.Expand(1.0, 1.0);

            var response = await request.ExecuteAsync(arg);

            var fileName = @$ "Flat-Elevation-{elevation}-Smoothing-{useSmoothing}-{maskSize}-{nullInfillMode}.bmp";
            var path     = Path.Combine("TestData", "RenderedTiles", "CutFillTile", fileName);

            var saveFileName = ""; // @$"C:\Temp\Flat-Elevation-{elevation}-Smoothing-{useSmoothing}-{maskSize}-{nullInfillMode}.bmp";

            CheckSimpleRenderTileResponse(response, DisplayMode.CutFill, saveFileName, path);
        }
Exemplo n.º 19
0
        public async Task SiteModelWithSingleCell_FullExtents_WithSingleFlatTriangleDesignAboutOrigin()
        {
            AddClusterComputeGridRouting();
            AddApplicationGridRouting();
            AddDesignProfilerGridRouting();

            var siteModel = BuildModelForSingleCellCutFill(HEIGHT_INCREMENT_0_5);
            var designUid = DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleDesignAboutOrigin(ref siteModel, 1.0f);

            var operation = new CutFillStatisticsOperation();
            var argument  = SimpleCutFillStatisticsArgument(siteModel, designUid, 0);

            argument.Offsets = new[] { 0.5, 0.2, 0.1, 0.0, -0.1, -0.2, -0.5 };

            var result = await operation.ExecuteAsync(argument);

            result.Should().NotBeNull();
            result.ResultStatus.Should().Be(RequestErrorStatus.OK);
            result.Counts[0].Should().Be(1);
            result.Percents[0].Should().Be(100);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        public async Task Test_TileRenderRequest_SiteModelWithSingleCell_FullExtents_CutFill(bool usePalette, double offset)
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();
            AddDesignProfilerGridRouting();

            // A location on the bug36372.ttm surface - X=247500.0, Y=193350.0
            const double TTMLocationX = 247500.0;
            const double TTMLocationY = 193350.0;

            // Find the location of the cell in the site model for that location
            SubGridTree.CalculateIndexOfCellContainingPosition
                (TTMLocationX, TTMLocationY, SubGridTreeConsts.DefaultCellSize, SubGridTreeConsts.DefaultIndexOriginOffset, out int cellX, out int cellY);

            // Create the site model containing a single cell and add the design to it for the cut/fill
            var siteModel = BuildModelForSingleCellTileRender(HEIGHT_INCREMENT_0_5, CCV_INCREMENT, cellX, cellY);

            var palette = usePalette ? PVMPaletteFactory.GetPalette(siteModel, DisplayMode.CutFill, siteModel.SiteModelExtent) : null;

            var designUid       = DITAGFileAndSubGridRequestsWithIgniteFixture.AddDesignToSiteModel(ref siteModel, TestHelper.CommonTestDataPath, "Bug36372.ttm", false);
            var referenceDesign = new DesignOffset(designUid, offset);

            var request = new TileRenderRequest();
            var arg     = SimpleTileRequestArgument(siteModel, DisplayMode.CutFill, palette, volumeType: VolumeComputationType.BetweenDesignAndFilter);

            // Add the cut/fill design reference to the request, and set the rendering extents to the cell in question,
            // with an additional 1 meter border around the cell
            arg.ReferenceDesign = referenceDesign;
            arg.Extents         = siteModel.Grid.GetCellExtents(cellX, cellY);
            arg.Extents.Expand(1.0, 1.0);

            var response = await request.ExecuteAsync(arg);

            CheckSimpleRenderTileResponse(response);

            //The tile for 0 offset is red, for -25 it is blue
            //File.WriteAllBytes($@"c:\temp\TRexTileRender-Unit-Test-{DisplayMode.CutFill}.bmp", ((TileRenderResponse) response).TileBitmapData);
        }
Exemplo n.º 22
0
        public async Task Request_SingleTriangle_ZeroTolerance()
        {
            AddGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            // Create three cells in a triangle at (0, 0), (0, 1) & (1, 0)
            var cellPasses = new List <CellPass> {
                new CellPass {
                    Time = DateTime.UtcNow, Height = 1.0f
                }
            };

            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);
            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset + 1, cellPasses);
            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset + 1, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses);
            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset + 1, SubGridTreeConsts.DefaultIndexOriginOffset + 1, cellPasses);

            DITAGFileAndSubGridRequestsFixture.ConvertSiteModelToImmutable(siteModel);

            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 VSS.TRex.Designs.TTM.TrimbleTINModel();

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

            model.Vertices.Count.Should().Be(4);
            model.Triangles.Count.Should().Be(2);
        }
Exemplo n.º 23
0
        public void Test_ACS_Coordinate_Conversion_Dimensions()
        {
            var targetSiteModel = BuildModel();

            DITAGFileAndSubGridRequestsWithIgniteFixture.AddCSIBToSiteModel(ref targetSiteModel, TestCommonConsts.DIMENSIONS_2012_DC_CSIB);
            var converter = DITagFileFixture.ReadTAGFile("ACS--Dimensions--CATACOM--121030175139.tag", Guid.NewGuid(), false, ref targetSiteModel);

            Assert.True(converter.IsUTMCoordinateSystem, "Tagfile should be ACS coordinate system");
            converter.Processor.ConvertedBladePositions.Should().NotBeNull();
            converter.Processor.ConvertedBladePositions.Should().HaveCount(429);
            converter.Processor.ConvertedBladePositions[0].Left.X.Should().BeApproximately(2740.5499, 0.01);
            converter.Processor.ConvertedBladePositions[0].Left.Y.Should().BeApproximately(1171.5488, 0.01);
            converter.Processor.ConvertedBladePositions[0].Left.Z.Should().BeApproximately(623.91649, 0.01);
            converter.Processor.ConvertedBladePositions[0].Right.X.Should().BeApproximately(2740.592, 0.01);
            converter.Processor.ConvertedBladePositions[0].Right.Y.Should().BeApproximately(1169.576, 0.01);
            converter.Processor.ConvertedBladePositions[0].Right.Z.Should().BeApproximately(623.7330, 0.01);
            converter.Processor.ConvertedRearAxlePositions.Should().HaveCount(0);
            converter.Processor.ConvertedTrackPositions.Should().HaveCount(0);
            converter.Processor.ConvertedWheelPositions.Should().HaveCount(0);
            converter.ProcessedCellPassCount.Should().Be(1003);
            converter.ProcessedEpochCount.Should().Be(429);
            Assert.True(converter.ReadResult == TAGReadResult.NoError, $"converter.ReadResult == TAGReadResult.NoError [= {converter.ReadResult}");
        }
Exemplo n.º 24
0
        private ISiteModel BuildModelForSingleCellSpeed(ushort mdpIncrement)
        {
            var    baseTime = DateTime.UtcNow;
            ushort baseMDP  = 10;

            var siteModel             = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

            var cellPasses = Enumerable.Range(0, 10).Select(x =>
                                                            new CellPass
            {
                InternalSiteModelMachineIndex = bulldozerMachineIndex,
                Time         = baseTime.AddMinutes(x),
                MachineSpeed = (ushort)(baseMDP + x * mdpIncrement),
                PassType     = PassType.Front
            }).ToArray();

            DITAGFileAndSubGridRequestsFixture.AddSingleCellWithPasses
                (siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses, 1, cellPasses.Length);
            DITAGFileAndSubGridRequestsFixture.ConvertSiteModelToImmutable(siteModel);

            return(siteModel);
        }
Exemplo n.º 25
0
        public async Task Test_TileRenderRequest_SurveyedSurface_ElevationOnly()
        {
            // Render a surveyed surface area of 100x100 meters in a tile 150x150 meters with a single cell with
            // production data placed at the origin
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();
            AddDesignProfilerGridRouting();

            // A location on the bug36372.ttm surface - X=247500.0, Y=193350.0
            const double LOCATION_X = 00.0;
            const double LOCATION_Y = 0.0;

            // Find the location of the cell in the site model for that location
            SubGridTree.CalculateIndexOfCellContainingPosition
                (LOCATION_X, LOCATION_Y, SubGridTreeConsts.DefaultCellSize, SubGridTreeConsts.DefaultIndexOriginOffset, out var cellX, out var cellY);

            // Create the site model containing a single cell and add the surveyed surface to it
            var siteModel = BuildModelForSingleCellTileRender(HEIGHT_INCREMENT_0_5, CCV_INCREMENT, cellX, cellY);

            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSurveyedSurfaceEncompassingExtent(ref siteModel,
                                                                                                    new TRex.Geometry.BoundingWorldExtent3D(0, 0, 100, 100), DateTime.UtcNow, new[] { 100.0, 100.0, 100.0, 100.0 });
            var palette = PVMPaletteFactory.GetPalette(siteModel, DisplayMode.Height, siteModel.SiteModelExtent);

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

            arg.Extents = new TRex.Geometry.BoundingWorldExtent3D(0, 0, 150, 150);

            var response = await request.ExecuteAsync(arg);

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

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

            CheckSimpleRenderTileResponse(response, DisplayMode.Height, saveFileName, path);
        }
Exemplo n.º 26
0
        private ISiteModel BuildModelForProductionDataAndOrSurveyedSurface(DateTime baseTime, int?totalMins, int?ssMins)
        {
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            if (totalMins.HasValue)
            {
                var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex;

                // Ensure the machine has start and stop events (don't need actual cell passes)
                siteModel.MachinesTargetValues[bulldozerMachineIndex].StartEndRecordedDataEvents.PutValueAtDate(baseTime, ProductionEventType.StartEvent);
                siteModel.MachinesTargetValues[bulldozerMachineIndex].StartEndRecordedDataEvents.PutValueAtDate(baseTime.AddMinutes(totalMins.Value), ProductionEventType.EndEvent);

                siteModel.MachinesTargetValues[bulldozerMachineIndex].SaveMachineEventsToPersistentStore(siteModel.PrimaryStorageProxy);
            }

            if (ssMins.HasValue)
            {
                siteModel.SurveyedSurfaces.AddSurveyedSurfaceDetails(Guid.NewGuid(), DesignDescriptor.Null(), baseTime.AddMinutes(ssMins.Value), BoundingWorldExtent3D.Null());
            }

            DITAGFileAndSubGridRequestsFixture.ConvertSiteModelToImmutable(siteModel);

            return(siteModel);
        }
Exemplo n.º 27
0
 public void ProcessChangeMapUpdateItems_NonEmptyMap_SingleSubGridAtOrigin()
 {
     var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
     var changeMap = new SubGridTreeSubGridExistenceBitMask
     {
Exemplo n.º 28
0
        public async Task Test_RenderOverlayTile_SurveyedSurface_ElevationOnly_Rotated(int initialRotation, int maxRotation, int rotationIncrement, double rotateAboutX, double rotateAboutY, ushort imagePixelSize)
        {
            AddClusterComputeGridRouting();
            AddDesignProfilerGridRouting();

            // Render a surveyed surface area of 100x100 meters in a tile 150x150 meters with a single cell with
            // production data placed at the origin

            // A location on the bug36372.ttm surface - X=247500.0, Y=193350.0
            const double LOCATION_X = 0.0;
            const double LOCATION_Y = 0.0;

            // Find the location of the cell in the site model for that location
            SubGridTree.CalculateIndexOfCellContainingPosition
                (LOCATION_X, LOCATION_Y, SubGridTreeConsts.DefaultCellSize, SubGridTreeConsts.DefaultIndexOriginOffset, out var cellX, out var cellY);

            // Create the site model containing a single cell and add the surveyed surface to it
            var siteModel = BuildModelForSingleCellTileRender(HEIGHT_INCREMENT_0_5, cellX, cellY);

            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSurveyedSurfaceEncompassingExtent(ref siteModel,
                                                                                                    new BoundingWorldExtent3D(-100, -100, 200, 200), DateTime.UtcNow, new double[] { 100, 100, 105, 105 });

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

            var rotationDegrees = initialRotation;

            while (rotationDegrees <= maxRotation)
            {
                // Rotate the 'top right'/rotatedPoint by x degrees/ Negate the rotation so the RotatePointAbout method match survey angle convention
                var rot = MathUtilities.DegreesToRadians(-rotationDegrees);
                GeometryHelper.RotatePointAbout(rot, 0, 0, out var rotatedBottomLeftPointX, out var rotatedBottomLeftPointY, rotateAboutX, rotateAboutY);
                GeometryHelper.RotatePointAbout(rot, 100, 100, out var rotatedTopRightPointX, out var rotatedTopRightPointY, rotateAboutX, rotateAboutY);
                GeometryHelper.RotatePointAbout(rot, 0, 100, out var rotatedTopLeftPointX, out var rotatedTopLeftPointY, rotateAboutX, rotateAboutY);
                GeometryHelper.RotatePointAbout(rot, 100, 0, out var rotatedBottomRightPointX, out var rotatedBottomRightPointY, rotateAboutX, rotateAboutY);

                var mockConvertCoordinates = new Mock <ICoreXWrapper>();
                mockConvertCoordinates.Setup(x => x.LLHToNEE(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), It.IsAny <CoreX.Types.InputAs>())).Returns(new CoreXModels.XYZ[]
                {
                    new CoreXModels.XYZ(rotatedBottomLeftPointX, rotatedBottomLeftPointY, 0.0),
                    new CoreXModels.XYZ(rotatedTopRightPointX, rotatedTopRightPointY, 0.0),
                    new CoreXModels.XYZ(rotatedTopLeftPointX, rotatedTopLeftPointY, 0.0),
                    new CoreXModels.XYZ(rotatedBottomRightPointX, rotatedBottomRightPointY, 0.0)
                }
                                                                                                                                                             );

                DIBuilder.Continue().Add(x => x.AddSingleton(mockConvertCoordinates.Object)).Complete();
                var render = new RenderOverlayTile(siteModel.ID,
                                                   DisplayMode.Height,
                                                   new XYZ(0, 0),
                                                   new XYZ(100, 100),
                                                   false,          // Coords are LLH for rotated, grid otherwise - the mocked conversion above will return the true rotated grid coordinates
                                                   imagePixelSize, //PixelsX
                                                   imagePixelSize, // PixelsY
                                                   new FilterSet(new CombinedFilter()),
                                                   new DesignOffset(),
                                                   palette,
                                                   Color.Black,
                                                   Guid.Empty,
                                                   new LiftParameters(),
                                                   VolumeComputationType.None);

                var result = await render.ExecuteAsync();

                result.Should().NotBeNull();

                var filename     = $"RotatedOverlayTileWithSurveyedSurface({imagePixelSize} pixels, rotate about {rotateAboutX},{rotateAboutY} by {rotationDegrees} degrees).bmp";
                var path         = Path.Combine("TestData", "RenderedTiles", "SurveyedSurface", filename);
                var saveFileName = ""; // @$"c:\temp\{filename}";
                CheckSimpleRenderTileResponse(result, saveFileName, "");

                rotationDegrees += rotationIncrement;
            }
        }