コード例 #1
0
        protected override void AddCore(Feature feature)
        {
            int   level    = QTreeHelper.GetAppropriateLevel(maxExtent, feature.GetBoundingBox());
            ulong location = QTreeHelper.GetLocation(maxExtent, feature.GetShape(), level);

            if (location != 0)
            {
                QuadCell cell = QTreeHelper.GetCellByLocation(maxExtent, location);
                lock (sync)
                {
                    if (!qtree.ContainsKey(location))
                    {
                        lock (sync)
                        {
                            QuadTreeNode node = new QuadTreeNode(cell.Location, cell.BoundingBox, feature.Id);
                            qtree.Add(location, node);
                        }
                        if (maxLevel < level)
                        {
                            maxLevel = level;
                        }
                    }
                }
            }
        }
コード例 #2
0
        private static Dictionary <int, Collection <QuadCell> > GetCells(ulong location, RectangleShape boudingBox, Dictionary <int, Collection <QuadCell> > currentLevelCellsSet, int currentLevel, int endLevel)
        {
            QuadCell newQTreeCell = new QuadCell(location, boudingBox);

            if (!currentLevelCellsSet.Keys.Contains(currentLevel))
            {
                Collection <QuadCell> qTreeCells = new Collection <QuadCell> {
                    newQTreeCell
                };
                currentLevelCellsSet.Add(currentLevel, qTreeCells);
            }
            else
            {
                currentLevelCellsSet[currentLevel].Add(newQTreeCell);
            }
            if (currentLevel < endLevel)
            {
                currentLevel++;
                GetCells((location << 1) | 1, GetUpperLeftQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 2) | 1, GetUpperRightQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 3) | 1, GetLowerLeftQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 4) | 1, GetLowerRightQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
            }

            return(currentLevelCellsSet);
        }
コード例 #3
0
        private static Dictionary<int, Collection<QuadCell>> GetCells(ulong location, RectangleShape boudingBox, Dictionary<int, Collection<QuadCell>> currentLevelCellsSet, int currentLevel, int endLevel)
        {
            QuadCell newQTreeCell = new QuadCell(location, boudingBox);
            if (!currentLevelCellsSet.Keys.Contains(currentLevel))
            {
                Collection<QuadCell> qTreeCells = new Collection<QuadCell> { newQTreeCell };
                currentLevelCellsSet.Add(currentLevel, qTreeCells);
            }
            else
            {
                currentLevelCellsSet[currentLevel].Add(newQTreeCell);
            }
            if (currentLevel < endLevel)
            {
                currentLevel++;
                GetCells((location << 1) | 1, GetUpperLeftQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 2) | 1, GetUpperRightQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 3) | 1, GetLowerLeftQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
                GetCells((location << 4) | 1, GetLowerRightQuater(boudingBox), currentLevelCellsSet, currentLevel, endLevel);
            }

            return currentLevelCellsSet;
        }