Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public async Task <IClientLeafSubGrid> ExecuteAsync(ISurfaceElevationPatchArgument arg) => Execute(arg); // Task.Run(() => Execute(arg));