コード例 #1
0
ファイル: Node.cs プロジェクト: zhongshuiyuan/mapwindowsix
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <param name="addEnv"></param>
        /// <returns></returns>
        public static Node CreateExpanded(Node node, IEnvelope addEnv)
        {
            Envelope expandEnv = new Envelope(addEnv);
            if (node != null) 
                expandEnv.ExpandToInclude(node.env);

            Node largerNode = CreateNode(expandEnv);
            if (node != null) 
                largerNode.InsertNode(node);
            return largerNode;
        }
コード例 #2
0
ファイル: Root.cs プロジェクト: zhongshuiyuan/mapwindowsix
 /// <summary> 
 /// Insert an item which is known to be contained in the tree rooted at
 /// the given QuadNode root.  Lower levels of the tree will be created
 /// if necessary to hold the item.
 /// </summary>
 private void InsertContained(Node tree, IEnvelope itemEnv, object item)
 {
     Assert.IsTrue(tree.Envelope.Contains(itemEnv));
     /*
     * Do NOT create a new quad for zero-area envelopes - this would lead
     * to infinite recursion. Instead, use a heuristic of simply returning
     * the smallest existing quad containing the query
     */
     bool isZeroX = IntervalSize.IsZeroWidth(itemEnv.Minimum.X, itemEnv.Maximum.X);
     bool isZeroY = IntervalSize.IsZeroWidth(itemEnv.Minimum.X, itemEnv.Maximum.X);
     NodeBase node;
     if (isZeroX || isZeroY)
          node = tree.Find(itemEnv);
     else node = tree.GetNode(itemEnv);
     node.Add(item);
 }
コード例 #3
0
ファイル: Node.cs プロジェクト: zhongshuiyuan/mapwindowsix
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private Node CreateSubnode(int index)
        {
            // create a new subquad in the appropriate quadrant
            double minx = 0.0;
            double maxx = 0.0;
            double miny = 0.0;
            double maxy = 0.0;

            switch (index) 
            {
                case 0:
                    minx = env.Minimum.X;
                    maxx = centre.X;
                    miny = env.Minimum.Y;
                    maxy = centre.Y;
                    break;
                case 1:
                    minx = centre.X;
                    maxx = env.Maximum.X;
                    miny = env.Minimum.Y;
                    maxy = centre.Y;
                    break;
                case 2:
                    minx = env.Minimum.X;
                    maxx = centre.X;
                    miny = centre.Y;
                    maxy = env.Maximum.Y;
                    break;
                case 3:
                    minx = centre.X;
                    maxx = env.Maximum.X;
                    miny = centre.Y;
                    maxy = env.Maximum.Y;
                    break;
	            default:
		            break;
            }
            Envelope sqEnv = new Envelope(minx, maxx, miny, maxy);
            Node node = new Node(sqEnv, level - 1);
            return node;
        }
コード例 #4
0
ファイル: Node.cs プロジェクト: zhongshuiyuan/mapwindowsix
 /// <summary>
 /// 
 /// </summary>
 /// <param name="env"></param>
 /// <returns></returns>
 public static Node CreateNode(IEnvelope env)
 {
     Key key = new Key(env);
     Node node = new Node(key.Envelope, key.Level);
     return node;
 }
コード例 #5
0
ファイル: Node.cs プロジェクト: zhongshuiyuan/mapwindowsix
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public virtual void InsertNode(Node node)
 {
     Assert.IsTrue(env == null || env.Contains(node.Envelope));        
     int index = GetSubnodeIndex(node.env, centre);        
     if (node.level == level - 1)
         Nodes[index] = node;                    
     else 
     {
         // the quad is not a direct child, so make a new child quad to contain it
         // and recursively insert the quad
         Node childNode = CreateSubnode(index);
         childNode.InsertNode(node);
         Nodes[index] = childNode;
     }
 }