Example #1
0
        public void Test_InterceptList_MergeInterceptLists_MaximumListLength()
        {
            InterceptList list1 = new InterceptList();
            InterceptList list2 = new InterceptList();

            for (int i = 0; i < InterceptList.MaxIntercepts + 10; i++)
            {
                list1.AddPoint(new InterceptRec(i, i, i, i, i, i));
            }

            for (int i = 99; i < 199; i++)
            {
                list2.AddPoint(new InterceptRec(i, i, i, i, i + 0.5, i));
            }

            InterceptList mergedList = new InterceptList();

            mergedList.MergeInterceptLists(list1, list2);

            Assert.True(InterceptList.MaxIntercepts == mergedList.Count, $"Count not == MaxIntercepts after overfilling list ({InterceptList.MaxIntercepts } vs {mergedList.Count}");

            mergedList = new InterceptList();
            mergedList.MergeInterceptLists(list2, list1);

            Assert.True(InterceptList.MaxIntercepts == mergedList.Count, $"Count not == MaxIntercepts after overfilling list ({InterceptList.MaxIntercepts } vs {mergedList.Count}");
        }
Example #2
0
        public void Test_InterceptList_Create()
        {
            InterceptList list = new InterceptList();

            Assert.NotNull(list);
            Assert.True(0 == list.Count, "List not empty after creation");
            Assert.NotNull(list.Items);
        }
Example #3
0
        /// <summary>
        /// Constructs a mask using all spatial filtering elements active in the supplied filter
        /// </summary>
        public static bool ConstructSubGridCellFilterMask(ISiteModel siteModel, SubGridCellAddress currentSubGridOrigin,
                                                          InterceptList intercepts,
                                                          int fromProfileCellIndex,
                                                          SubGridTreeBitmapSubGridBits mask,
                                                          ICellSpatialFilter cellFilter,
                                                          IDesign surfaceDesignMaskDesign)
        {
            ConstructSubGridSpatialAndPositionalMask(currentSubGridOrigin, intercepts, fromProfileCellIndex, mask, cellFilter, siteModel.Grid);

            // If the filter contains an alignment design mask filter then compute this and AND it with the
            // mask calculated in the step above to derive the final required filter mask

            if (cellFilter.HasAlignmentDesignMask())
            {
                if (cellFilter.AlignmentFence.IsNull()) // Should have been done in ASNode but if not
                {
                    throw new ArgumentException($"Spatial filter does not contained pre-prepared alignment fence for design {cellFilter.AlignmentDesignMaskDesignUID}");
                }

                var tree = siteModel.Grid;
                // Go over set bits and determine if they are in Design fence boundary
                mask.ForEachSetBit((x, y) =>
                {
                    tree.GetCellCenterPosition(currentSubGridOrigin.X + x, currentSubGridOrigin.Y + y, out var cx, out var cy);
                    if (!cellFilter.AlignmentFence.IncludesPoint(cx, cy))
                    {
                        mask.ClearBit(x, y); // remove interest as its not in design boundary
                    }
                });
            }

            // If the filter contains a design mask filter then compute this and AND it with the
            // mask calculated in the step above to derive the final required filter mask

            if (surfaceDesignMaskDesign != null)
            {
                var getFilterMaskResult = surfaceDesignMaskDesign.GetFilterMaskViaLocalCompute(siteModel, currentSubGridOrigin, siteModel.CellSize);

                if (getFilterMaskResult.errorCode == DesignProfilerRequestResult.OK || getFilterMaskResult.errorCode == DesignProfilerRequestResult.NoElevationsInRequestedPatch)
                {
                    if (getFilterMaskResult.filterMask == null)
                    {
                        _log.LogWarning("FilterMask null in response from surfaceDesignMaskDesign.GetFilterMask, ignoring it's contribution to filter mask");
                    }
                    else
                    {
                        mask.AndWith(getFilterMaskResult.filterMask);
                    }
                }
                else
                {
                    _log.LogError($"Call (A2) to {nameof(ConstructSubGridCellFilterMask)} returned error result {getFilterMaskResult.errorCode} for {cellFilter.SurfaceDesignMaskDesignUid}");
                    return(false);
                }
            }

            return(true);
        }
Example #4
0
        public void Test_InterceptList_AddPoint_3D_Duplicate()
        {
            InterceptList list = new InterceptList();

            for (int i = 0; i < 5; i++)
            {
                list.AddPoint(1, 1, 1);
            }

            Assert.True(1 == list.Count, "List count incorrect after addition of duplicates");
        }
Example #5
0
        public void Test_InterceptList_AddPoint_3D_Resize()
        {
            InterceptList list = new InterceptList();

            for (int i = 0; i < InterceptList.ListInc + 5; i++)
            {
                list.AddPoint(i, i, i);
            }

            Assert.True(InterceptList.ListInc + 5 == list.Count, "List count incorrect after addition");
        }
Example #6
0
        public void Test_InterceptList_AddPoint2()
        {
            InterceptList list = new InterceptList();

            var newPoint = new InterceptRec(1, 2, 0, 0, 5, 0);

            list.AddPoint(newPoint);

            Assert.True(1 == list.Count, "List count not 1 after addition");
            Assert.True(list.Items[0].Equals(newPoint), "New point and list point not same after addition");
        }
