public async void Add() { AddApplicationRouting(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Mutable); siteModel.SurveyedSurfaces.Count.Should().Be(0); siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Immutable); siteModel.SurveyedSurfaces.Count.Should().Be(0); var designID = Guid.NewGuid(); var existenceMap = new TRex.SubGridTrees.SubGridTreeSubGridExistenceBitMask(); existenceMap[0, 0] = true; var asAtDate = DateTime.UtcNow; var request = new AddSurveyedSurfaceRequest(); var response = await request.ExecuteAsync(new AddSurveyedSurfaceArgument { ProjectID = siteModel.ID, DesignDescriptor = new DesignDescriptor(designID, "folder", "filename"), AsAtDate = asAtDate, Extents = new TRex.Geometry.BoundingWorldExtent3D(0, 0, 1, 1), ExistenceMap = existenceMap }); response.Should().NotBeNull(); response.DesignUid.Should().Be(designID); response.RequestResult.Should().Be(DesignProfilerRequestResult.OK); // Re-request the sitemodel to reflect the change siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(siteModel.ID, false); siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Mutable); siteModel.SurveyedSurfaces.Count.Should().Be(1); siteModel.SurveyedSurfaces[0].DesignDescriptor.Should().BeEquivalentTo(new TRex.Designs.Models.DesignDescriptor(designID, "folder", "filename")); siteModel.SurveyedSurfaces[0].AsAtDate.Should().Be(asAtDate); siteModel.SetStorageRepresentationToSupply(TRex.Storage.Models.StorageMutability.Immutable); siteModel.SurveyedSurfaces.Count.Should().Be(1); siteModel.SurveyedSurfaces[0].DesignDescriptor.Should().BeEquivalentTo(new TRex.Designs.Models.DesignDescriptor(designID, "folder", "filename")); siteModel.SurveyedSurfaces[0].AsAtDate.Should().Be(asAtDate); var readExistenceMap = DIContext.Obtain <IExistenceMapServer>().GetExistenceMap(new NonSpatialAffinityKey(siteModel.ID, BaseExistenceMapRequest.CacheKeyString(TRex.ExistenceMaps.Interfaces.Consts.EXISTENCE_SURVEYED_SURFACE_DESCRIPTOR, designID))); existenceMap.Should().NotBeNull(); existenceMap.CountBits().Should().Be(readExistenceMap.CountBits()); readExistenceMap[0, 0].Should().BeTrue(); }
public async void Add_FailWithNoProject() { AddApplicationRouting(); var request = new AddSurveyedSurfaceRequest(); var response = await request.ExecuteAsync(new AddSurveyedSurfaceArgument { ProjectID = Guid.NewGuid(), DesignDescriptor = new DesignDescriptor(Guid.NewGuid(), "folder", "filename"), AsAtDate = DateTime.UtcNow, Extents = new TRex.Geometry.BoundingWorldExtent3D(0, 0, 1, 1), ExistenceMap = new TRex.SubGridTrees.SubGridTreeSubGridExistenceBitMask() }); response.Should().NotBeNull(); response.DesignUid.Should().Be(Guid.Empty); response.RequestResult.Should().Be(DesignProfilerRequestResult.FailedToAddDesign); }
public void Creation() { var req = new AddSurveyedSurfaceRequest(); req.Should().NotBeNull(); }
/// <summary> /// Add a design or surveyed surface or alignment file to TRex /// </summary> protected async Task AddDesign(DesignRequest request, string executorName) { // load core file from s3 to local var localPath = FilePathHelper.GetTempFolderForProject(request.ProjectUid); var localPathAndFileName = Path.Combine(new[] { localPath, request.FileName }); DesignBase design; if (request.FileType == ImportedFileType.Alignment) { design = new SVLAlignmentDesign(); } else { design = new TTMDesign(SubGridTreeConsts.DefaultCellSize); } var designLoadResult = design.LoadFromStorage(request.ProjectUid, request.FileName, localPath); if (designLoadResult != DesignLoadResult.Success) { log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}"); throw CreateServiceException <TExecutor> (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError, RequestErrorStatus.DesignImportUnableToRetrieveFromS3, designLoadResult.ToString()); } if (request.FileType != ImportedFileType.Alignment) { // This generates the 2 index files designLoadResult = design.LoadFromFile(localPathAndFileName); if (designLoadResult != DesignLoadResult.Success) { log.LogError($"#Out# {executorName}. Addition of design failed :{request.FileName}, Project:{request.ProjectUid}, DesignUid:{request.DesignUid}, designLoadResult: {designLoadResult}"); throw CreateServiceException <TExecutor> (HttpStatusCode.InternalServerError, ContractExecutionStatesEnum.InternalProcessingError, RequestErrorStatus.DesignImportUnableToCreateDesign, designLoadResult.ToString()); } } var extents = new BoundingWorldExtent3D(); design.GetExtents(out extents.MinX, out extents.MinY, out extents.MaxX, out extents.MaxY); design.GetHeightRange(out extents.MinZ, out extents.MaxZ); if (request.FileType == ImportedFileType.DesignSurface) { // Create the new designSurface in our site var tRexRequest = new AddTTMDesignRequest(); var designSurfaceUid = await tRexRequest.ExecuteAsync(new AddTTMDesignArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), Extents = extents, ExistenceMap = design.SubGridOverlayIndex() }); } if (request.FileType == ImportedFileType.SurveyedSurface) { // Create the new SurveyedSurface in our site model var tRexRequest = new AddSurveyedSurfaceRequest(); var surveyedSurfaceUid = await tRexRequest.ExecuteAsync(new AddSurveyedSurfaceArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), AsAtDate = request.SurveyedUtc ?? TRex.Common.Consts.MIN_DATETIME_AS_UTC, // validation will have ensured this exists Extents = extents, ExistenceMap = design.SubGridOverlayIndex() }); } if (request.FileType == ImportedFileType.Alignment) { // Create the new alignment in our site model var tRexRequest = new AddAlignmentRequest(); var alignmentUid = await tRexRequest.ExecuteAsync(new AddAlignmentArgument { ProjectID = request.ProjectUid, DesignDescriptor = new Designs.Models.DesignDescriptor(request.DesignUid, localPathAndFileName, request.FileName), Extents = extents }); } if (request.FileType != ImportedFileType.Alignment) { // TTM.LoadFromFile() will have created these 3 files. We need to store them on S3 to reload cache when required var s3FileTransfer = new S3FileTransfer(TransferProxyType.DesignImport); s3FileTransfer.WriteFile(localPath, request.ProjectUid, SubGridIndexFileName(request.FileName)); s3FileTransfer.WriteFile(localPath, request.ProjectUid, SpatialIndexFileName(request.FileName)); s3FileTransfer.WriteFile(localPath, request.ProjectUid, BoundaryFileName(request.FileName)); } }