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; } } } } }
protected override void DeleteCore(Feature feature) { int level = QTreeHelper.GetAppropriateLevel(maxExtent, feature.GetBoundingBox()); ulong location = QTreeHelper.GetLocation(maxExtent, feature.GetShape(), level); if (location == 0 && qtree.ContainsKey(location)) { qtree.Remove(location); } }
protected override Collection <string> GetFeatureIdsIntersectingBoundingBoxCore(RectangleShape boundingBox) { int level = QTreeHelper.GetAppropriateLevel(maxExtent, boundingBox); Collection <QuadTreeNode> intersectedNodes = GetIntersectedCells(boundingBox, level + 1); Collection <string> featureIds = new Collection <string>(); foreach (QuadTreeNode node in intersectedNodes) { featureIds.Add(node.Id); } return(featureIds); }