Example #7
0
        public void Test_InterceptList_MaximumListLength()
        {
            InterceptList list = new InterceptList();

            for (int i = 0; i < InterceptList.MaxIntercepts + 10; i++)
            {
                list.AddPoint(new InterceptRec(i, i, i, i, i, i));
            }

            Assert.True(InterceptList.MaxIntercepts == list.Count, $"Count not == MaxIntercepts after overfilling list ({InterceptList.MaxIntercepts } vs {list.Count}");
        }
Example #8
0
        public void Test_InterceptList_UpdateMergedListInterceptMidPoints_EmptyList()
        {
            InterceptList list1 = new InterceptList();
            InterceptList list2 = new InterceptList();

            InterceptList mergedList = new InterceptList();

            mergedList.MergeInterceptLists(list1, list2);
            mergedList.UpdateMergedListInterceptMidPoints();

            Assert.True(0 == mergedList.Count, $"merged list count != 0 after merge, = {mergedList.Count}");
        }
Example #9
0
        public void Test_InterceptList_MergeInterceptLists_SameItems()
        {
            InterceptList list1 = new InterceptList();
            InterceptList list2 = new InterceptList();

            var newPoint = new InterceptRec(1, 2, 3, 4, 5, 6);

            list1.AddPoint(newPoint);
            list2.AddPoint(newPoint);

            InterceptList mergedList = new InterceptList();

            mergedList.MergeInterceptLists(list1, list2);

            Assert.True(1 == mergedList.Count, $"merged list count != after merge, = {mergedList.Count}");
            Assert.Equal(newPoint, mergedList.Items[0]);
        }
Example #10
0
        /// <summary>
        /// Constructs a mask using polygonal and positional spatial filtering aspects of a filter.
        /// </summary>
        private static void ConstructSubGridSpatialAndPositionalMask(SubGridCellAddress currentSubGridOrigin,
                                                                     InterceptList intercepts,
                                                                     int fromProfileCellIndex,
                                                                     SubGridTreeBitmapSubGridBits mask,
                                                                     ICellSpatialFilter cellFilter,
                                                                     ISubGridTree subGridTree)
        {
            var cellFilterHasSpatialOrPositionalFilters = cellFilter.HasSpatialOrPositionalFilters;
            var interceptsCount = intercepts.Count;

            mask.Clear();

            for (var interceptIdx = fromProfileCellIndex; interceptIdx < interceptsCount; interceptIdx++)
            {
                // Determine the on-the-ground cell underneath the midpoint of each cell on the intercept line
                subGridTree.CalculateIndexOfCellContainingPosition(intercepts.Items[interceptIdx].MidPointX,
                                                                   intercepts.Items[interceptIdx].MidPointY, out var otgCellX, out var otgCellY);

                var thisSubGridOrigin = new SubGridCellAddress(otgCellX & ~SubGridTreeConsts.SubGridLocalKeyMask, otgCellY & ~SubGridTreeConsts.SubGridLocalKeyMask);

                if (!currentSubGridOrigin.Equals(thisSubGridOrigin))
                {
                    break;
                }

                var cellX = otgCellX & SubGridTreeConsts.SubGridLocalKeyMask;
                var cellY = otgCellY & SubGridTreeConsts.SubGridLocalKeyMask;

                if (cellFilterHasSpatialOrPositionalFilters)
                {
                    subGridTree.GetCellCenterPosition(otgCellX, otgCellY, out var cellCenterX, out var cellCenterY);

                    if (cellFilter.IsCellInSelection(cellCenterX, cellCenterY))
                    {
                        mask.SetBit(cellX, cellY);
                    }
                }
                else
                {
                    mask.SetBit(cellX, cellY);
                }
            }
        }
Example #11
0
        public void Test_InterceptList_MergeInterceptLists_UniqueItems_InOrder()
        {
            InterceptList list1 = new InterceptList();
            InterceptList list2 = new InterceptList();

            var newPoint1 = new InterceptRec(1, 2, 3, 4, 5, 6);
            var newPoint2 = new InterceptRec(2, 3, 4, 5, 6, 7);

            list1.AddPoint(newPoint1);
            list2.AddPoint(newPoint2);

            InterceptList mergedList = new InterceptList();

            mergedList.MergeInterceptLists(list1, list2);

            Assert.True(2 == mergedList.Count, $"merged list count != after merge, = {mergedList.Count}");
            Assert.Equal(newPoint1, mergedList.Items[0]);
            Assert.Equal(newPoint2, mergedList.Items[1]);
        }
Example #12
0
        public void Test_InterceptList_MergeInterceptLists_SameItems_InExactOutOfOrder()
        {
            InterceptList list1 = new InterceptList();
            InterceptList list2 = new InterceptList();

            var newPoint1 = new InterceptRec(1.99995f, 2.99995f, 3, 4, 5.99995f, 6);
            var newPoint2 = new InterceptRec(2, 3, 4, 5, 6, 7);

            list1.AddPoint(newPoint2);
            list2.AddPoint(newPoint1);

            InterceptList mergedList = new InterceptList();

            mergedList.MergeInterceptLists(list1, list2);

            Assert.True(1 == mergedList.Count, $"merged list count != after merge, = {mergedList.Count}");
            Assert.Equal(newPoint1, mergedList.Items[0]);
            Assert.Equal(newPoint2, mergedList.Items[0]);
        }