/** * 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; }
/** * @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; }