Пример #1
0
        public override bool UpdateProcessingMapForSurveyedSurfaces(SubGridTreeBitmapSubGridBits processingMap, IList filteredSurveyedSurfaces, bool returnEarliestFilteredCellPass)
        {
            if (!(filteredSurveyedSurfaces is ISurveyedSurfaces surveyedSurfaces))
            {
                return(false);
            }

            processingMap.Assign(FilterMap);

            // If we're interested in a particular cell, but we don't have any surveyed surfaces later (or earlier)
            // than the cell production data pass time (depending on PassFilter.ReturnEarliestFilteredCellPass)
            // then there's no point in asking the Design Profiler service for an elevation

            processingMap.ForEachSetBit((x, y) =>
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (Cells[x, y] != Consts.NullHeight &&
                    !(returnEarliestFilteredCellPass ? surveyedSurfaces.HasSurfaceEarlierThan(Times[x, y]) : surveyedSurfaces.HasSurfaceLaterThan(Times[x, y])))
                {
                    processingMap.ClearBit(x, y);
                }
            });

            return(true);
        }
Пример #2
0
        public override bool ComputeFilterPatch(double startStn, double endStn, double leftOffset, double rightOffset,
                                                SubGridTreeBitmapSubGridBits mask,
                                                SubGridTreeBitmapSubGridBits patch,
                                                double originX, double originY,
                                                double cellSize,
                                                double offset)
        {
            var Heights = new float[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension];

            if (InterpolateHeights(Heights, originX, originY, cellSize, offset))
            {
                mask.ForEachSetBit((x, y) =>
                {
                    if (Heights[x, y] == Common.Consts.NullHeight)
                    {
                        mask.ClearBit(x, y);
                    }
                });
                patch.Assign(mask);

                //SIGLogMessage.PublishNoODS(Self, Format('Filter patch construction successful with %d bits', [patch.CountBits]), ...);

                return(true);
            }

            //SIGLogMessage.PublishNoODS(Self, Format('Filter patch construction failed...', []), ...);
            return(false);
        }
Пример #3
0
        public override bool PerformHeightAnnotation(SubGridTreeBitmapSubGridBits processingMap, IList filteredSurveyedSurfaces, bool returnEarliestFilteredCellPass,
                                                     IClientLeafSubGrid surfaceElevationsSource, Func <int, int, float, bool> elevationRangeFilterLambda)
        {
            if (!(surfaceElevationsSource is ClientHeightAndTimeLeafSubGrid surfaceElevations))
            {
                _log.LogError($"{nameof(ClientHeightAndTimeLeafSubGrid)}.{nameof(PerformHeightAnnotation)} not supplied a ClientHeightAndTimeLeafSubGrid instance, but an instance of {surfaceElevationsSource?.GetType().FullName}");
                return(false);
            }

            // For all cells we wanted to request a surveyed surface elevation for,
            // update the cell elevation if a non null surveyed surface of appropriate time was computed
            // Note: The surveyed surface will return all cells in the requested sub grid, not just the ones indicated in the processing map
            // IE: It is unsafe to test for null top indicate not-filtered, use the processing map iterators to cover only those cells required
            processingMap.ForEachSetBit((x, y) =>
            {
                var surveyedSurfaceCellHeight = surfaceElevations.Cells[x, y];

                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (surveyedSurfaceCellHeight == Consts.NullHeight)
                {
                    return;
                }

                // If we got back a surveyed surface elevation...
                var surveyedSurfaceCellTime = surfaceElevations.Times[x, y];
                var prodHeight = Cells[x, y];
                var prodTime   = Times[x, y];

                // Determine if the elevation from the surveyed surface data is required based on the production data elevation being null, and
                // the relative age of the measured surveyed surface elevation compared with a non-null production data height
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (!(prodHeight == Consts.NullHeight || (returnEarliestFilteredCellPass ? surveyedSurfaceCellTime <prodTime : surveyedSurfaceCellTime> prodTime)))
                {
                    // We didn't get a surveyed surface elevation, so clear the bit in the processing map to indicate there is no surveyed surface information present for it
                    processingMap.ClearBit(x, y);
                    return;
                }

                // Check if there is an elevation range filter in effect and whether the surveyed surface elevation data matches it
                if (elevationRangeFilterLambda != null)
                {
                    if (!elevationRangeFilterLambda(x, y, surveyedSurfaceCellHeight))
                    {
                        // We didn't get a surveyed surface elevation, so clear the bit in the processing map to indicate there is no surveyed surface information present for it
                        processingMap.ClearBit(x, y);
                        return;
                    }
                }

                Cells[x, y] = surveyedSurfaceCellHeight;
                Times[x, y] = surveyedSurfaceCellTime;
            });

            //        if (ClientGrid_is_TICClientSubGridTreeLeaf_HeightAndTime)
            //          ClientGridAsHeightAndTime.SurveyedSurfaceMap.Assign(ProcessingMap);
            return(true);
        }
Пример #4
0
        public void Test_SubGridTreeBitmapSubGridBitsTests_ForEachSetBit()
        {
            // Test iteration action for empty, full and arbitrary masks
            SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled);

            int sum;

            sum = 0;
            bits.ForEachSetBit((x, y) => { sum++; });
            Assert.True(sum == bits.CountBits() && sum == SubGridTreeConsts.CellsPerSubGrid, "Summation via ForEachSetBit on full mask did not give expected result");

            sum = 0;
            bits.Clear();
            bits.ForEachSetBit((x, y) => { sum++; });
            Assert.True(sum == bits.CountBits() && sum == 0, "Summation via ForEachSetBit on empty mask did not give expected result");

            sum = 0;
            bits.SetBit(1, 1);
            bits.ForEachSetBit((x, y) => { sum++; });
            Assert.True(sum == bits.CountBits() && sum == 1, "Summation via ForEachSetBit on mask with single bit set at (1, 1) did not give expected result");
        }
Пример #5
0
 /// <summary>
 /// Assign cell information from a previously cached result held in the general sub grid result cache
 /// using the supplied map to control which cells from the caches sub grid should be copied into this
 /// client leaf sub grid
 /// </summary>
 /// <param name="source"></param>
 /// <param name="map"></param>
 public override void AssignFromCachedPreProcessedClientSubGrid(ISubGrid source, SubGridTreeBitmapSubGridBits map)
 {
     if (map.IsFull())
     {
         AssignFromCachedPreProcessedClientSubGrid(source);
     }
     else
     {
         var subGrid = (GenericClientLeafSubGrid <T>)source;
         map.ForEachSetBit((x, y) => Cells[x, y] = subGrid.Cells[x, y]);
     }
 }