Exemplo n.º 1
0
        public async Task Test_SimpleVolumesRequest_ApplicationService_DesignToDefaultFilter_SingleCell()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();
            AddDesignProfilerGridRouting();

            var siteModel = BuildModelForSingleCellSummaryVolume(-ELEVATION_INCREMENT_0_5);

            var baseDesign = DITAGFileAndSubGridRequestsWithIgniteFixture.ConstructSingleFlatTriangleDesignAboutOrigin(ref siteModel, 0);

            var request = new SimpleVolumesRequest_ApplicationService();
            var arg     = SimpleDefaultRequestArg(siteModel.ID);

            arg.VolumeType = VolumeComputationType.BetweenDesignAndFilter;
            arg.BaseDesign = new DesignOffset(baseDesign, 0);

            var response = await request.ExecuteAsync(arg);

            const double EPSILON = 0.000001;

            response.Should().NotBeNull();
            response.Cut.Should().BeApproximately(3.5 * 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);
        }
Exemplo n.º 2
0
        public async Task Test_SimpleVolumesRequest_ApplicationService_FilterToFilterWithIntermediary_Execute_SingleCell_ProjectExtent()
        {
            void CheckVolumesResponse(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.5202, EPSILON);
                response.Fill.Should().BeApproximately(0.0, EPSILON);
                response.CutArea.Should().BeApproximately(0.1156, EPSILON);
                response.FillArea.Should().BeApproximately(0.0, EPSILON);
                response.TotalCoverageArea.Should().BeApproximately(0.1156, EPSILON);

                response.BoundingExtentGrid.MinX.Should().BeApproximately(0, EPSILON);
                response.BoundingExtentGrid.MinY.Should().BeApproximately(0, EPSILON);
                response.BoundingExtentGrid.MaxX.Should().BeApproximately(0.34, EPSILON);
                response.BoundingExtentGrid.MaxY.Should().BeApproximately(0.34, EPSILON);
                response.BoundingExtentGrid.MinZ.Should().Be(Consts.NullDouble);
                response.BoundingExtentGrid.MaxZ.Should().Be(Consts.NullDouble);
            }

            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var siteModel = BuildModelForSingleCellSummaryVolume(-ELEVATION_INCREMENT_0_5);

            var request = new SimpleVolumesRequest_ApplicationService();

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

            CheckVolumesResponse(response);
        }
Exemplo n.º 3
0
        public async Task Test_SimpleVolumesRequest_ApplicationService_FilterToFilter_EarliestToMidTime_Execute_SingleTAGFile()
        {
            const string expectedResponseText = "{\"Cut\":0.6670116119384769,\"Fill\":2.2439066680908204,\"TotalCoverageArea\":279.75200000000007,\"CutArea\":78.72360000000002,\"FillArea\":175.24960000000004,\"BoundingExtentGrid\":{\"MinX\":537669.2000000001,\"MinY\":5427396.54,\"MaxX\":537675.6600000001,\"MaxY\":5427509.76,\"MinZ\":1E+308,\"MaxZ\":1E+308,\"Area\":731.4012000072782,\"CenterX\":537672.4300000002,\"CenterY\":5427453.15,\"CenterZ\":1E+308,\"IsMaximalPlanConverage\":false,\"IsValidHeightExtent\":false,\"IsValidPlanExtent\":true,\"LargestPlanDimension\":113.21999999973923,\"SizeX\":6.460000000079162,\"SizeY\":113.21999999973923,\"SizeZ\":0.0},\"BoundingExtentLLH\":{\"MinX\":1E+308,\"MinY\":1E+308,\"MaxX\":1E+308,\"MaxY\":1E+308,\"MinZ\":1E+308,\"MaxZ\":1E+308,\"Area\":0.0,\"CenterX\":1E+308,\"CenterY\":1E+308,\"CenterZ\":1E+308,\"IsMaximalPlanConverage\":false,\"IsValidHeightExtent\":false,\"IsValidPlanExtent\":false,\"LargestPlanDimension\":1E+308,\"SizeX\":0.0,\"SizeY\":0.0,\"SizeZ\":0.0},\"ResponseCode\":1,\"ClusterNode\":\"\",\"NumSubgridsProcessed\":0,\"NumSubgridsExamined\":0,\"NumProdDataSubGridsProcessed\":0,\"NumProdDataSubGridsExamined\":0,\"NumSurveyedSurfaceSubGridsProcessed\":0,\"NumSurveyedSurfaceSubGridsExamined\":0}";

            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

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

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

            var request = new SimpleVolumesRequest_ApplicationService();
            var arg     = SimpleDefaultRequestArg(siteModel.ID);

            var(startUtc, endUtc) = siteModel.GetDateRange();

            arg.TopFilter.AttributeFilter.HasTimeFilter = true;
            arg.TopFilter.AttributeFilter.StartTime     = DateTime.SpecifyKind(new DateTime((startUtc.Ticks + endUtc.Ticks) / 2), DateTimeKind.Utc);

            var response = await request.ExecuteAsync(arg);

            // var responseText = JsonConvert.SerializeObject(response);
            JsonConvert.DeserializeObject <SimpleVolumesResponse>(expectedResponseText).Should().BeEquivalentTo(response);
        }
