Example #1
0
        public async Task Geometry_FromFile_WithArcConversion()
        {
            AddDesignProfilerGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();
            var designUid = DITAGFileAndSubGridRequestsWithIgniteFixture.AddSVLAlignmentDesignToSiteModel(ref siteModel, TestHelper.CommonTestDataPath, "Large Sites Road - Trimble Road.svl");

            var request  = new AlignmentDesignGeometryRequest();
            var response = await request.ExecuteAsync(new AlignmentDesignGeometryArgument
            {
                ProjectID              = siteModel.ID,
                AlignmentDesignID      = designUid,
                ConvertArcsToPolyLines = true,
                ArcChordTolerance      = 0.1
            });

            response.RequestResult.Should().Be(DesignProfilerRequestResult.OK);
            response.Vertices.Should().NotBeNull();
            response.Vertices.Length.Should().Be(1);

            response.Arcs.Should().NotBeNull();
            response.Arcs.Length.Should().Be(0);

            response.Labels.Should().NotBeNull();
            response.Labels.Length.Should().Be(21);
        }
Example #2
0
        public async Task Geometry_SimpleArcWithChords()
        {
            AddDesignProfilerGridRouting();

            var(siteModel, alignmentGuid) = ConstructSimpleArcNFFFileModel();

            var request  = new AlignmentDesignGeometryRequest();
            var response = await request.ExecuteAsync(new AlignmentDesignGeometryArgument
            {
                ProjectID              = siteModel.ID,
                AlignmentDesignID      = alignmentGuid,
                ConvertArcsToPolyLines = true,
                ArcChordTolerance      = 0.01
            });

            response.RequestResult.Should().Be(DesignProfilerRequestResult.OK);
            response.Vertices.Should().NotBeNullOrEmpty();
            response.Vertices.Length.Should().Be(1);
            response.Vertices[0].Length.Should().Be(7);

            response.Labels.Length.Should().Be(2);

            response.Labels[0].Station.Should().BeApproximately(0, 0.001);
            response.Labels[0].X.Should().BeApproximately(0, 0.001);
            response.Labels[0].Y.Should().BeApproximately(0, 0.001);
            response.Labels[0].Rotation.Should().BeApproximately(Math.PI, 0.000001);

            response.Labels[1].Station.Should().BeApproximately(Math.PI / 2, 0.001);
            response.Labels[1].X.Should().BeApproximately(1.0, 0.001);
            response.Labels[1].Y.Should().BeApproximately(1.0, 0.001);

            response.Labels[1].Rotation.Should().BeApproximately(Math.PI / 2, 0.000001);
        }
Example #3
0
        public Task <ContractExecutionResult> GetAlignmentGeometryForRendering([FromQuery] Guid projectUid, [FromQuery] Guid designUid, [FromQuery] string fileName,
                                                                               [FromQuery] bool convertArcsToChords, [FromQuery] double arcChordTolerance)
        {
            Log.LogInformation($"{nameof(GetAlignmentGeometryForRendering)}: projectUid:{projectUid}, designUid:{designUid}, fileName:{fileName}");

            var alignmentMasterGeometryRequest = new AlignmentDesignGeometryRequest(projectUid, designUid, fileName, convertArcsToChords, arcChordTolerance);

            alignmentMasterGeometryRequest.Validate();

            return(WithServiceExceptionTryExecuteAsync(() =>
                                                       RequestExecutorContainer
                                                       .Build <AlignmentMasterGeometryExecutor>(ConfigStore, LoggerFactory, ServiceExceptionHandler)
                                                       .ProcessAsync(alignmentMasterGeometryRequest)));
        }
