Ejemplo n.º 1
0
        public async Task <PointsListResult> GetFilterPointsList(
            [FromServices] ISummaryDataHelper summaryDataHelper,
            [FromQuery] Guid projectUid,
            [FromQuery] Guid?filterUid,
            [FromQuery] Guid?baseUid,
            [FromQuery] Guid?topUid,
            [FromQuery] FilterBoundaryType boundaryType,
            [FromServices] IBoundingBoxService boundingBoxService)
        {
            Log.LogInformation($"{nameof(GetFilterPointsList)}: " + Request.QueryString);

            var projectTask = ((RaptorPrincipal)User).GetProject(projectUid);
            var filterTask  = GetCompactionFilter(projectUid, filterUid);
            //Base or top may be a design UID
            var baseFilterTask = summaryDataHelper.WithSwallowExceptionExecute(() => GetCompactionFilter(projectUid, baseUid));
            var topFilterTask  = summaryDataHelper.WithSwallowExceptionExecute(() => GetCompactionFilter(projectUid, topUid));

            var result = new PointsListResult();

            await Task.WhenAll(projectTask, filterTask, baseFilterTask, topFilterTask);

            var polygons = await boundingBoxService.GetFilterBoundaries(projectTask.Result, filterTask.Result, baseFilterTask.Result, topFilterTask.Result, boundaryType, CustomHeaders);

            result.PointsList = ConvertPoints(polygons);

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get a list of boundaries or polygons used by the filter.
        /// For design boundaries there may be multiple polygons per design.
        /// For custom boundaries and alignments there is at most one.
        /// </summary>
        /// <param name="project">The project for the report</param>
        /// <param name="filter">The filter to get boundaries for</param>
        /// <param name="boundaryType">Type of boundary to get: custom polygon or design boundaries or both</param>
        /// <param name="customHeaders"></param>
        /// <returns>A list of boundaries (polygons). Points are latitude/longitude in degrees.</returns>
        public async Task <List <List <WGSPoint> > > GetFilterBoundaries(ProjectData project, FilterResult filter,
                                                                         FilterBoundaryType boundaryType, IHeaderDictionary customHeaders)
        {
            var boundaries = new List <List <WGSPoint> >();

            if (filter != null)
            {
                if (boundaryType == FilterBoundaryType.Alignment || boundaryType == FilterBoundaryType.All)
                {
                    if (filter.AlignmentFile != null)
                    {
                        log.LogDebug($"{nameof(GetFilterBoundaries)}: adding design boundary polygons for projectId={project.ShortRaptorProjectId}, filter name={filter.Name}");

                        boundaries.Add((await GetAlignmentPoints(project, filter.AlignmentFile,
                                                                 filter.StartStation ?? 0, filter.EndStation ?? 0, filter.LeftOffset ?? 0, filter.RightOffset ?? 0, customHeaders)).ToList());
                    }
                }
                if (boundaryType == FilterBoundaryType.Design || boundaryType == FilterBoundaryType.All)
                {
                    if (filter.DesignFile != null)
                    {
                        log.LogDebug($"{nameof(GetFilterBoundaries)}: adding design boundary polygons for projectId={project.ShortRaptorProjectId}, filter name={filter.Name}");
                        boundaries.AddRange(await GetDesignBoundaryPolygons(project, filter.DesignFile, customHeaders));
                    }
                }
                if (boundaryType == FilterBoundaryType.Polygon || boundaryType == FilterBoundaryType.All)
                {
                    if (filter.PolygonLL != null && filter.PolygonLL.Count > 0)
                    {
                        log.LogDebug($"{nameof(GetFilterBoundaries)}s: adding custom polygon for projectId={project.ShortRaptorProjectId}, filter name={filter.Name}");
                        boundaries.Add(filter.PolygonLL);
                    }
                }
            }
            return(boundaries);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the boundary points for the requested filters for a project if they have a spatial filter
        /// </summary>
        public async Task <PointsListResult> GetFilterPointsList(Guid projectUid, Guid?filterUid, Guid?baseUid, Guid?topUid, FilterBoundaryType boundaryType, IHeaderDictionary customHeaders = null)
        {
            log.LogDebug($"{nameof(GetFilterPointsList)} projectUid={projectUid}, filterUid={filterUid}, baseUid={baseUid}, topUid={topUid}, boundaryType={boundaryType}");

            var queryParams = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("projectUid", projectUid.ToString()),
                new KeyValuePair <string, string>("filterUid", filterUid.ToString()),
                new KeyValuePair <string, string>("baseUid", baseUid.ToString()),
                new KeyValuePair <string, string>("topUid", topUid.ToString()),
                new KeyValuePair <string, string>("boundaryType", boundaryType.ToString())
            };
            var result = await GetMasterDataItemServiceDiscoveryNoCache <PointsListResult>
                             ("/raptor/filterpointslist", customHeaders, queryParameters : queryParams);

            if (result != null)
            {
                return(result);
            }

            log.LogDebug($"{nameof(GetFilterPointsList)} Failed to get streamed results");
            return(null);
        }
Ejemplo n.º 4
0
        public PointsListResult GetMockFilterPointsList(
            [FromQuery] Guid projectUid,
            [FromQuery] Guid?filterUid,
            [FromQuery] Guid?baseUid,
            [FromQuery] Guid?topUid,
            [FromQuery] FilterBoundaryType boundaryType)
        {
            Logger.LogInformation($"GetMockFilterPointsList: {Request.QueryString}");

            if (projectUid.ToString() == "ff91dd40-1569-4765-a2bc-014321f76ace")
            {
                if (baseUid.ToString() == "f07ed071-f8a1-42c3-804a-1bde7a78be5b" && topUid.ToString() == "a40814aa-9cdb-4981-9a21-96ea30ffecdd")//GroundToGround
                {
                    //SummaryVolumesBaseFilter and SummaryVolumesTopFilter
                    return(new PointsListResult
                    {
                        PointsList = new List <List <WGSPoint> >
                        {
                            new List <WGSPoint>
                            {
                                new WGSPoint(0.63192486410214576686, -2.0075397823134681907),
                                new WGSPoint(0.63192486410214576686, -2.0075399142735710356),
                                new WGSPoint(0.63192459673603029735, -2.0075399142735710356),
                                new WGSPoint(0.63192459673603029735, -2.0075397823134681907)
                            }
                        }
                    });
                }

                if (baseUid.ToString() == "dd64fe2e-6f27-4a78-82a3-0c0e8a5e84ff" && topUid.ToString() == "a54e5945-1aaa-4921-9cc1-c9d8c0a343d3")//DesignToGround
                {
                    //SummaryVolumesFilterToday
                    return(new PointsListResult
                    {
                        PointsList = new List <List <WGSPoint> >
                        {
                            new List <WGSPoint>
                            {
                                new WGSPoint(0.631933421757, -2.00745117663),
                                new WGSPoint(0.631937191668, -2.007449675651),
                                new WGSPoint(0.631939949288, -2.007470794135),
                                new WGSPoint(0.631933125051, -2.00746859502)
                            }
                        }
                    });
                }
                if (baseUid.ToString() == "9c27697f-ea6d-478a-a168-ed20d6cd9a22" && topUid.ToString() == "dd64fe2e-6f27-4a78-82a3-0c0e8a5e84ff")//GroundToDesign
                {
                    //SummaryVolumesFilterProjectExtentsEarliest
                    return(new PointsListResult
                    {
                        PointsList = new List <List <WGSPoint> >
                        {
                            new List <WGSPoint>
                            {
                                new WGSPoint(0.631933421757, -2.00745117663),
                                new WGSPoint(0.631937191668, -2.007449675651),
                                new WGSPoint(0.631939949288, -2.007470794135),
                                new WGSPoint(0.631933125051, -2.00746859502)
                            }
                        }
                    });
                }
                if (filterUid.ToString() == "2811c7c3-d270-4d63-97e2-fc3340bf6c6b")//'Large Sites Road' alignment
                {
                    return(new PointsListResult
                    {
                        PointsList = new List <List <WGSPoint> >
                        {
                            new List <WGSPoint>
                            {
                                /*
                                 * new WGSPoint(0.631933977148023, -2.00748895357148),
                                 * new WGSPoint(0.631933977148023, -2.00745211260671),
                                 * new WGSPoint(0.631938717124322, -2.00748895357148),
                                 * new WGSPoint(0.631938717124322, -2.00745211260671)
                                 */
                                new WGSPoint(0.631933977148023, -2.00748895357148),
                                new WGSPoint(0.631938717124322, -2.00745211260671)
                            }
                        }
                    });
                }
            }

            return(new PointsListResult());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get a list of all boundaries or polygons used by the filters.
        /// For design boundaries there may be multiple polygons per design.
        /// For custom boundaries and alignments there is at most one.
        /// </summary>
        /// <param name="project">The project for the report</param>
        /// <param name="filter">The filter for production data tiles</param>
        /// <param name="baseFilter">The base filter for summary volumes</param>
        /// <param name="topFilter">The top filter for summary volumes</param>
        /// <param name="boundaryType">Type of boundary to get: custom polygon or design boundaries or both</param>
        /// <param name="customHeaders"></param>
        /// <returns>A list of boundaries (polygons). Points are latitude/longitude in degrees.</returns>
        public async Task <List <List <WGSPoint> > > GetFilterBoundaries(ProjectData project, FilterResult filter,
                                                                         FilterResult baseFilter, FilterResult topFilter, FilterBoundaryType boundaryType,
                                                                         IHeaderDictionary customHeaders)
        {
            var boundariesTask         = GetFilterBoundaries(project, filter, boundaryType, customHeaders);
            var baseFilterBoundaryTask = GetFilterBoundaries(project, baseFilter, boundaryType, customHeaders);
            var topFilterBoundaryTask  = GetFilterBoundaries(project, topFilter, boundaryType, customHeaders);

            await Task.WhenAll(boundariesTask, baseFilterBoundaryTask, topFilterBoundaryTask);

            var boundaries = boundariesTask.Result;

            boundaries.AddRange(baseFilterBoundaryTask.Result);
            boundaries.AddRange(topFilterBoundaryTask.Result);

            return(boundaries);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets a map tile with spatial filter boundaries drawn on it
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="filterPolygons">List of filter polygons</param>
        /// <param name="boundaryType">Type of filter boundary which determines the color</param>
        /// <returns>A bitmap</returns>
        public byte[] GetFilterBoundaryBitmap(MapParameters parameters, List <List <WGSPoint> > filterPolygons, FilterBoundaryType boundaryType)
        {
            byte[] geofenceImage = null;

            if (filterPolygons != null && filterPolygons.Any())
            {
                using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
                {
                    foreach (var polygonPoints in filterPolygons)
                    {
                        if (polygonPoints != null && polygonPoints.Any())
                        {
                            int color = 0;
                            switch (boundaryType)
                            {
                            case FilterBoundaryType.Alignment:
                                color = DEFAULT_ALIGNMENT_BOUNDARY_COLOR;
                                break;

                            case FilterBoundaryType.Design:
                                color = DEFAULT_DESIGN_BOUNDARY_COLOR;
                                break;

                            default:
                                color = DEFAULT_CUSTOM_BOUNDARY_COLOR;
                                break;
                            }
                            DrawGeofence(parameters, bitmap, $"{boundaryType} Filter Boundary", polygonPoints, color, true);
                        }
                    }
                    geofenceImage = bitmap.BitmapToByteArray();
                }
            }
            return(geofenceImage);
        }