Esempio n. 1
0
        /// <summary>
        /// Get the station range for the alignment file
        /// </summary>
        /// <param name="project"></param>
        /// <param name="alignDescriptor"></param>
        /// <param name="customHeaders"></param>
        /// <returns>The station range</returns>
        public async Task <AlignmentStationRangeResult> GetAlignmentStationRange(ProjectData project, DesignDescriptor alignDescriptor, IHeaderDictionary customHeaders)
        {
            if (alignDescriptor == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(
                                               ContractExecutionStatesEnum.FailedToGetResults,
                                               "Invalid request - Missing alignment file"));
            }

            //AlignmentStationResult result = null;
            var description = TileServiceUtils.DesignDescriptionForLogging(alignDescriptor);

            log.LogDebug($"{nameof(GetAlignmentStationRange)}: projectUid={project.ProjectUID}, projectId={project.ShortRaptorProjectId}, alignment={description}");

            //Get the station extents
#if RAPTOR
            if (UseTRexGateway("ENABLE_TREX_GATEWAY_DESIGN_BOUNDARY"))
            {
#endif
            var queryParams = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("projectUid", project.ProjectUID.ToString()),
                new KeyValuePair <string, string>("designUid", alignDescriptor.FileUid.ToString())
            }
            ;

            return(await tRexCompactionDataProxy.SendDataGetRequest <AlignmentStationRangeResult>(project.ProjectUID.ToString(), "/design/alignment/stationrange", customHeaders, queryParams));

#if RAPTOR
        }

        var alignmentDescriptor = RaptorConverters.DesignDescriptor(alignDescriptor);
        var success             = raptorClient.GetStationExtents(project.LegacyProjectId, alignmentDescriptor,
                                                                 out double startStation, out double endStation);

        if (success)
        {
            return(new AlignmentStationRangeResult(startStation, endStation));
        }
#endif

            throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(
                                           ContractExecutionStatesEnum.FailedToGetResults,
                                           $"Failed to get station range for alignment file: {alignDescriptor.File.FileName}"));
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a list of polygons representing the design surface boundary.
        /// The boundary may consist of a number of polygons.
        /// </summary>
        /// <returns>A list of latitude/longitude points in degrees</returns>
        public async Task <List <List <WGSPoint> > > GetDesignBoundaryPolygons(ProjectData project,
                                                                               DesignDescriptor designDescriptor, IHeaderDictionary customHeaders)
        {
            var polygons    = new List <List <WGSPoint> >();
            var description = TileServiceUtils.DesignDescriptionForLogging(designDescriptor);

            log.LogDebug($"{nameof(GetDesignBoundaryPolygons)}: projectUid={project.ProjectUID}, projectId={project.ShortRaptorProjectId}, design={description}");

            if (designDescriptor == null)
            {
                return(polygons);
            }

            var geoJson = await GetDesignBoundary(project, designDescriptor, customHeaders);

            log.LogDebug($"{nameof(GetDesignBoundaryPolygons)}: geoJson={geoJson}");

            if (string.IsNullOrEmpty(geoJson))
            {
                return(polygons);
            }

            var root = JsonConvert.DeserializeObject <GeoJson>(geoJson);

            foreach (var feature in root.Features)
            {
                var points = new List <WGSPoint>();

                foreach (var coordList in feature.Geometry.Coordinates)
                {
                    foreach (var coordPair in coordList)
                    {
                        points.Add(new WGSPoint(
                                       coordPair[1].LatDegreesToRadians(),
                                       coordPair[0].LonDegreesToRadians())); //GeoJSON is lng/lat
                    }
                }
                polygons.Add(points);
            }

            return(polygons);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the list of points making up the alignment boundary.
        /// If the start & end station and left & right offsets are zero,
        /// then gets the centerline of the alignment.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="alignDescriptor">Design descriptor for the alignment file</param>
        /// <param name="startStation">Start station for the alignment file boundary</param>
        /// <param name="endStation">End station for the alignment file boundary</param>
        /// <param name="leftOffset">Left offset for the alignment file boundary</param>
        /// <param name="rightOffset">Right offset for the alignment file boundary</param>
        /// <param name="customHeaders"></param>
        /// <returns>A list of latitude/longitude points in degrees</returns>
        public async Task <IEnumerable <WGSPoint> > GetAlignmentPoints(ProjectData project, DesignDescriptor alignDescriptor,
                                                                       double startStation = 0, double endStation = 0, double leftOffset = 0, double rightOffset = 0, IHeaderDictionary customHeaders = null)
        {
            var description = TileServiceUtils.DesignDescriptionForLogging(alignDescriptor);

            log.LogDebug($"{nameof(GetAlignmentPoints)}: projectUid={project.ProjectUID}, projectId={project.ShortRaptorProjectId}, alignment={description}");
            List <WGSPoint> alignmentPoints = null;

            if (alignDescriptor != null)
            {
                bool success      = true;
                bool isCenterline = startStation == 0 && endStation == 0 &&
                                    leftOffset == 0 && rightOffset == 0;
                if (isCenterline)
                {
                    try
                    {
                        var stationRange = await GetAlignmentStationRange(project, alignDescriptor, customHeaders);

                        startStation = stationRange.StartStation;
                        endStation   = stationRange.EndStation;
                    }
                    catch
                    {
                        success = false;
                    }
                }

                if (success)
                {
                    log.LogDebug($"{nameof(GetAlignmentPoints)}: projectId={project.ShortRaptorProjectId}, station range={startStation}-{endStation}");
#if RAPTOR
                    if (UseTRexGateway("ENABLE_TREX_GATEWAY_DESIGN_BOUNDARY"))
#endif
                    return(await ProcessDesignFilterBoundaryWithTRex(project.ProjectUID.ToString(), alignDescriptor, customHeaders));

#if RAPTOR
                    var alignmentDescriptor = RaptorConverters.DesignDescriptor(alignDescriptor);

                    success = raptorClient.GetDesignFilterBoundaryAsPolygon(
                        DesignProfiler.ComputeDesignFilterBoundary.RPC.__Global.Construct_CalculateDesignFilterBoundary_Args(
                            project.LegacyProjectId,
                            alignmentDescriptor,
                            startStation, endStation, leftOffset, rightOffset,
                            DesignProfiler.ComputeDesignFilterBoundary.RPC.TDesignFilterBoundaryReturnType.dfbrtList), out TWGS84Point[] pdsPoints);

                    if (success && pdsPoints != null && pdsPoints.Length > 0)
                    {
                        log.LogDebug($"{nameof(GetAlignmentPoints)} success: projectId={project.LegacyProjectId}, number of points={pdsPoints.Length}");

                        alignmentPoints = new List <WGSPoint>();
                        //For centerline, we only need half the points as normally GetDesignFilterBoundaryAsPolygon
                        //has offsets so is returning a polygon.
                        //Since we have no offsets we have the centreline twice.
                        var count = isCenterline ? pdsPoints.Length / 2 : pdsPoints.Length;
                        for (var i = 0; i < count; i++)
                        {
                            alignmentPoints.Add(new WGSPoint(pdsPoints[i].Lat, pdsPoints[i].Lon));
                        }
                    }
#endif
                }
            }
            return(alignmentPoints);
        }