protected override async Task <ContractExecutionResult> ProcessAsyncEx <T>(T item) { var request = item as DesignBoundariesRequest; if (request == null) { ThrowRequestTypeCastException <DesignBoundariesRequest>(); } var siteModel = GetSiteModel(request.ProjectUid); var csib = siteModel.CSIB(); if (csib == string.Empty) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults, $"The project does not have Coordinate System definition data. Project UID: {siteModel.ID}")); } var referenceDesign = new DesignOffset(request.DesignUid, request.Tolerance); var designBoundaryRequest = new DesignBoundaryRequest(); var designBoundaryResponse = await designBoundaryRequest.ExecuteAsync(new DesignBoundaryArgument { ProjectID = siteModel.ID, ReferenceDesign = referenceDesign }); if (designBoundaryResponse != null && designBoundaryResponse.RequestResult == DesignProfilerRequestResult.OK && designBoundaryResponse.Boundary != null) { return(await DesignBoundaryHelper.ConvertBoundary(designBoundaryResponse.Boundary, request.Tolerance, siteModel.CellSize, csib, request.FileName)); } throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.FailedToGetResults, $"Failed to get requested Design Boundary data. Project UID: {siteModel.ID}, Design UID: {request.DesignUid}")); }
public async Task DesignBoundariesExecutor_ConvertBoundary() { const int DECIMALS = 6; const double TOLERANCE = 0.0; const string FILE_NAME = "Test.ttm"; const string DIMENSIONS_2012_DC_CSIB = "QM0G000ZHC4000000000800BY7SN2W0EYST640036P3P1SV09C1G61CZZKJC976CNB295K7W7G30DA30A1N74ZJH1831E5V0CHJ60W295GMWT3E95154T3A85H5CRK9D94PJM1P9Q6R30E1C1E4Q173W9XDE923XGGHN8JR37B6RESPQ3ZHWW6YV5PFDGCTZYPWDSJEFE1G2THV3VAZVN28ECXY7ZNBYANFEG452TZZ3X2Q1GCYM8EWCRVGKWD5KANKTXA1MV0YWKRBKBAZYVXXJRM70WKCN2X1CX96TVXKFRW92YJBT5ZCFSVM37ZD5HKVFYYYMJVS05KA6TXFY6ZE4H6NQX8J3VAX79TTF82VPSV1KVR8W9V7BM1N3MEY5QHACSFNCK7VWPNY52RXGC1G9BPBS1QWA7ZVM6T2E0WMDY7P6CXJ68RB4CHJCDSVR6000047S29YVT08000"; var boundary = new List <Fence>() { new Fence() }; boundary[0].Points.Add(new FencePoint(2700.20170260547, 1225.08445683629, 0.0)); boundary[0].Points.Add(new FencePoint(2700.16517351542, 1224.38744027628, 0.0)); boundary[0].Points.Add(new FencePoint(2700.10136538994, 1223.16990871245, 0.0)); boundary[0].Points.Add(new FencePoint(2889.7599542129, 1178.36648123432, 0.0)); boundary[0].Points.Add(new FencePoint(2889.75893340242, 1178.41010195536, 0.0)); boundary[0].Points.Add(new FencePoint(2705.18796425658, 1224.6913839156, 0.0)); boundary[0].Points.Add(new FencePoint(2700.20170260547, 1225.08445683629, 0.0)); // Mocked ConvertCoordinates expected result. var llhCoords = new XYZ[boundary[0].Points.Count]; llhCoords[0].X = Math.Round(-115.02063908350371, DECIMALS); llhCoords[0].Y = Math.Round(36.20750448242144, DECIMALS); llhCoords[1].X = Math.Round(-115.02063948986357, DECIMALS); llhCoords[1].Y = Math.Round(36.20749820152535, DECIMALS); llhCoords[2].X = Math.Round(-115.02064019968294, DECIMALS); llhCoords[2].Y = Math.Round(36.20748723020888, DECIMALS); llhCoords[3].X = Math.Round(-115.01853140279106, DECIMALS); llhCoords[3].Y = Math.Round(36.2070834400289, DECIMALS); llhCoords[4].X = Math.Round(-115.0185314141189, DECIMALS); llhCoords[4].Y = Math.Round(36.20708383310118, DECIMALS); llhCoords[5].X = Math.Round(-115.02058364119604, DECIMALS); llhCoords[5].Y = Math.Round(36.20750093926768, DECIMALS); llhCoords[6].X = Math.Round(-115.02063908350371, DECIMALS); llhCoords[6].Y = Math.Round(36.20750448242144, DECIMALS); var convertCoordinatesMock = new Mock <ICoreXWrapper>(); var expectedCoordinateConversionResult = llhCoords.ToCoreX_XYZ(); convertCoordinatesMock.Setup(x => x.NEEToLLH(It.IsAny <string>(), It.IsAny <CoreXModels.XYZ[]>(), It.IsAny <CoreX.Types.ReturnAs>())).Returns(expectedCoordinateConversionResult); DIBuilder.Continue().Add(x => x.AddSingleton(convertCoordinatesMock.Object)).Complete(); var designBoundaryResult = await DesignBoundaryHelper.ConvertBoundary(boundary, TOLERANCE, TestConsts.CELL_SIZE, DIMENSIONS_2012_DC_CSIB, FILE_NAME); designBoundaryResult.Should().NotBeNull(); designBoundaryResult.GeoJSON.Should().NotBeNull(); designBoundaryResult.GeoJSON.Features.Count.Should().Be(1); designBoundaryResult.GeoJSON.Features[0].Geometry.Coordinates.Count.Should().Be(1); designBoundaryResult.GeoJSON.Features[0].Geometry.Coordinates[0].Count.Should().Be(llhCoords.Length); for (var i = 0; i < llhCoords.Length; i++) { var coordinate = designBoundaryResult.GeoJSON.Features[0].Geometry.Coordinates[0][i]; coordinate[0].Should().Be(llhCoords[i].X); coordinate[1].Should().Be(llhCoords[i].Y); } designBoundaryResult.GeoJSON.Features[0].Properties.Name.Should().Be(FILE_NAME); }