예제 #1
0
        public async Task GetBoundingBoxDesignBoundaryFilter()
        {
            var design       = new DesignDescriptor(-1, null, 0);
            var filterResult = FilterResult.CreateFilterObsolete(designFile: design);
            var raptorClient = new Mock <IASNodeClient>();

            TDesignProfilerRequestResult designProfilerResult;
            var ms = new MemoryStream();

            using (var writer = new StreamWriter(ms))
            {
                writer.Write(DESIGN_GEO_JSON);
                writer.Flush();

                raptorClient
                .Setup(x => x.GetDesignBoundary(It.IsAny <TDesignProfilerServiceRPCVerb_CalculateDesignBoundary_Args>(),
                                                out ms, out designProfilerResult))
                .Returns(true);

                var service = new BoundingBoxService(serviceProvider.GetRequiredService <ILoggerFactory>()
#if RAPTOR
                                                     , raptorClient.Object
#endif
                                                     , new Mock <IConfigurationStore>().Object
                                                     , new Mock <ITRexCompactionDataProxy>().Object, new Mock <IFileImportProxy>().Object
                                                     );
                var bbox = await service.GetBoundingBox(project, filterResult, new[] { TileOverlayType.BaseMap }, null, null, null, null, null);

                //Values are from GeoJson below
                Assert.AreEqual(-115.123.LonDegreesToRadians(), bbox.minLng);
                Assert.AreEqual(36.175.LatDegreesToRadians(), bbox.minLat);
                Assert.AreEqual(-115.018.LonDegreesToRadians(), bbox.maxLng);
                Assert.AreEqual(36.214.LatDegreesToRadians(), bbox.maxLat);
            }
        }
예제 #2
0
        public void MapFilterResultHasElevationRangeFilterToCombinedFilter()
        {
            //Offset from bench
            var filterResult = FilterResult.CreateFilterObsolete(layerType: FilterLayerMethod.OffsetFromBench, benchElevation: 1.25, layerNumber: 3, layerThickness: 0.4);

            filterResult.Validate();

            var combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);

            combinedFilter.AttributeFilter.HasLayerStateFilter.Should().Be(true);
            combinedFilter.AttributeFilter.LayerState.Should().Be(LayerState.On);
            combinedFilter.AttributeFilter.HasElevationRangeFilter.Should().Be(true);
            combinedFilter.AttributeFilter.ElevationRangeLevel.Should().Be(filterResult.BenchElevation);
            combinedFilter.AttributeFilter.ElevationRangeOffset.Should().Be(filterResult.LayerNumber * filterResult.LayerThickness);
            combinedFilter.AttributeFilter.ElevationRangeThickness.Should().Be(filterResult.LayerThickness);

            //Offset from design
            var designFile = new DesignDescriptor(-1, null, 0, Guid.NewGuid());

            filterResult = FilterResult.CreateFilterObsolete(layerType: FilterLayerMethod.OffsetFromDesign, layerDesignOrAlignmentFile: designFile, layerNumber: -2, layerThickness: 0.3);
            filterResult.Validate();

            combinedFilter = AutoMapperUtility.Automapper.Map <CombinedFilter>(filterResult);
            combinedFilter.AttributeFilter.HasLayerStateFilter.Should().Be(true);
            combinedFilter.AttributeFilter.LayerState.Should().Be(LayerState.On);
            combinedFilter.AttributeFilter.HasElevationRangeFilter.Should().Be(true);
            combinedFilter.AttributeFilter.ElevationRangeDesign.Should().NotBeNull();
            combinedFilter.AttributeFilter.ElevationRangeDesign.DesignID.Should().Be(designFile.FileUid.Value);
            combinedFilter.AttributeFilter.ElevationRangeDesign.Offset.Should().Be(designFile.Offset);
            combinedFilter.AttributeFilter.ElevationRangeOffset.Should().Be((filterResult.LayerNumber + 1) * filterResult.LayerThickness);
            combinedFilter.AttributeFilter.ElevationRangeThickness.Should().Be(filterResult.LayerThickness);
        }
