Esempio n. 1
0
        /// <summary>
        /// Annotates height information with elevations from surveyed surfaces
        /// </summary>
        private ServerRequestResult PerformHeightAnnotation()
        {
            if (!_haveComputedSpatialFilterMaskAndClientProdDataMap)
            {
                // At this point, the prod data map will be empty. Fill it here so the filter has something to filter against...
                _clientGrid.ProdDataMap.Fill();
            }

            if (!_haveComputedSpatialFilterMaskAndClientProdDataMap && (ComputeSpatialFilterMaskAndClientProdDataMap() != ServerRequestResult.NoError))
            {
                ClientLeafSubGridFactory.ReturnClientSubGrid(ref _clientGrid);
                return(ServerRequestResult.FilterInitialisationFailure);
            }

            if ((_filteredSurveyedSurfaces?.Count ?? 0) == 0)
            {
                return(ServerRequestResult.NoError);
            }

            var result = ServerRequestResult.NoError;

            // TODO: Add Debug_SwitchOffCompositeSurfaceGenerationFromSurveyedSurfaces to configuration
            // if <config>.Debug_SwitchOffCompositeSurfaceGenerationFromSurveyedSurfaces then Exit;

            if (!_clientGrid.UpdateProcessingMapForSurveyedSurfaces(_processingMap, _filteredSurveyedSurfaces as IList, _returnEarliestFilteredCellPass))
            {
                return(ServerRequestResult.NoError);
            }

            if (_processingMap.IsEmpty())
            {
                return(result);
            }

            try
            {
                // Hand client grid details, a mask of cells we need surveyed surface elevations for, and a temp grid to the Design Profiler

                // Instantiate an argument object for the surface elevation patch request. We always want to request all surface elevations to
                // promote cacheability.
                var surfaceElevationPatchArg = new SurfaceElevationPatchArgument
                {
                    SiteModelID              = _siteModel.ID,
                    OTGCellBottomLeftX       = _clientGrid.OriginX,
                    OTGCellBottomLeftY       = _clientGrid.OriginY,
                    CellSize                 = _siteModel.CellSize,
                    IncludedSurveyedSurfaces = _filteredSurveyedSurfacesAsGuidArray,
                    SurveyedSurfacePatchType = _surveyedSurfacePatchType,
                    ProcessingMap            = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled)
                };

                if (!(_surfaceElevationPatchRequest.Execute(surfaceElevationPatchArg) is ClientHeightAndTimeLeafSubGrid surfaceElevations))
                {
                    return(result);
                }

                // Construct the elevation range filter lambda
                Func <int, int, float, bool> elevationRangeFilterLambda = null;
                if (_filter.AttributeFilter.HasElevationRangeFilter)
                {
                    elevationRangeFilterLambda = ApplyElevationRangeFilter;
                }

                if (!_clientGrid.PerformHeightAnnotation(_processingMap, _filteredSurveyedSurfaces as IList, _returnEarliestFilteredCellPass, surfaceElevations, elevationRangeFilterLambda))
                {
                    return(ServerRequestResult.SubGridHeightAnnotationFailed);
                }

                result = ServerRequestResult.NoError;
            }
            finally
            {
                // TODO: Use client sub grid pool...
                //    PSNodeImplInstance.RequestProcessor.RepatriateClientGrid(TICSubGridTreeLeafSubGridBase(SurfaceElevations));
            }

            return(result);
        }