Example #4
0
        public async Task AlignmentMasterGeometryExecutor_SiteModelNotFound()
        {
            const string FILE_NAME = "Test.svl";

            var projectUid = Guid.NewGuid();

            var request = new AlignmentDesignGeometryRequest(projectUid, Guid.NewGuid(), FILE_NAME);

            request.Validate();

            var executor = RequestExecutorContainer
                           .Build <AlignmentMasterGeometryExecutor>(
                DIContext.Obtain <IConfigurationStore>(),
                DIContext.Obtain <ILoggerFactory>(),
                DIContext.Obtain <IServiceExceptionHandler>());

            var result = await Assert.ThrowsAsync <ServiceException>(() => executor.ProcessAsync(request));

            Assert.Equal(HttpStatusCode.BadRequest, result.Code);
            Assert.Equal(ContractExecutionStatesEnum.InternalProcessingError, result.GetResult.Code);
            Assert.Equal($"Site model {projectUid} is unavailable", result.GetResult.Message);
        }
Example #5
0
        public async Task Geometry_SimpleLine()
        {
            AddDesignProfilerGridRouting();

            var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel();

            var polyline = new NFFLineworkPolyLineEntity();

            polyline.Vertices.Add(new NFFLineworkPolyLineVertexEntity(polyline, 1, 2, 3, 0));
            polyline.Vertices.Add(new NFFLineworkPolyLineVertexEntity(polyline, 2, 2, 4, 1));

            var alignment = new NFFGuidableAlignmentEntity();

            alignment.Entities.Add(polyline);

            var alignmentGuid = Guid.NewGuid();
            var testDesign    = new SVLAlignmentDesign(alignment);

            siteModel.Alignments.AddAlignmentDetails(alignmentGuid, new DesignDescriptor(alignmentGuid, "", ""), BoundingWorldExtent3D.Full());

            var mockDesignFiles = new Mock <IDesignFiles>();

            mockDesignFiles.Setup(x => x.Lock(It.IsAny <Guid>(), It.IsAny <ISiteModelBase>(), It.IsAny <double>(), out It.Ref <DesignLoadResult> .IsAny))
            .Returns(new GobbleDesignFilesLockReturns((Guid designUid, ISiteModelBase siteModel, double cellSize, out DesignLoadResult result) =>
            {
                result = DesignLoadResult.Success;
                return(testDesign);
            }));

            DIBuilder.
            Continue()
            .Add(x => x.AddSingleton(mockDesignFiles.Object))
            .Complete();

            var request  = new AlignmentDesignGeometryRequest();
            var response = await request.ExecuteAsync(new AlignmentDesignGeometryArgument
            {
                ProjectID              = siteModel.ID,
                AlignmentDesignID      = alignmentGuid,
                ConvertArcsToPolyLines = false,
                ArcChordTolerance      = 0.0
            });

            response.RequestResult.Should().Be(DesignProfilerRequestResult.OK);
            response.Vertices.Should().NotBeNull();
            response.Vertices.Length.Should().Be(1);
            response.Vertices[0].Length.Should().Be(2);
            response.Vertices[0][0].Length.Should().Be(3);
            response.Vertices[0][1].Length.Should().Be(3);

            response.Vertices[0][0].Should().BeEquivalentTo(new double[] { 1, 2, 0 });
            response.Vertices[0][1].Should().BeEquivalentTo(new double[] { 2, 2, 1 });

            response.Arcs.Should().BeNullOrEmpty();

            response.Labels.Length.Should().Be(2);

            response.Labels[0].Station.Should().BeApproximately(0.0, 0.001);
            response.Labels[0].X.Should().BeApproximately(1.0, 0.001);
            response.Labels[0].Y.Should().BeApproximately(2.0, 0.001);
            response.Labels[0].Rotation.Should().BeApproximately(Math.PI / 2, 0.001);

            response.Labels[1].Station.Should().BeApproximately(1.0, 0.001);
            response.Labels[1].X.Should().BeApproximately(2.0, 0.001);
            response.Labels[1].Y.Should().BeApproximately(2.0, 0.001);
            response.Labels[1].Rotation.Should().BeApproximately(Math.PI / 2, 0.001);
        }
Example #6
0
        public void Creation()
        {
            var request = new AlignmentDesignGeometryRequest();

            request.Should().NotBeNull();
        }