예제 #3
0
        public async Task GetBoundingBoxPolygonFilter()
        {
            var polygonPoints = new List <WGSPoint>
            {
                new WGSPoint(10, 20),
                new WGSPoint(15, 20),
                new WGSPoint(13, 15),
                new WGSPoint(25, 30),
                new WGSPoint(27, 27)
            };

            var filterResult = FilterResult.CreateFilterObsolete(polygonLL: polygonPoints);
            var raptorClient = new Mock <IASNodeClient>();

            var service = new BoundingBoxService(serviceProvider.GetRequiredService <ILoggerFactory>()
#if RAPTOR
                                                 , raptorClient.Object
#endif
                                                 , new Mock <IConfigurationStore>().Object
                                                 , new Mock <ITRexCompactionDataProxy>().Object, new Mock <IFileImportProxy>().Object
                                                 );
            var bbox = await service.GetBoundingBox(project, filterResult, new[] { TileOverlayType.BaseMap }, null, null, null, null, null);

            Assert.AreEqual(polygonPoints.Min(p => p.Lat), bbox.minLat);
            Assert.AreEqual(polygonPoints.Min(p => p.Lon), bbox.minLng);
            Assert.AreEqual(polygonPoints.Max(p => p.Lat), bbox.maxLat);
            Assert.AreEqual(polygonPoints.Max(p => p.Lon), bbox.maxLng);
        }
예제 #4
0
 public static void ClassInit(TestContext context)
 {
     filterResult = FilterResult.CreateFilterObsolete(
         0, null, "name", "desc", DateTime.Now, DateTime.Now, 1, "designName", null, false, false, ElevationType.Highest,
         new List <WGSPoint>(), new List <Point>(), false, null, 0, 0, 0, 0,
         FilterLayerMethod.None, null, 0, 0, 0, new List <MachineDetails>(), new List <long>(),
         true, GPSAccuracyType.Coarse, false, false, false, false);
 }
예제 #5
0
        public void MapFilterResultHasAlignmentFilterToCombinedFilter()
        {
            var alignment = new DesignDescriptor(42l, FileDescriptor.CreateFileDescriptor("x", "y", "z"), 0, Guid.NewGuid());
            var filter    = FilterResult.CreateFilterObsolete(alignmentFile: alignment);

            var combinedFilter = AutoMapperUtility.Automapper.Map <FilterResult, CombinedFilter>(filter);

            combinedFilter.Should().NotBeNull();
            combinedFilter.SpatialFilter.IsDesignMask.Should().BeFalse();
            combinedFilter.SpatialFilter.SurfaceDesignMaskDesignUid.Should().Be(Guid.Empty);
            combinedFilter.SpatialFilter.IsAlignmentMask.Should().BeTrue();
            combinedFilter.SpatialFilter.AlignmentDesignMaskDesignUID.Should().Be(alignment.FileUid.Value);
        }
예제 #6
0
        public async Task GetBoundingBoxAlignmentFilter()
        {
            var alignment    = new DesignDescriptor(-1, null, 0);
            var filterResult = FilterResult.CreateFilterObsolete(alignmentFile: alignment, startStation: 0, endStation: 3, leftOffset: 0.5, rightOffset: 0.5);

            var raptorClient = new Mock <IASNodeClient>();

            TWGS84Point[] fence =
            {
                new TWGS84Point {
                    Lat = 36.1.LatDegreesToRadians(), Lon = -115.1.LonDegreesToRadians()
                },
                new TWGS84Point {
                    Lat = 36.2.LatDegreesToRadians(), Lon = -115.1.LonDegreesToRadians()
                },
                new TWGS84Point {
                    Lat = 36.3.LatDegreesToRadians(), Lon = -115.2.LonDegreesToRadians()
                },
                new TWGS84Point {
                    Lat = 36.3.LatDegreesToRadians(), Lon = -115.3.LonDegreesToRadians()
                },
                new TWGS84Point {
                    Lat = 36.2.LatDegreesToRadians(), Lon = -115.3.LonDegreesToRadians()
                },
                new TWGS84Point {
                    Lat = 36.2.LatDegreesToRadians(), Lon = -115.2.LonDegreesToRadians()
                },
                new TWGS84Point {
                    Lat = 36.1.LatDegreesToRadians(), Lon = -115.1.LonDegreesToRadians()
                }
            };

            raptorClient
            .Setup(x => x.GetDesignFilterBoundaryAsPolygon(It.IsAny <TDesignProfilerServiceRPCVerb_ComputeDesignFilterBoundary_Args>(),
                                                           out fence))
            .Returns(true);

            var service = new BoundingBoxService(serviceProvider.GetRequiredService <ILoggerFactory>()
#if RAPTOR
                                                 , raptorClient.Object
#endif
                                                 , new Mock <IConfigurationStore>().Object
                                                 , new Mock <ITRexCompactionDataProxy>().Object, new Mock <IFileImportProxy>().Object
                                                 );
            var bbox = await service.GetBoundingBox(project, filterResult, new[] { TileOverlayType.BaseMap }, null, null, null, null, null);

            Assert.AreEqual(-115.3.LonDegreesToRadians(), bbox.minLng);
            Assert.AreEqual(36.1.LatDegreesToRadians(), bbox.minLat);
            Assert.AreEqual(-115.1.LonDegreesToRadians(), bbox.maxLng);
            Assert.AreEqual(36.3.LatDegreesToRadians(), bbox.maxLat);
        }
