public async Task <IClientLeafSubGrid> ExecuteAsync(ISurfaceElevationPatchArgument arg) => Execute(arg); // Task.Run(() => Execute(arg)); public IClientLeafSubGrid Execute(ISurfaceElevationPatchArgument arg) { if (arg.SurveyedSurfacePatchType > SurveyedSurfacePatchType.CompositeElevations) { return(null); } var cachingSupported = arg.SurveyedSurfacePatchType != SurveyedSurfacePatchType.CompositeElevations && _cache != null; // Check the item is available in the cache if (cachingSupported && _cache?.Get(arg.OTGCellBottomLeftX, arg.OTGCellBottomLeftY) is IClientLeafSubGrid cacheResult) { return(_cache.ExtractFromCachedItem(cacheResult, arg.ProcessingMap, arg.SurveyedSurfacePatchType)); } SubGridTreeBitmapSubGridBits savedMap = null; // Always request the full sub grid from the surveyed surface engine unless composite elevations are requested if (cachingSupported) { savedMap = arg.ProcessingMap; arg.ProcessingMap = SubGridTreeBitmapSubGridBits.FullMask; } var subGridInvalidationVersion = cachingSupported ? _cache.InvalidationVersion : 0; var executor = new CalculateSurfaceElevationPatch(); _sitemodel ??= DIContext.ObtainRequired <ISiteModels>().GetSiteModel(arg.SiteModelID); _designFiles ??= DIContext.ObtainRequired <IDesignFiles>(); _surveyedSurfaces ??= _sitemodel.SurveyedSurfaces; var clientResult = executor.Execute(_sitemodel, arg.OTGCellBottomLeftX, arg.OTGCellBottomLeftY, arg.CellSize, arg.SurveyedSurfacePatchType, arg.IncludedSurveyedSurfaces, _designFiles, _surveyedSurfaces, arg.ProcessingMap); if (clientResult != null) { // For now, only cache non-composite elevation sub grids if (cachingSupported) { _cache?.Add(clientResult, subGridInvalidationVersion); } if (savedMap != null) { clientResult = _cache.ExtractFromCachedItem(clientResult, savedMap, arg.SurveyedSurfacePatchType); } } return(clientResult); }
public override IClientLeafSubGrid Execute(ISurfaceElevationPatchArgument arg) { var cachingSupported = arg.SurveyedSurfacePatchType != SurveyedSurfacePatchType.CompositeElevations && _cache != null; // Check the item is available in the cache if (cachingSupported && _cache?.Get(arg.OTGCellBottomLeftX, arg.OTGCellBottomLeftY) is IClientLeafSubGrid cacheResult) { return(_cache.ExtractFromCachedItem(cacheResult, arg.ProcessingMap, arg.SurveyedSurfacePatchType)); } SubGridTreeBitmapSubGridBits savedMap = null; // Always request the full sub grid from the surveyed surface engine unless composite elevations are requested if (cachingSupported) { savedMap = arg.ProcessingMap; arg.ProcessingMap = SubGridTreeBitmapSubGridBits.FullMask; } var subGridInvalidationVersion = cachingSupported ? _cache.InvalidationVersion : 0; IClientLeafSubGrid clientResult = null; var result = Compute.Apply(_computeFunc, arg); if (result?.Bytes != null) { clientResult = _clientLeafSubGridFactory.GetSubGrid(arg.SurveyedSurfacePatchType == SurveyedSurfacePatchType.CompositeElevations ? GridDataType.CompositeHeights : GridDataType.HeightAndTime); clientResult.FromBytes(result.Bytes); // For now, only cache non-composite elevation sub grids if (cachingSupported) { _cache?.Add(clientResult, subGridInvalidationVersion); } if (savedMap != null) { clientResult = _cache.ExtractFromCachedItem(clientResult, savedMap, arg.SurveyedSurfacePatchType); } } return(clientResult); }