Beispiel #1
0
        protected void setElement(List <Edge> newElements, MBR newMbr)
        {
            this.elements.Clear();
            foreach (Edge pt in newElements)
            {
                this.elements.Add(pt);
            }

            this.children.Clear();

            if (m_br == null)
            {
                m_br = new MBR(newMbr);
            }
            else
            {
                m_br.become(newMbr);
            }
        }
Beispiel #2
0
        protected void quadraticSplitNodes(List <rtree> oldItems, rtree newItem, List <rtree> set_one, List <rtree> set_two, MBR br_one, MBR br_two)
        {
            oldItems.Add(newItem);

            int    m = 0, n = 1;
            double maxArea = areaExpand(oldItems[0].m_br, oldItems[1].m_br);

            for (int i = 0; i < oldItems.Count; i++)
            {
                for (int j = i + 1; j < oldItems.Count; j++)
                {
                    double area = areaExpand(oldItems[i].m_br, oldItems[j].m_br);
                    if (area > maxArea)
                    {
                        maxArea = area;
                        m       = i;
                        n       = j;
                    }
                }
            }

            set_one.Add(oldItems[m]);
            set_two.Add(oldItems[n]);

            MBR set_one_mbr = new MBR(oldItems[m].m_br);
            MBR set_two_mbr = new MBR(oldItems[n].m_br);

            oldItems.RemoveAt(m);

            if (m < n)
            {
                oldItems.RemoveAt(n - 1);
            }
            else
            {
                oldItems.RemoveAt(n);
            }

            while (!(oldItems.Count == 0))
            {
                if (minItems - set_one.Count == oldItems.Count)
                {
                    for (int i = 0; i < oldItems.Count; i++)
                    {
                        set_one.Add(oldItems[i]);
                        set_one_mbr.unionWith(oldItems[i].m_br);
                    }
                    break;
                }
                else if (oldItems.Count == minItems - set_two.Count)
                {
                    for (int i = 0; i < oldItems.Count; i++)
                    {
                        set_two.Add(oldItems[i]);
                        set_two_mbr.unionWith(oldItems[i].m_br);
                    }
                    break;
                }

                int k = 0;

                double s = areaExpand(set_one_mbr, oldItems[k].m_br);
                double t = areaExpand(set_two_mbr, oldItems[k].m_br);

                if (s < t)
                {
                    set_one.Add(oldItems[k]);
                    set_one_mbr.unionWith(oldItems[k].m_br);
                }
                else
                {
                    set_two.Add(oldItems[k]);
                    set_two_mbr.unionWith(oldItems[k].m_br);
                }

                oldItems.RemoveAt(k);
            }

            br_one.become(set_one_mbr);
            br_two.become(set_two_mbr);
        }