예제 #7
0
        public async Task GetBoundingBoxSummaryVolumesFilter()
        {
            var polygonPoints1 = new List <WGSPoint>
            {
                new WGSPoint(10, 20),
                new WGSPoint(15, 20),
                new WGSPoint(13, 15),
                new WGSPoint(25, 30),
                new WGSPoint(27, 27)
            };

            var baseFilterResult = FilterResult.CreateFilterObsolete(polygonLL: polygonPoints1);

            var polygonPoints2 = new List <WGSPoint>
            {
                new WGSPoint(30, 20),
                new WGSPoint(25, 25),
                new WGSPoint(50, 35),
                new WGSPoint(25, 15),
                new WGSPoint(32, 16)
            };

            var topFilterResult = FilterResult.CreateFilterObsolete(polygonLL: polygonPoints2);

            var raptorClient = new Mock <IASNodeClient>();

            var service = new BoundingBoxService(serviceProvider.GetRequiredService <ILoggerFactory>()
#if RAPTOR
                                                 , raptorClient.Object
#endif
                                                 , new Mock <IConfigurationStore>().Object
                                                 , new Mock <ITRexCompactionDataProxy>().Object, new Mock <IFileImportProxy>().Object
                                                 );
            var bbox = await service.GetBoundingBox(project, null, new[] { TileOverlayType.BaseMap }, baseFilterResult, topFilterResult, null, null, null);

            var expectedMinLat = Math.Min(polygonPoints1.Min(p => p.Lat), polygonPoints2.Min(p => p.Lat));
            var expectedMinLng = Math.Min(polygonPoints1.Min(p => p.Lon), polygonPoints2.Min(p => p.Lon));
            var expectedMaxLat = Math.Max(polygonPoints1.Max(p => p.Lat), polygonPoints2.Max(p => p.Lat));
            var expectedMaxLng = Math.Max(polygonPoints1.Max(p => p.Lon), polygonPoints2.Max(p => p.Lon));

            Assert.AreEqual(expectedMinLat, bbox.minLat);
            Assert.AreEqual(expectedMinLng, bbox.minLng);
            Assert.AreEqual(expectedMaxLat, bbox.maxLat);
            Assert.AreEqual(expectedMaxLng, bbox.maxLng);
        }
예제 #8
0
        public void CPR_CanCreateCellPassesRequestTest()
        {
            var liftThicknessTarget = new LiftThicknessTarget {
                AboveToleranceLiftThickness = (float)0.001,
                BelowToleranceLiftThickness = (float)0.002,
                TargetLiftThickness         = (float)0.05
            };

            var validator = new DataAnnotationsValidator();

            CellPassesRequest cpRequest = CellPassesRequest.CreateCellPassRequest(544, null, null, null, null, 0, 0,
                                                                                  null);

            Assert.IsTrue(validator.TryValidate(cpRequest, out ICollection <ValidationResult> results));

            // invalid projectid
            cpRequest = CellPassesRequest.CreateCellPassRequest(-1, null, null, null, null, 0, 0, null);
            Assert.IsFalse(validator.TryValidate(cpRequest, out results));

            // full data
            CellAddress       cellAddress = CellAddress.CreateCellAddress(1, 2);
            Point             point       = Point.CreatePoint(1.0, 2.0);
            WGSPoint          wgsPoint    = new WGSPoint(1.0, 2.0);
            LiftBuildSettings settings    = new LiftBuildSettings(
                new CCVRangePercentage(30.0, 70.0), false, 0.0, 0.0, 0.2f, LiftDetectionType.Automatic,
                LiftThicknessType.Compacted, new MDPRangePercentage(35.0, 75.0),
                false, 0.0f, 0, 0, null, null, null, liftThicknessTarget, null);

            var filterResult = FilterResult.CreateFilterObsolete(null, null, null, null, null, null, 1, "", new List <long>(), true, false, null,
                                                                 new List <WGSPoint>(),
                                                                 new List <Point>(),
                                                                 false,
                                                                 new DesignDescriptor(1, FileDescriptor.EmptyFileDescriptor, 0),
                                                                 0, 0, 0, 0,
                                                                 null, new DesignDescriptor(1, FileDescriptor.EmptyFileDescriptor, 0),
                                                                 0, 0, 0,
                                                                 new List <MachineDetails>(),
                                                                 new List <long>(),
                                                                 false, GPSAccuracyType.Medium, false, null, null, null,
                                                                 new DesignDescriptor(1, FileDescriptor.EmptyFileDescriptor, 0));

            cpRequest = CellPassesRequest.CreateCellPassRequest(544, cellAddress, point, wgsPoint, settings, 0, 0, filterResult);
            Assert.IsTrue(validator.TryValidate(cpRequest, out results));
        }
