public override void Dispose() { base.Dispose(); SurfaceElevationPatchRequest = null; TRexSpatialMemoryCacheContext = null; }
public virtual void Initialise() { // Todo: Only first filter in filter set is currently used for surface & alignment mask designs or surveyed surface restriction driven by date range var PassFilter = FilterSet.Filters[0].AttributeFilter; var CellFilter = FilterSet.Filters[0].SpatialFilter; if (CellFilter.SurfaceDesignMaskDesignUid != Guid.Empty) { SurfaceDesignMaskDesign = SiteModel.Designs.Locate(CellFilter.SurfaceDesignMaskDesignUid); if (SurfaceDesignMaskDesign == null) { throw new ArgumentException($"Design {CellFilter.SurfaceDesignMaskDesignUid} not found in project {SiteModel.ID}"); } } if (SiteModel.SurveyedSurfaces?.Count > 0) { // Filter out any surveyed surfaces which don't match current filter (if any) // - realistically, this is time filters we're thinking of here FilteredSurveyedSurfaces = DIContext.Obtain <ISurveyedSurfaces>(); SiteModel.SurveyedSurfaces?.FilterSurveyedSurfaceDetails(PassFilter.HasTimeFilter, PassFilter.StartTime, PassFilter.EndTime, PassFilter.ExcludeSurveyedSurfaces(), FilteredSurveyedSurfaces, PassFilter.SurveyedSurfaceExclusionList); if (FilteredSurveyedSurfaces?.Count == 0) { FilteredSurveyedSurfaces = null; } } // Instantiate a single instance of the argument object for the surface elevation patch requests to obtain composite // elevation sub grids and populate it with the common elements for this set of sub grids being requested. SurfaceElevationPatchArg = new SurfaceElevationPatchArgument (siteModelID: SiteModel.ID, oTGCellBottomLeftX: int.MaxValue, oTGCellBottomLeftY: int.MaxValue, cellSize: SiteModel.CellSize, includedSurveyedSurfaces: FilteredSurveyedSurfaces, surveyedSurfacePatchType: SurveyedSurfacePatchType.CompositeElevations, processingMap: new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled)); var _cache = DIContext.Obtain <ITRexSpatialMemoryCache>(); var _context = _cache?.LocateOrCreateContext(SiteModel.ID, GridDataType.SurveyedSurfaceHeightAndTime, SurfaceElevationPatchArg.CacheFingerprint()); SurfaceElevationPatchRequest = SurfaceElevationPatchRequestFactory(_cache, _context); }
public RequestorUtilitiesTestsLoggingFixture() { // Provide the surveyed surface request mock var surfaceElevationPatchRequest = new Mock <ISurfaceElevationPatchRequest>(); surfaceElevationPatchRequest.Setup(x => x.ExecuteAsync(It.IsAny <ISurfaceElevationPatchArgument>())).Returns(Task.FromResult(new ClientHeightAndTimeLeafSubGrid() as IClientLeafSubGrid)); SurfaceElevationPatchRequest = surfaceElevationPatchRequest.Object; // Provide the mocks for spatial caching var tRexSpatialMemoryCacheContext = new Mock <ITRexSpatialMemoryCacheContext>(); TRexSpatialMemoryCacheContext = tRexSpatialMemoryCacheContext.Object; var tRexSpatialMemoryCache = new Mock <ITRexSpatialMemoryCache>(); tRexSpatialMemoryCache.Setup(x => x.LocateOrCreateContext(It.IsAny <Guid>(), It.IsAny <GridDataType>(), It.IsAny <string>())).Returns(TRexSpatialMemoryCacheContext); tRexSpatialMemoryCache.Setup(x => x.LocateOrCreateContext(It.IsAny <Guid>(), It.IsAny <GridDataType>(), It.IsAny <string>(), It.IsAny <TimeSpan>())).Returns(TRexSpatialMemoryCacheContext); DIBuilder .Continue() .Add(x => x.AddSingleton(ClientLeafSubGridFactoryFactory.CreateClientSubGridFactory())) .Add(x => x.AddSingleton <ISubGridSpatialAffinityKeyFactory>(new SubGridSpatialAffinityKeyFactory())) // Register the mock factory for surface elevation requests .Add(x => x.AddSingleton <Func <ITRexSpatialMemoryCache, ITRexSpatialMemoryCacheContext, ISurfaceElevationPatchRequest> >((cache, context) => SurfaceElevationPatchRequest)) .Add(x => x.AddSingleton <ITRexSpatialMemoryCache>(tRexSpatialMemoryCache.Object)) .Add(x => x.AddTransient <ISurveyedSurfaces>(factory => new TRex.SurveyedSurfaces.SurveyedSurfaces())) .Add(x => x.AddSingleton <ISiteModels>(new TRex.SiteModels.SiteModels(TRex.Storage.Models.StorageMutability.Immutable))) .Add(x => x.AddSingleton <Func <ISubGridRequestor> >(factory => () => new SubGridRequestor())) .Add(x => x.AddSingleton <ISubGridRetrieverFactory>(new SubGridRetrieverFactory())) .Complete(); }
/// <summary> /// Constructor that accepts the common parameters around a set of sub grids the requester will be asked to process /// and initializes the requester state ready to start processing individual sub grid requests. /// </summary> public void Initialize(ISubGridsRequestArgument subGridsRequestArgument, ISiteModel siteModel, GridDataType gridDataType, IStorageProxy storageProxy, ICombinedFilter filter, bool hasOverrideSpatialCellRestriction, BoundingIntegerExtent2D overrideSpatialCellRestriction, int maxNumberOfPassesToReturn, AreaControlSet areaControlSet, IFilteredValuePopulationControl populationControl, ISubGridTreeBitMask pdExistenceMap, ITRexSpatialMemoryCache subGridCache, ITRexSpatialMemoryCacheContext[] subGridCacheContexts, ISurveyedSurfaces filteredSurveyedSurfaces, ISurfaceElevationPatchRequest surfaceElevationPatchRequest, IOverrideParameters overrides, ILiftParameters liftParams) { _siteModel = siteModel; _gridDataType = gridDataType; _filter = filter; _hasOverrideSpatialCellRestriction = hasOverrideSpatialCellRestriction; _overrideSpatialCellRestriction = overrideSpatialCellRestriction; _retriever = DIContext.Obtain <ISubGridRetrieverFactory>().Instance(subGridsRequestArgument, siteModel, gridDataType, storageProxy, filter, _filterAnnex, hasOverrideSpatialCellRestriction, overrideSpatialCellRestriction, maxNumberOfPassesToReturn, areaControlSet, populationControl, pdExistenceMap, subGridCacheContexts, overrides, liftParams); _returnEarliestFilteredCellPass = _filter.AttributeFilter.ReturnEarliestFilteredCellPass; _processingMap = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); _surfaceElevationPatchRequest = surfaceElevationPatchRequest; _subGridCache = subGridCache; _subGridCacheContexts = subGridCacheContexts; _surveyedSurfacePatchType = _filter.AttributeFilter.ReturnEarliestFilteredCellPass ? SurveyedSurfacePatchType.EarliestSingleElevation : SurveyedSurfacePatchType.LatestSingleElevation; _filteredSurveyedSurfaces = filteredSurveyedSurfaces; _filteredSurveyedSurfaces?.SortChronologically(_surveyedSurfacePatchType == SurveyedSurfacePatchType.LatestSingleElevation); _filteredSurveyedSurfacesAsGuidArray = _filteredSurveyedSurfaces?.Select(x => x.ID).ToArray() ?? new Guid[0]; var elevRangeDesignFilter = _filter.AttributeFilter.ElevationRangeDesign; if (elevRangeDesignFilter.DesignID != Guid.Empty) { var design = _siteModel.Designs.Locate(elevRangeDesignFilter.DesignID); if (design == null) { _log.LogError($"ElevationRangeDesign {elevRangeDesignFilter.DesignID} is unknown in project {siteModel.ID}"); } else { _elevationRangeDesign = new DesignWrapper(elevRangeDesignFilter, design); } } if (_filter.SpatialFilter.IsDesignMask) { _surfaceDesignMaskDesign = _siteModel.Designs.Locate(_filter.SpatialFilter.SurfaceDesignMaskDesignUid); } _filter.AttributeFilter.SiteModel = _siteModel; }