Exemplo n.º 4
0
        public async Task <JsonResult> GetVolume(string siteModelID,
                                                 [FromQuery] string filter)
        {
            var filterJson = Encoding.ASCII.GetString(Convert.FromBase64String(filter));

            // Create the two filters necessary to capture the earliest and latest surfaces for the volume
            var baseFilter = JsonConvert.DeserializeObject <CombinedFilter>(filterJson);

            baseFilter.AttributeFilter.ReturnEarliestFilteredCellPass = true;
            baseFilter.SpatialFilter.Fence?.UpdateExtents();
            var topFilter = JsonConvert.DeserializeObject <CombinedFilter>(filterJson);

            topFilter.SpatialFilter.Fence?.UpdateExtents();

            var request  = new SimpleVolumesRequest_ApplicationService();
            var response = await request.ExecuteAsync(new SimpleVolumesRequestArgument
            {
                ProjectID  = Guid.Parse(siteModelID),
                VolumeType = VolumeComputationType.Between2Filters,
                BaseFilter = baseFilter,
                TopFilter  = topFilter
            });

            return(new JsonResult(response));
        }
Exemplo n.º 5
0
        public async Task Test_SimpleVolumesRequest_ApplicationService_DefaultFilterToFilter_Execute_NoData()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var request  = new SimpleVolumesRequest_ApplicationService();
            var response = await request.ExecuteAsync(SimpleDefaultRequestArg(Guid.NewGuid()));

            // This is a no data test, so the response will be null
            CheckResponseContainsNullValues(response);
        }
Exemplo n.º 6
0
        public async Task Test_SimpleVolumesRequest_ApplicationService_DefaultFilterToFilter_Execute_SingleCell_WithCut()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

            var siteModel = BuildModelForSingleCellSummaryVolume(-ELEVATION_INCREMENT_0_5);

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

            CheckDefaultFilterToFilterSingleCutCellAtOriginResponse(response);
        }
Exemplo n.º 7
0
        public async Task FilterToFilter_TwoFilters_WithIntermediary()
        {
            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 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)
                    }
                },
                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)
                    }
                },
                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);
        }
Exemplo n.º 8
0
        public async Task Test_SimpleVolumesRequest_ApplicationService_DefaultFilterToFilter_Execute_SingleTAGFile()
        {
            AddApplicationGridRouting();
            AddClusterComputeGridRouting();

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

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

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

            CheckDefaultFilterToFilterSingleTAGFileResponse(response);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item)
        {
            var request = item as SummaryVolumesDataRequest;

            if (request == null)
            {
                ThrowRequestTypeCastException <SummaryVolumesDataRequest>();
            }

            // ReSharper disable once PossibleNullReferenceException
            var siteModel = GetSiteModel(request.ProjectUid);

            var baseFilter = ConvertFilter(request.BaseFilter, siteModel);
            var topFilter  = ConvertFilter(request.TopFilter, siteModel);
            var additionalSpatialFilter = ConvertFilter(request.AdditionalSpatialFilter, siteModel);

            var summaryVolumesRequest = new SimpleVolumesRequest_ApplicationService();

            var simpleVolumesResponse = await summaryVolumesRequest.ExecuteAsync(new SimpleVolumesRequestArgument
            {
                ProjectID  = siteModel.ID,
                BaseFilter = baseFilter,
                TopFilter  = topFilter,
                AdditionalSpatialFilter = additionalSpatialFilter,
                BaseDesign    = new DesignOffset(request.BaseDesignUid ?? Guid.Empty, request.BaseDesignOffset ?? 0),
                TopDesign     = new DesignOffset(request.TopDesignUid ?? Guid.Empty, request.TopDesignOffset ?? 0),
                VolumeType    = ConvertVolumesHelper.ConvertVolumesType(request.VolumeCalcType),
                CutTolerance  = request.CutTolerance ?? VolumesConsts.DEFAULT_CELL_VOLUME_CUT_TOLERANCE,
                FillTolerance = request.CutTolerance ?? VolumesConsts.DEFAULT_CELL_VOLUME_FILL_TOLERANCE
            });

            if (simpleVolumesResponse != null)
            {
                log.LogInformation($"Volume response is {JsonConvert.SerializeObject(simpleVolumesResponse)}");
                return(ConvertResult(simpleVolumesResponse));
            }

            log.LogWarning("Volume response is null");
            throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults,
                                                                                              "Failed to get requested Summary Volumes data"));
        }
Exemplo n.º 11
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);
        }