public async Task Test_AlignmentDesignFilterBoundaryRequest() { const double START_STATION = 0.0; const double END_STATION = 100.0; const double LEFT_OFFSET = 1.0; const double RIGHT_OFFSET = 2.0; AddDesignProfilerGridRouting(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var designUid = DITAGFileAndSubGridRequestsWithIgniteFixture.AddSVLAlignmentDesignToSiteModel(ref siteModel, TestHelper.CommonTestDataPath, "Large Sites Road - Trimble Road.svl"); var referenceDesign = new DesignOffset(designUid, 0); var request = new AlignmentDesignFilterBoundaryRequest(); var response = await request.ExecuteAsync(new AlignmentDesignFilterBoundaryArgument { ProjectID = siteModel.ID, ReferenceDesign = referenceDesign, Filters = new FilterSet(new CombinedFilter()), TRexNodeID = Guid.NewGuid(), StartStation = START_STATION, EndStation = END_STATION, LeftOffset = LEFT_OFFSET, RightOffset = RIGHT_OFFSET }); // TODO To complete this test later once an alignment filter boundary implementation becomes available on a .Net standard version of the Symphony SDK response.RequestResult.Should().Be(DesignProfilerRequestResult.OK); }
protected override async Task<ContractExecutionResult> ProcessAsyncEx<T>(T item) { var request = item as DesignFilterBoundaryRequest; if (request == null) ThrowRequestTypeCastException<DesignFilterBoundaryRequest>(); var siteModel = GetSiteModel(request.ProjectUid); var designFilterBoundaryRequest = new AlignmentDesignFilterBoundaryRequest(); var referenceDesign = new DesignOffset(request.DesignUid, 0.0); var designFilterBoundaryResponse = await designFilterBoundaryRequest.ExecuteAsync(new AlignmentDesignFilterBoundaryArgument() { ProjectID = siteModel.ID, ReferenceDesign = referenceDesign, StartStation = request.StartStation, EndStation = request.EndStation, LeftOffset = request.LeftOffset, RightOffset = request.RightOffset }); if (designFilterBoundaryResponse != null && designFilterBoundaryResponse.RequestResult != DesignProfilerRequestResult.OK && designFilterBoundaryResponse.Boundary != null) return ConvertResult(designFilterBoundaryResponse.Boundary); throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults, "Failed to get requested Design Filter Boundary data")); }
public void Test_AlignmentDesignFilterBoundaryResponse_Polygon() { var response = new AlignmentDesignFilterBoundaryRequest { }; SimpleBinarizableInstanceTester.TestClass(response, "Custom AlignmentDesignFilterBoundaryRequest not same after round trip serialisation"); }
/* * private IExistenceMaps existenceMaps = null; * private IExistenceMaps GetExistenceMaps() => existenceMaps ??= DIContext.Obtain<IExistenceMaps>()); */ /// <summary> /// Prepare a filter for use by performing any necessary coordinate conversions and requesting any /// supplemental information such as alignment design boundary calculations. /// </summary> public static RequestErrorStatus PrepareFilterForUse(ICombinedFilter filter, Guid dataModelId) { // Fence DesignBoundary = null; var result = RequestErrorStatus.OK; if (filter == null) { return(result); } if (filter.SpatialFilter != null) { if (!filter.SpatialFilter.CoordsAreGrid) { var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(dataModelId); XYZ[] llhCoords; // If the filter has a spatial or positional context, then convert the LLH values in the // spatial context into the NEE values consistent with the data model. if (filter.SpatialFilter.IsSpatial) { llhCoords = new XYZ[filter.SpatialFilter.Fence.NumVertices]; // Note: Lat/Lons in filter fence boundaries are supplied to us in decimal degrees, not radians for (var fencePointIdx = 0; fencePointIdx < filter.SpatialFilter.Fence.NumVertices; fencePointIdx++) { llhCoords[fencePointIdx] = new XYZ(MathUtilities.DegreesToRadians(filter.SpatialFilter.Fence[fencePointIdx].X), MathUtilities.DegreesToRadians(filter.SpatialFilter.Fence[fencePointIdx].Y), 0); } XYZ[] neeCoords; try { neeCoords = DIContext .Obtain <ICoreXWrapper>() .LLHToNEE(siteModel.CSIB(), llhCoords.ToCoreX_XYZ(), InputAs.Radians) .ToTRex_XYZ(); } catch (Exception e) { return(RequestErrorStatus.FailedToConvertClientWGSCoords); } for (var fencePointIdx = 0; fencePointIdx < filter.SpatialFilter.Fence.NumVertices; fencePointIdx++) { filter.SpatialFilter.Fence[fencePointIdx].X = neeCoords[fencePointIdx].X; filter.SpatialFilter.Fence[fencePointIdx].Y = neeCoords[fencePointIdx].Y; } // Ensure that the bounding rectangle for the filter fence correctly encloses the newly calculated grid coordinates filter.SpatialFilter.Fence.UpdateExtents(); } if (filter.SpatialFilter.IsPositional) { // Note: Lat/Lons in positions are supplied to us in decimal degrees, not radians llhCoords = new[] { new XYZ(MathUtilities.DegreesToRadians(filter.SpatialFilter.PositionX), MathUtilities.DegreesToRadians(filter.SpatialFilter.PositionY), 0) }; XYZ[] neeCoords; try { neeCoords = DIContext .Obtain <ICoreXWrapper>() .LLHToNEE(siteModel.CSIB(), llhCoords.ToCoreX_XYZ(), InputAs.Radians) .ToTRex_XYZ(); } catch { return(RequestErrorStatus.FailedToConvertClientWGSCoords); } filter.SpatialFilter.PositionX = neeCoords[0].X; filter.SpatialFilter.PositionY = neeCoords[0].Y; } filter.SpatialFilter.CoordsAreGrid = true; } // Ensure that the bounding rectangle for the filter fence correctly encloses the newly calculated grid coordinates filter.SpatialFilter?.Fence.UpdateExtents(); // Is there an alignment file to look up? If so, only do it if there not an already existing alignment fence boundary if (filter.SpatialFilter.HasAlignmentDesignMask() && !(filter.SpatialFilter.AlignmentFence?.HasVertices ?? true)) { var boundaryRequest = new AlignmentDesignFilterBoundaryRequest(); var boundaryResult = boundaryRequest.Execute (new AlignmentDesignFilterBoundaryArgument { ProjectID = dataModelId, ReferenceDesign = new DesignOffset(filter.SpatialFilter.AlignmentDesignMaskDesignUID, 0), StartStation = filter.SpatialFilter.StartStation ?? Common.Consts.NullDouble, EndStation = filter.SpatialFilter.EndStation ?? Common.Consts.NullDouble, LeftOffset = filter.SpatialFilter.LeftOffset ?? Common.Consts.NullDouble, RightOffset = filter.SpatialFilter.RightOffset ?? Common.Consts.NullDouble, Filters = new FilterSet(new CombinedFilter()) }); if (boundaryResult.RequestResult != DesignProfilerRequestResult.OK) { _log.LogError($"{nameof(PrepareFilterForUse)}: Failed to get boundary for alignment design ID:{filter.SpatialFilter.AlignmentDesignMaskDesignUID}"); return(RequestErrorStatus.NoResultReturned); } filter.SpatialFilter.AlignmentFence = boundaryResult.Boundary; } // Is there a surface design to look up if (filter.SpatialFilter.HasSurfaceDesignMask()) { // Todo: Not yet supported (or demonstrated that it's needed as this should be taken care of in the larger scale determination of the sub grids that need to be queried). /* If the filter needs to retain a reference to the existence map, then do this... * Filter.SpatialFilter.DesignMaskExistenceMap = GetExistenceMaps().GetSingleExistenceMap(ProjectUid, EXISTENCE_MAP_DESIGN_DESCRIPTOR, Filter.SpatialFilter.SurfaceDesignMaskDesignUid); * * if (Filter.SpatialFilter.DesignMaskExistenceMap == null) * { * Log.LogError($"PrepareFilterForUse: Failed to get existence map for surface design ID:{Filter.SpatialFilter.SurfaceDesignMaskDesignUid}"); * } */ } } return(result); }
public void Test_AlignmentDesignFilterBoundaryRequest_Creation() { var request = new AlignmentDesignFilterBoundaryRequest(); request.Should().NotBeNull(); }