Example #1
0
  /**
   * @deprecated match the input rectangle to support range query the return is
   * @param x
   * @param y
   * @param radius
   * @return an array of two boxes object, and the first box represents the left top point and the
   *     second box represents the right bottom point
   */
  public Hashtable<String, XBox[]> dmatch(double x, double y, double radius) {
    System.out.println("in matching./..." + x + ";" + y);
    Rectangle2D.Double matchRect =
        new Rectangle2D.Double(x - radius, y - radius, 2 * radius, 2 * radius);
    List<XQuadTree> tiles = this.quadtree.tileMatch(x, y, radius);
    Hashtable<String, XBox[]> result = null;
    try {
      if (tiles != null && tiles.size() > 0) {
        result = new Hashtable<String, XBox[]>();
        for (int i = 0; i < tiles.size(); i++) {
          XQuadTree oneTile = tiles.get(i);
          String tileIndex = oneTile.getIndex();
          // get the tile rect where the point is located
          Rectangle2D.Double tile_rect = oneTile.getM_rect();
          Point2D.Double offsetPoint = new Point2D.Double(tile_rect.getX(), tile_rect.getY());
          X2DGrid grid = new X2DGrid(tile_rect, this.cell_size, offsetPoint);
          XBox[] range = grid.intersect(matchRect);
          result.put(tileIndex, range);
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return result;
  }
Example #2
0
  /**
   * match the input rectangle to support range query the return is
   *
   * @param x
   * @param y
   * @param radius
   * @return an array of two boxes object, and the first box represents the left top point and the
   *     second box represents the right bottom point
   */
  public Hashtable<String, XBox[]> match(double x, double y, double radius) {
    System.out.println("in updatedMatch./..." + x + ";" + y);
    double normalized[] = this.quadtree.normalize(x, y);
    x = normalized[0];
    y = normalized[1];
    Rectangle2D.Double matchRect =
        new Rectangle2D.Double(x - radius, y - radius, 2 * radius, 2 * radius);
    List<XQuadTree> tiles = this.quadtree.tileMatch(x, y, radius);
    Hashtable<String, XBox[]> result = null;
    try {
      if (tiles != null && tiles.size() > 0) {
        result = new Hashtable<String, XBox[]>();
        for (int i = 0; i < tiles.size(); i++) {
          XQuadTree oneTile = tiles.get(i);
          String tileIndex = oneTile.getIndex();
          // get the tile rect where the point is located
          X2DGrid grid = this.m_tiles.get(tileIndex);
          XBox[] range = grid.intersect(matchRect);
          result.put(tileIndex, range);
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return result;
  }