ITRexSpatialMemoryCacheContext[] CacheContexts) GetIntermediary(ICombinedFilter filter) { // Construct the appropriate list of surveyed surfaces // Obtain local reference to surveyed surface list. If it is replaced while processing the // list then the local reference will still be valid allowing lock free read access to the list. ISurveyedSurfaces filteredSurveyedSurfaces = null; var surveyedSurfaceList = siteModel.SurveyedSurfaces; if (includeSurveyedSurfaceInformation && surveyedSurfaceList?.Count > 0) { filteredSurveyedSurfaces = DIContext.Obtain <ISurveyedSurfaces>(); // Filter out any surveyed surfaces which don't match current filter (if any) - realistically, this is time filters we're thinking of here surveyedSurfaceList.FilterSurveyedSurfaceDetails(filter.AttributeFilter.HasTimeFilter, filter.AttributeFilter.StartTime, filter.AttributeFilter.EndTime, filter.AttributeFilter.ExcludeSurveyedSurfaces(), filteredSurveyedSurfaces, filter.AttributeFilter.SurveyedSurfaceExclusionList); // Ensure that the filtered surveyed surfaces are in a known ordered state filteredSurveyedSurfaces.SortChronologically(filter.AttributeFilter.ReturnEarliestFilteredCellPass); } var filteredSurveyedSurfacesAsArray = filteredSurveyedSurfaces?.Count > 0 ? filteredSurveyedSurfaces.Select(s => s.ID).ToArray() : new Guid[0]; // Get a caching context for the sub grids returned by this requester, but only if the requested grid data type supports it ITRexSpatialMemoryCacheContext[] subGridCacheContexts = null; if (_enableGeneralSubGridResultCaching && ClientLeafSubGrid.SupportsAssignationFromCachedPreProcessedClientSubGrid[(int)gridDataType]) { filter.AttributeFilter.SiteModel = siteModel; var contextType1 = Utilities.IntermediaryICGridDataTypeForDataType(gridDataType, true); var contextType2 = Utilities.IntermediaryICGridDataTypeForDataType(gridDataType, false); var context1 = SubGridCache?.LocateOrCreateContext(siteModel.ID, contextType1, SpatialCacheFingerprint.ConstructFingerprint(siteModel.ID, contextType1, filter, filteredSurveyedSurfacesAsArray)); var context2 = SubGridCache?.LocateOrCreateContext(siteModel.ID, contextType2, SpatialCacheFingerprint.ConstructFingerprint(siteModel.ID, contextType2, filter, filteredSurveyedSurfacesAsArray)); subGridCacheContexts = new[] { context1, context2 }.Where(x => x != null).ToArray(); } return(gridDataType, filter, filteredSurveyedSurfaces, _surfaceElevationPatchRequestFactory(SubGridCache, SubGridCache?.LocateOrCreateContext(siteModel.ID, GridDataType.SurveyedSurfaceHeightAndTime, SpatialCacheFingerprint.ConstructFingerprint(siteModel.ID, GridDataType.SurveyedSurfaceHeightAndTime, null, filteredSurveyedSurfaces?.Select(x => x.ID).ToArray() ?? new Guid[0]))), subGridCacheContexts); }
/// <summary> /// Constructor taking the full state of the surface patch computation operation /// </summary> public SurfaceElevationPatchArgument(Guid siteModelID, int oTGCellBottomLeftX, int oTGCellBottomLeftY, double cellSize, SurveyedSurfacePatchType surveyedSurfacePatchType, SubGridTreeBitmapSubGridBits processingMap, ISurveyedSurfaces includedSurveyedSurfaces) { SiteModelID = siteModelID; OTGCellBottomLeftX = oTGCellBottomLeftX; OTGCellBottomLeftY = oTGCellBottomLeftY; CellSize = cellSize; SurveyedSurfacePatchType = surveyedSurfacePatchType; ProcessingMap = processingMap == null ? new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled) : new SubGridTreeBitmapSubGridBits(processingMap); // Prepare the list of surveyed surfaces for use by all invocations using this argument includedSurveyedSurfaces?.SortChronologically(surveyedSurfacePatchType == SurveyedSurfacePatchType.LatestSingleElevation); IncludedSurveyedSurfaces = includedSurveyedSurfaces?.Select(x => x.ID).ToArray() ?? new Guid[0]; }
/// <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; }