Beispiel #1
0
  /**
   * get index for the data point, the column index should be appended the location id later row
   * index: (QT tile index - row index, column index)
   *
   * @param x latitude of the location point
   * @param y longitude of the location point
   * @return
   */
  public String[] locate(double x, double y) {
    LOG.info("Entry: locate():" + x + ";" + y);
    CLOG.info("Entry: locate():" + x + ";" + y);
    // filter the tile with quad tree first
    double normalized[] = this.quadtree.normalize(x, y);
    x = normalized[0];
    y = normalized[1];
    XQuadTree tile = this.quadtree.locate(x, y);
    LOG.info("tile is " + tile.getIndex());
    // get index in the first level
    String tile_index = tile.getIndex();
    X2DGrid grid = this.m_tiles.get(tile_index);

    // get the tile rect where the point is located
    XBox box = grid.locate(x, y);
    String[] indexes = new String[2];
    if (tile_index.isEmpty()) {
      indexes[0] = box.getRow();
    } else {
      indexes[0] = tile_index + "-" + box.getRow();
    }
    indexes[1] = box.getColumn();
    LOG.info("Locate: row=> " + indexes[0] + ";column=>" + indexes[1]);
    CLOG.info("Locate: row=> " + indexes[0] + ";column=>" + indexes[1]);
    return indexes;
  }
Beispiel #2
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;
  }
Beispiel #3
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;
  }
Beispiel #4
0
 /**
  * @deprecated get index for the data point, the column index should be appended the location id
  *     later row index: (QT tile index - row index, column index)
  * @param x latitude of the location point
  * @param y longitude of the location point
  * @return
  */
 public String[] dlocate(double x, double y) {
   // filter the tile with quad tree first
   XQuadTree tile = this.quadtree.locate(x, y);
   // get index in the first level
   String tile_index = tile.getIndex();
   // get the tile rect where the point is located
   Rectangle2D.Double tile_rect = tile.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 box = grid.locate(x, y);
   String[] indexes = new String[2];
   indexes[0] = tile_index + "-" + box.getRow();
   indexes[1] = box.getColumn();
   // System.out.println("row=> "+indexes[0]+";column=>"+indexes[1]);
   return indexes;
 }
Beispiel #5
0
 public void getTiles(XQuadTree treeNode) {
   if (!treeNode.isHasChild()) { // this is the leaf node     	
     Rectangle2D.Double tile_rect = treeNode.getM_rect();
     Point2D.Double offsetPoint = new Point2D.Double(tile_rect.getX(), tile_rect.getY());
     X2DGrid grid = new X2DGrid(tile_rect, this.cell_size, offsetPoint);
     this.m_tiles.put(treeNode.getIndex(), grid);
   } else {
     this.getTiles(treeNode.getM_tl_child());
     this.getTiles(treeNode.getM_tr_child());
     this.getTiles(treeNode.getM_bl_child());
     this.getTiles(treeNode.getM_br_child());
   }
 }