Beispiel #1
0
        private async Task <CompactionProfileResult <CompactionProfileVertex> > MockGetProfile(DesignProfile designProfile)
        {
            var raptorClient = new Mock <IASNodeClient>();
            var configStore  = new Mock <IConfigurationStore>();

            var ms = new MemoryStream();
            //No serialization so do it by hand
            BinaryWriter writer = new BinaryWriter(ms);

            writer.Write(BitConverter.GetBytes(designProfile.vertices.Count));
            foreach (var vertex in designProfile.vertices)
            {
                writer.Write(BitConverter.GetBytes(vertex.station));
                writer.Write(BitConverter.GetBytes(vertex.elevation));
            }
            writer.Write(BitConverter.GetBytes(designProfile.GridDistanceBetweenProfilePoints));
            ms.Position = 0;
            raptorClient
            .Setup(x => x.GetDesignProfile(It.IsAny <TDesignProfilerServiceRPCVerb_CalculateDesignProfile_Args>()))
            .Returns(ms);

            var request = new CompactionProfileDesignRequest(
                1234, null, null, null, -1, null, new ProfileGridPoints(), new ProfileLLPoints(), ValidationConstants3D.MIN_STATION, ValidationConstants3D.MIN_STATION);

            var executor = RequestExecutorContainerFactory
                           .Build <CompactionDesignProfileExecutor>(logger, raptorClient.Object, configStore: configStore.Object);
            var result = await executor.ProcessAsync(request) as CompactionProfileResult <CompactionProfileVertex>;

            return(result);
        }
Beispiel #2
0
        public void Should_return_empty_result_When_no_result_returned_from_Raptor()
        {
            var raptorClient = new Mock <IASNodeClient>();
            var configStore  = new Mock <IConfigurationStore>();

            raptorClient
            .Setup(x => x.GetDesignProfile(It.IsAny <TDesignProfilerServiceRPCVerb_CalculateDesignProfile_Args>()))
            .Returns((MemoryStream)null);

            var request = new CompactionProfileDesignRequest(
                1234, null, null, null, -1, null, new ProfileGridPoints(), new ProfileLLPoints(), ValidationConstants3D.MIN_STATION, ValidationConstants3D.MIN_STATION);

            var executor = RequestExecutorContainerFactory
                           .Build <CompactionDesignProfileExecutor>(logger, raptorClient.Object, configStore: configStore.Object);
            var result = executor.ProcessAsync(request).Result as CompactionProfileResult <CompactionProfileVertex>;

            Assert.IsNotNull(result, ExecutorFailed);
            Assert.AreEqual(0, result.gridDistanceBetweenProfilePoints, WrongGridDistanceBetweenProfilePoints);
            Assert.AreEqual(0, result.results.Count, ResultsShouldBeEmpty);
        }
Beispiel #3
0
        private CompactionProfileResult <CompactionProfileVertex> PerformProductionDataProfilePost(CompactionProfileDesignRequest request)
        {
            CompactionProfileResult <CompactionProfileVertex> result;

            try
            {
                ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out TWGS84Point startPt, out TWGS84Point endPt, out bool positionsAreGrid);

                var designProfile = DesignProfiler.ComputeProfile.RPC.__Global.Construct_CalculateDesignProfile_Args(
                    request.ProjectId ?? VelociraptorConstants.NO_PROJECT_ID,
                    false,
                    startPt,
                    endPt,
                    ValidationConstants3D.MIN_STATION,
                    ValidationConstants3D.MAX_STATION,
                    RaptorConverters.DesignDescriptor(request.DesignDescriptor),
                    RaptorConverters.EmptyDesignDescriptor,
                    RaptorConverters.ConvertFilter(request.Filter, request.ProjectId, raptorClient),
                    positionsAreGrid);

                var memoryStream = raptorClient.GetDesignProfile(designProfile);

                if (memoryStream != null)
                {
                    result = ConvertProfileResult(memoryStream);
                    memoryStream.Close();
                }
                else
                {
                    //For convenience return empty list rather than null for easier manipulation
                    result = new CompactionProfileResult <CompactionProfileVertex> {
                        results = new List <CompactionProfileVertex>()
                    };
                }
            }
            finally
            {
                ContractExecutionStates.ClearDynamic();
            }

            return(result);
        }
Beispiel #4
0
        private async Task <CompactionProfileResult <CompactionProfileVertex> > PerformProductionDataProfilePostWithTRexGateway(CompactionProfileDesignRequest request)
        {
            ProfilesHelper.ConvertProfileEndPositions(request.GridPoints, request.WGS84Points, out WGSPoint startPt, out var endPt, out bool positionsAreGrid);

            var designProfileRequest = new DesignProfileRequest(request.ProjectUid ?? Guid.Empty, request.DesignDescriptor?.FileUid ?? Guid.Empty, request.DesignDescriptor?.Offset ?? 0, startPt.Lon, startPt.Lat, endPt.Lon, endPt.Lat, positionsAreGrid);

            var trexResult = await trexCompactionDataProxy.SendDataPostRequest <DesignProfileResult, DesignProfileRequest>(designProfileRequest, "/profile/design", customHeaders);

            return(trexResult?.Code == ContractExecutionStatesEnum.ExecutedSuccessfully ? ConvertTRexProfileResult(trexResult) : null);
        }