Ejemplo n.º 1
0
        public void Execute_SingleSurveyedSurface_WithSpatialCaching(SurveyedSurfacePatchType patchType, GridDataType expectedGridType)
        {
            AddApplicationGridRouting();

            var asAtDate  = DateTime.UtcNow;
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            // Construct a surveyed surface from the design
            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleSurveyedSurfaceAboutOrigin(ref siteModel, 1.0f, asAtDate);

            var cache   = new TRexSpatialMemoryCache(100, 10000, 0.5);
            var context = cache.LocateOrCreateContext(siteModel.ID, expectedGridType, $"Execute_SingleSurveyedSurface_WithSpatialCaching-{patchType}", TimeSpan.FromHours(1));
            var req     = new SurfaceElevationPatchRequestViaLocalCompute(cache, context);

            // Make one call which will populate the cache
            var result = req.Execute(new SurfaceElevationPatchArgument(siteModel.ID, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                                                                       siteModel.CellSize, patchType, SubGridTreeBitmapSubGridBits.FullMask, siteModel.SurveyedSurfaces));

            ValidateSurveyedSurfaceSuGridResult(siteModel, expectedGridType, patchType, result);

            // Make a second call which will utilise the value in the cache
            var result2 = req.Execute(new SurfaceElevationPatchArgument(siteModel.ID, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                                                                        siteModel.CellSize, patchType, SubGridTreeBitmapSubGridBits.FullMask, siteModel.SurveyedSurfaces));

            ValidateSurveyedSurfaceSuGridResult(siteModel, expectedGridType, patchType, result2);

            result.Should().BeEquivalentTo(result2);
        }
Ejemplo n.º 2
0
        public void Execute_FailWithNonExistentDesignReference(SurveyedSurfacePatchType patchType)
        {
            AddApplicationGridRouting();

            var asAtDate  = DateTime.UtcNow;
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            // Construct a surveyed surface from the design
            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleSurveyedSurfaceAboutOrigin(ref siteModel, 1.0f, asAtDate);

            // Delete the second surveyed surface TTM file from both it's original location and the project temporary folder
            string fileToDelete = siteModel.SurveyedSurfaces[0].DesignDescriptor.FullPath;

            File.Exists(fileToDelete).Should().BeTrue();
            File.Delete(fileToDelete);
            File.Exists(fileToDelete).Should().BeFalse();

            fileToDelete = Path.Combine(FilePathHelper.GetTempFolderForProject(siteModel.ID), siteModel.SurveyedSurfaces[0].DesignDescriptor.FileName);
            File.Exists(fileToDelete).Should().BeTrue();
            File.Delete(fileToDelete);
            File.Exists(fileToDelete).Should().BeFalse();

            var req    = new SurfaceElevationPatchRequestViaLocalCompute();
            var result = req.Execute(new SurfaceElevationPatchArgument(siteModel.ID, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                                                                       siteModel.CellSize, patchType, SubGridTreeBitmapSubGridBits.FullMask, siteModel.SurveyedSurfaces));

            result.Should().BeNull();
        }
Ejemplo n.º 3
0
        public void Execute_DualSurveyedSurfaces_DifferingInTime(SurveyedSurfacePatchType patchType, GridDataType expectedGridType)
        {
            AddApplicationGridRouting();

            var asAtDate  = DateTime.UtcNow;
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            // Construct a surveyed surface from the design
            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleSurveyedSurfaceAboutOrigin(ref siteModel, 1.0f, asAtDate);
            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleSurveyedSurfaceAboutOrigin(ref siteModel, 1.0f, asAtDate.AddMinutes(1));

            var filteredSurveyedSurfaces = new TRex.SurveyedSurfaces.SurveyedSurfaces();

            siteModel.SurveyedSurfaces.FilterSurveyedSurfaceDetails(false, Consts.MIN_DATETIME_AS_UTC, Consts.MIN_DATETIME_AS_UTC,
                                                                    false, filteredSurveyedSurfaces, new Guid[0]);

            var req    = new SurfaceElevationPatchRequestViaLocalCompute();
            var result = req.Execute(new SurfaceElevationPatchArgument(siteModel.ID, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                                                                       siteModel.CellSize, patchType, SubGridTreeBitmapSubGridBits.FullMask, filteredSurveyedSurfaces));

            ValidateSurveyedSurfaceSuGridResult(siteModel, expectedGridType, patchType, result);

            if (expectedGridType == GridDataType.HeightAndTime)
            {
                // Check the times on the result cells are correct
                result.ForEach((x, y) =>
                {
                    if (((ClientHeightAndTimeLeafSubGrid)result).Cells[x, y] != Consts.NullHeight)
                    {
                        ((ClientHeightAndTimeLeafSubGrid)result).Times[x, y].Should().Be
                            (patchType == SurveyedSurfacePatchType.EarliestSingleElevation ? asAtDate.Ticks : asAtDate.AddMinutes(1).Ticks);
                    }
                });
            }
        }
Ejemplo n.º 4
0
        public void Execute_WithInvalidPatchType()
        {
            AddApplicationGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var req       = new SurfaceElevationPatchRequestViaLocalCompute();

            req.Execute(new SurfaceElevationPatchArgument(siteModel.ID, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                                                          siteModel.CellSize, (SurveyedSurfacePatchType)100, SubGridTreeBitmapSubGridBits.FullMask, siteModel.SurveyedSurfaces)).Should().BeNull();
        }
Ejemplo n.º 5
0
        public void Execute_SingleSurveyedSurface(SurveyedSurfacePatchType patchType, GridDataType expectedGridType)
        {
            AddApplicationGridRouting();

            var asAtDate  = DateTime.UtcNow;
            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            // Construct a surveyed surface from the design
            DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleSurveyedSurfaceAboutOrigin(ref siteModel, 1.0f, asAtDate);

            var req    = new SurfaceElevationPatchRequestViaLocalCompute();
            var result = req.Execute(new SurfaceElevationPatchArgument(siteModel.ID, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset,
                                                                       siteModel.CellSize, patchType, SubGridTreeBitmapSubGridBits.FullMask, siteModel.SurveyedSurfaces));

            ValidateSurveyedSurfaceSuGridResult(siteModel, expectedGridType, patchType, result);
        }