예제 #9
0
        public async Task GetBoundingBoxPolygonAndDesignBoundaryFilter()
        {
            //design boundary points: -115.018,36.208 -115.025,36.214 -115.123,36.17 -115.018,36.208
            var design        = new DesignDescriptor(-1, null, 0);
            var polygonPoints = new List <WGSPoint>
            {
                new WGSPoint(35.98.LatDegreesToRadians(), -115.11.LonDegreesToRadians()),
                new WGSPoint(36.15.LatDegreesToRadians(), -115.74.LonDegreesToRadians()),
                new WGSPoint(36.10.LatDegreesToRadians(), -115.39.LonDegreesToRadians())
            };
            var filterResult = FilterResult.CreateFilterObsolete(polygonLL: polygonPoints, designFile: design);

            var raptorClient = new Mock <IASNodeClient>();

            TDesignProfilerRequestResult designProfilerResult;
            var ms = new MemoryStream();

            using (var writer = new StreamWriter(ms))
            {
                writer.Write(DESIGN_GEO_JSON);
                writer.Flush();

                raptorClient
                .Setup(x => x.GetDesignBoundary(It.IsAny <TDesignProfilerServiceRPCVerb_CalculateDesignBoundary_Args>(),
                                                out ms, out designProfilerResult))
                .Returns(true);

                var service = new BoundingBoxService(serviceProvider.GetRequiredService <ILoggerFactory>()
#if RAPTOR
                                                     , raptorClient.Object
#endif
                                                     , new Mock <IConfigurationStore>().Object
                                                     , new Mock <ITRexCompactionDataProxy>().Object, new Mock <IFileImportProxy>().Object
                                                     );
                var bbox = await service.GetBoundingBox(project, filterResult, new[] { TileOverlayType.BaseMap }, null, null, null, null, null);

                //bbox is a mixture of polgon and design boundary (see GeoJson)
                Assert.AreEqual(-115.74.LonDegreesToRadians(), bbox.minLng);
                Assert.AreEqual(35.98.LatDegreesToRadians(), bbox.minLat);
                Assert.AreEqual(-115.018.LonDegreesToRadians(), bbox.maxLng);
                Assert.AreEqual(36.214.LatDegreesToRadians(), bbox.maxLat);
            }
        }
예제 #10
0
        public async Task GetBoundingBoxPolygonFilterAndCutFillDesign()
        {
            var polygonPoints = new List <WGSPoint>
            {
                new WGSPoint(10, 20),
                new WGSPoint(15, 20),
                new WGSPoint(13, 15),
                new WGSPoint(25, 30),
                new WGSPoint(27, 27)
            };

            var filterResult = FilterResult.CreateFilterObsolete(polygonLL: polygonPoints);
            var design       = new DesignDescriptor(-1, null, 0);
            var raptorClient = new Mock <IASNodeClient>();

            TDesignProfilerRequestResult designProfilerResult;
            var ms = new MemoryStream();

            using (var writer = new StreamWriter(ms))
            {
                writer.Write(DESIGN_GEO_JSON);
                writer.Flush();

                raptorClient
                .Setup(x => x.GetDesignBoundary(It.IsAny <TDesignProfilerServiceRPCVerb_CalculateDesignBoundary_Args>(),
                                                out ms, out designProfilerResult))
                .Returns(true);

                var service = new BoundingBoxService(serviceProvider.GetRequiredService <ILoggerFactory>()
#if RAPTOR
                                                     , raptorClient.Object
#endif
                                                     , new Mock <IConfigurationStore>().Object
                                                     , new Mock <ITRexCompactionDataProxy>().Object, new Mock <IFileImportProxy>().Object
                                                     );
                var bbox = await service.GetBoundingBox(project, filterResult, new[] { TileOverlayType.BaseMap }, null, null, design, null, null);

                Assert.AreEqual(polygonPoints.Min(p => p.Lat), bbox.minLat);
                Assert.AreEqual(polygonPoints.Min(p => p.Lon), bbox.minLng);
                Assert.AreEqual(polygonPoints.Max(p => p.Lat), bbox.maxLat);
                Assert.AreEqual(polygonPoints.Max(p => p.Lon), bbox.maxLng);
            }
        }