/// <summary> /// Calculates a cut/fill sub grid from a production data elevation sub grid and an elevation sub grid computed from a referenced design, /// replacing the elevations in the first sub grid with the resulting cut fill values /// </summary> public static (bool executionResult, DesignProfilerRequestResult profilerRequestResult) ComputeCutFillSubGrid(ISiteModel siteModel, IClientLeafSubGrid SubGrid, IDesignWrapper designWrapper) { (bool executionResult, DesignProfilerRequestResult profilerRequestResult)result = (false, DesignProfilerRequestResult.UnknownError); if (designWrapper?.Design == null) { return(result); } var getDesignHeightsResult = designWrapper.Design.GetDesignHeightsViaLocalCompute(siteModel, designWrapper.Offset, SubGrid.OriginAsCellAddress(), SubGrid.CellSize); result.profilerRequestResult = getDesignHeightsResult.errorCode; if (result.profilerRequestResult != DesignProfilerRequestResult.OK && result.profilerRequestResult != DesignProfilerRequestResult.NoElevationsInRequestedPatch) { _log.LogError($"Design profiler sub grid elevation request for {SubGrid.OriginAsCellAddress()} failed with error {result.profilerRequestResult}"); return(result); } ComputeCutFillSubGrid((IClientHeightLeafSubGrid)SubGrid, getDesignHeightsResult.designHeights); result.executionResult = true; return(result); }
/// <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); }