예제 #1
0
        /// <summary>
        /// InitialiseFilterContext performs any required filter initialization and configuration
        /// that is external to the filter prior to engaging in cell by cell processing of this sub grid
        /// </summary>
        private bool InitialiseFilterContext()
        {
            if (_filter == null)
            {
                return(true);
            }

            // TODO: If the elevation range design and the surface design mask design are the same then only request the design elevations once.

            if (_filter.AttributeFilter.HasElevationRangeFilter)
            {
                _filterAnnex.ClearElevationRangeFilterInitialization();

                // If the elevation range filter uses a design then the design elevations
                // for the sub grid need to be calculated and supplied to the filter

                if (_elevationRangeDesign != null)
                {
                    // Query the design to get the patch of elevations calculated from the design
                    var getDesignHeightsResult = _elevationRangeDesign.Design.GetDesignHeightsViaLocalCompute(_siteModel,
                                                                                                              _elevationRangeDesign.Offset, _clientGrid.OriginAsCellAddress(), _clientGrid.CellSize);
                    _elevationRangeDesignElevations = getDesignHeightsResult.designHeights?.Cells;

                    if ((getDesignHeightsResult.errorCode != DesignProfilerRequestResult.OK && getDesignHeightsResult.errorCode != DesignProfilerRequestResult.NoElevationsInRequestedPatch) ||
                        _elevationRangeDesignElevations == null)
                    {
                        return(false);
                    }

                    _filterAnnex.InitializeElevationRangeFilter(_filter.AttributeFilter, _elevationRangeDesignElevations);
                }
            }

            if (_filter.SpatialFilter.HasSurfaceDesignMask())
            {
                // SIGLogMessage.PublishNoODS(Nil, Format('#D# InitialiseFilterContext RequestDesignElevationPatch for Design %s',[CellFilter.DesignFilter.FileName]), ...);
                // Query the DesignProfiler service to get the patch of elevations calculated

                //Spatial design filter - don't care about offset
                var getDesignHeightsResult = _surfaceDesignMaskDesign.GetDesignHeightsViaLocalCompute(_siteModel, 0, _clientGrid.OriginAsCellAddress(), _clientGrid.CellSize);
                _surfaceDesignMaskElevations = getDesignHeightsResult.designHeights?.Cells;

                if ((getDesignHeightsResult.errorCode != DesignProfilerRequestResult.OK && getDesignHeightsResult.errorCode != DesignProfilerRequestResult.NoElevationsInRequestedPatch) ||
                    _surfaceDesignMaskElevations == null)
                {
                    _log.LogError($"#D# InitialiseFilterContext RequestDesignElevationPatch for Design {_surfaceDesignMaskDesign.DesignDescriptor.FileName} failed");
                    return(false);
                }
            }

            return(true);
        }