Пример #1
0
 private void refresh(RNode part1, RNode part2) throws DimensionalException {
   if (part1 == root) {
     if (part2 != null) {
       // build new root and add children.
       root = makeRoot(false);
       root.addChild(part1);
       part1.setParent(root);
       root.addChild(part2);
       part2.setParent(root);
     }
     update(root);
     return;
   }
   update(part1);
   if (part2 != null) {
     update(part2);
     if (part1.getParent().getChildren().size() > M_order) {
       RNode[] splits = makePartition(part1.getParent());
       refresh(splits[0], splits[1]);
     }
   }
   if (part1.getParent() != null) {
     refresh(part1.getParent(), null);
   }
 }
Пример #2
0
 /**
  * shrinks the mbr area to the just necessary
  *
  * @param n
  */
 private void update(RNode n) throws DimensionalException {
   double[] minCoords = new double[dimension];
   double[] maxCoords = new double[dimension];
   for (int i = 0; i < dimension; i++) {
     minCoords[i] = Double.MAX_VALUE;
     maxCoords[i] = -Double.MAX_VALUE;
     for (RNode c : n.children()) {
       c.setParent(n);
       double minp = Math.min(c.getMbr().getP_start()[i], c.getMbr().getP_end()[i]);
       double maxp = Math.max(c.getMbr().getP_end()[i], c.getMbr().getP_start()[i]);
       if (minp < minCoords[i]) {
         minCoords[i] = minp;
       }
       if (maxp > maxCoords[i]) {
         maxCoords[i] = maxp;
       }
     }
   }
   n.setMbr(new MBR(minCoords, maxCoords, dimension));
 }