Package sil.spatialindex

Examples of sil.spatialindex.Region


  public IShape getChildShape(int index) throws IndexOutOfBoundsException
  {
    if (index < 0 || index >= m_children) throw new IndexOutOfBoundsException("" + index);

    return new Region(m_pMBR[index]);
  }
View Full Code Here


    mask[seeds[0]] = true;
    mask[seeds[1]] = true;

    // find MBR of each group.
    Region mbr1 = (Region) m_pMBR[seeds[0]].clone();
    Region mbr2 = (Region) m_pMBR[seeds[1]].clone();

    // count how many entries are left unchecked (exclude the seeds here.)
    int cRemaining = m_capacity + 1 - 2;

    while (cRemaining > 0)
    {
      if (minimumLoad - group1.size() == cRemaining)
      {
        // all remaining entries must be assigned to group1 to comply with minimun load requirement.
        for (cChild = 0; cChild < m_capacity + 1; cChild++)
        {
          if (mask[cChild] == false)
          {
            group1.add(new Integer(cChild));
            mask[cChild] = true;
            cRemaining--;
          }
        }
      }
      else if (minimumLoad - group2.size() == cRemaining)
      {
        // all remaining entries must be assigned to group2 to comply with minimun load requirement.
        for (cChild = 0; cChild < m_capacity + 1; cChild++)
        {
          if (mask[cChild] == false)
          {
            group2.add(new Integer(cChild));
            mask[cChild] = true;
            cRemaining--;
          }
        }
      }
      else
      {
        // For all remaining entries compute the difference of the cost of grouping an
        // entry in either group. When done, choose the entry that yielded the maximum
        // difference. In case of linear split, select any entry (e.g. the first one.)
        int sel = -1;
        double md1 = 0.0f, md2 = 0.0f;
        double m = Double.NEGATIVE_INFINITY;
        double d1, d2, d;
        double a1 = mbr1.getArea();
        double a2 = mbr2.getArea();

        for (cChild = 0; cChild < m_capacity + 1; cChild++)
        {
          if (mask[cChild] == false)
          {
            Region a = mbr1.combinedRegion(m_pMBR[cChild]);
            d1 = a.getArea() - a1;
            Region b = mbr2.combinedRegion(m_pMBR[cChild]);
            d2 = b.getArea() - a2;
            d = Math.abs(d1 - d2);

            if (d > m)
            {
              m = d;
View Full Code Here

        {
          tl1[cIndex] = dataLow[cIndex].m_pRegion;
          th1[cIndex] = dataHigh[cIndex].m_pRegion;
        }

        Region bbl1 = Region.combinedRegion(tl1);
        Region bbh1 = Region.combinedRegion(th1);

        Region[] tl2 = new Region[m_capacity + 1 - l];
        Region[] th2 = new Region[m_capacity + 1 - l];

        int tmpIndex = 0;
        for (cIndex = l; cIndex < m_capacity + 1; cIndex++)
        {
          tl2[tmpIndex] = dataLow[cIndex].m_pRegion;
          th2[tmpIndex] = dataHigh[cIndex].m_pRegion;
          tmpIndex++;
        }

        Region bbl2 = Region.combinedRegion(tl2);
        Region bbh2 = Region.combinedRegion(th2);

        marginl += bbl1.getMargin() + bbl2.getMargin();
        marginh += bbh1.getMargin() + bbh2.getMargin();
      } // for (cChild)

      double margin = Math.min(marginl, marginh);

      // keep minimum margin as split axis.
      if (margin < minimumMargin)
      {
        minimumMargin = margin;
        splitAxis = cDim;
        sortOrder = (marginl < marginh) ? 0 : 1;
      }

      // increase the dimension according to which the data entries should be sorted.
      for (cChild = 0; cChild < m_capacity + 1; cChild++)
      {
        dataLow[cChild].m_sortDim = cDim + 1;
      }
    } // for (cDim)

    for (cChild = 0; cChild < m_capacity + 1; cChild++)
    {
      dataLow[cChild].m_sortDim = splitAxis;
    }

    if (sortOrder == 0)
      Arrays.sort(dataLow, new RstarSplitEntryComparatorLow());
    else
      Arrays.sort(dataLow, new RstarSplitEntryComparatorHigh());

    double ma = Double.POSITIVE_INFINITY;
    double mo = Double.POSITIVE_INFINITY;
    int splitPoint = -1;

    for (cChild = 1; cChild <= splitDistribution; cChild++)
    {
      int l = nodeSPF - 1 + cChild;

      Region[] t1 = new Region[l];

      for (cIndex = 0; cIndex < l; cIndex++)
      {
        t1[cIndex] = dataLow[cIndex].m_pRegion;
      }

      Region bb1 = Region.combinedRegion(t1);

      Region[] t2 = new Region[m_capacity + 1 - l];

      int tmpIndex = 0;
      for (cIndex = l; cIndex < m_capacity + 1; cIndex++)
      {
        t2[tmpIndex] = dataLow[cIndex].m_pRegion;
        tmpIndex++;
      }

      Region bb2 = Region.combinedRegion(t2);

      double o = bb1.getIntersectingArea(bb2);

      if (o < mo)
      {
        splitPoint = cChild;
        mo = o;
        ma = bb1.getArea() + bb2.getArea();
      }
      else if (o == mo)
      {
        double a = bb1.getArea() + bb2.getArea();

        if (a < ma)
        {
          splitPoint = cChild;
          ma = a;
View Full Code Here

          double a = m_pMBR[cChild].getArea();

          for (cIndex = cChild + 1; cIndex < m_capacity + 1; cIndex++)
          {
            // get the combined MBR of those two entries.
            Region r = m_pMBR[cChild].combinedRegion(m_pMBR[cIndex]);

            // find the inefficiency of grouping these entries together.
            double d = r.getArea() - a - m_pMBR[cIndex].getArea();

            if (d > inefficiency)
            {
              inefficiency = d;
              i1 = cChild;
View Full Code Here

    m_level = ds.readInt();
    m_children = ds.readInt();

    for (int cChild = 0; cChild < m_children; cChild++)
    {
      m_pMBR[cChild] = new Region();
      m_pMBR[cChild].m_pLow = new double[m_pTree.m_dimension];
      m_pMBR[cChild].m_pHigh = new double[m_pTree.m_dimension];

      for (int cDim = 0; cDim < m_pTree.m_dimension; cDim++)
      {
View Full Code Here

    double area = Double.POSITIVE_INFINITY;
    int best = -1;

    for (int cChild = 0; cChild < m_children; cChild++)
    {
      Region t = m_pMBR[cChild].combinedRegion(r);

      double a = m_pMBR[cChild].getArea();
      double enl = t.getArea() - a;

      if (enl < area)
      {
        area = enl;
        best = cChild;
View Full Code Here

TOP

Related Classes of sil.spatialindex.Region

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.