Esempio n. 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;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private Collection <QuadTreeNode> GetIntersectedCells(RectangleShape boundingBox, int level)
        {
            Collection <QuadTreeNode> result = new Collection <QuadTreeNode>();

            ulong queriedBboxLocation = QTreeHelper.GetLocation(maxExtent, boundingBox, level);

            lock (sync)
            {
                foreach (ulong key in qtree.Keys)
                {
                    //QuadCell cell = QTreeHelper.GetCellByLocation(maxExtent, key);
                    if (QTreeHelper.HasPart(queriedBboxLocation, key) && boundingBox.Intersects(QTreeHelper.GetCellByLocation(maxExtent, key).BoundingBox))
                    {
                        result.Add(qtree[key]);
                    }
                }
            }

            return(result);
        }