/** * Get the GeoPoint for x,y in screen coordinates. * * @param x screen coordinate * @param y screen coordinate * @return the corresponding GeoPoint */ public GeoPoint fromScreenPoint(float x, float y) { fromScreenPoint(x, y, mMovePoint); return new GeoPoint( MercatorProjection.toLatitude(mMovePoint.y), MercatorProjection.toLongitude(mMovePoint.x)); }
@Override public void query(MapTile tile, ITileDataSink sink) { if (mTileSource.fileHeader == null) { sink.completed(FAILED); return; } if (mIntBuffer == null) mIntBuffer = new int[MAXIMUM_WAY_NODES_SEQUENCE_LENGTH * 2]; try { mTileProjection.setTile(tile); // mTile = tile; /* size of tile in map coordinates; */ double size = 1.0 / (1 << tile.zoomLevel); /* simplification tolerance */ int pixel = (tile.zoomLevel > 11) ? 1 : 2; int simplify = Tile.SIZE / pixel; /* translate screen pixel for tile to latitude and longitude * tolerance for point reduction before projection. */ minDeltaLat = (int) (Math.abs( MercatorProjection.toLatitude(tile.y + size) - MercatorProjection.toLatitude(tile.y)) * 1e6) / simplify; minDeltaLon = (int) (Math.abs( MercatorProjection.toLongitude(tile.x + size) - MercatorProjection.toLongitude(tile.x)) * 1e6) / simplify; QueryParameters queryParameters = new QueryParameters(); queryParameters.queryZoomLevel = mTileSource.fileHeader.getQueryZoomLevel(tile.zoomLevel); /* get and check the sub-file for the query zoom level */ SubFileParameter subFileParameter = mTileSource.fileHeader.getSubFileParameter(queryParameters.queryZoomLevel); if (subFileParameter == null) { log.warn("no sub-file for zoom level: " + queryParameters.queryZoomLevel); sink.completed(FAILED); return; } QueryCalculations.calculateBaseTiles(queryParameters, tile, subFileParameter); QueryCalculations.calculateBlocks(queryParameters, subFileParameter); processBlocks(sink, queryParameters, subFileParameter); } catch (IOException e) { log.error(e.getMessage()); sink.completed(FAILED); return; } sink.completed(SUCCESS); }