use of net.osmand.data.QuadRect in project Osmand by osmandapp.
the class PrecalculatedRouteDirection method getIndex.
public int getIndex(int x31, int y31) {
int ind = -1;
cachedS.clear();
// indexedPoints.getObjects(x31 - SHIFT, y31 - SHIFT, x31 + SHIFT, y31 + SHIFT, cachedS);
quadTree.queryInBox(new QuadRect(x31 - SHIFT, y31 - SHIFT, x31 + SHIFT, y31 + SHIFT), cachedS);
if (cachedS.size() == 0) {
for (int k = 0; k < SHIFTS.length; k++) {
quadTree.queryInBox(new QuadRect(x31 - SHIFTS[k], y31 - SHIFTS[k], x31 + SHIFTS[k], y31 + SHIFTS[k]), cachedS);
// indexedPoints.getObjects(x31 - SHIFTS[k], y31 - SHIFTS[k], x31 + SHIFTS[k], y31 + SHIFTS[k],cachedS);
if (cachedS.size() != 0) {
break;
}
}
if (cachedS.size() == 0) {
return -1;
}
}
double minDist = 0;
for (int i = 0; i < cachedS.size(); i++) {
Integer n = cachedS.get(i);
double ds = BinaryRoutePlanner.squareRootDist(x31, y31, pointsX[n], pointsY[n]);
if (ds < minDist || i == 0) {
ind = n;
minDist = ds;
}
}
return ind;
}
use of net.osmand.data.QuadRect in project Osmand by osmandapp.
the class SearchPhrase method getRadiusBBoxToSearch.
public QuadRect getRadiusBBoxToSearch(int radius) {
int radiusInMeters = getRadiusSearch(radius);
QuadRect cache1kmRect = get1km31Rect();
if (cache1kmRect == null) {
return null;
}
int max = (1 << 31) - 1;
double dx = (cache1kmRect.width() / 2) * radiusInMeters / 1000;
double dy = (cache1kmRect.height() / 2) * radiusInMeters / 1000;
double topLeftX = Math.max(0, cache1kmRect.left - dx);
double topLeftY = Math.max(0, cache1kmRect.top - dy);
double bottomRightX = Math.min(max, cache1kmRect.right + dx);
double bottomRightY = Math.min(max, cache1kmRect.bottom + dy);
return new QuadRect(topLeftX, topLeftY, bottomRightX, bottomRightY);
}
use of net.osmand.data.QuadRect in project Osmand by osmandapp.
the class OsmandRegions method getCountries.
private List<BinaryMapDataObject> getCountries(int tile31x, int tile31y) {
HashSet<String> set = new HashSet<String>(quadTree.queryInBox(new QuadRect(tile31x, tile31y, tile31x, tile31y), new ArrayList<String>()));
List<BinaryMapDataObject> result = new ArrayList<BinaryMapDataObject>();
Iterator<String> it = set.iterator();
while (it.hasNext()) {
String cname = it.next();
BinaryMapDataObject container = null;
int count = 0;
for (BinaryMapDataObject bo : countriesByDownloadName.get(cname)) {
if (contain(bo, tile31x, tile31y)) {
count++;
container = bo;
break;
}
}
if (count % 2 == 1) {
result.add(container);
}
}
return result;
}
use of net.osmand.data.QuadRect in project Osmand by osmandapp.
the class Way method getLatLonBBox.
public QuadRect getLatLonBBox() {
QuadRect qr = null;
if (nodes != null) {
for (Node n : nodes) {
if (qr == null) {
qr = new QuadRect();
qr.left = (float) n.getLongitude();
qr.right = (float) n.getLongitude();
qr.top = (float) n.getLatitude();
qr.bottom = (float) n.getLatitude();
}
if (n.getLongitude() < qr.left) {
qr.left = (float) n.getLongitude();
} else if (n.getLongitude() > qr.right) {
qr.right = (float) n.getLongitude();
}
if (n.getLatitude() > qr.top) {
qr.top = (float) n.getLatitude();
} else if (n.getLatitude() < qr.bottom) {
qr.bottom = (float) n.getLatitude();
}
}
}
return qr;
}
use of net.osmand.data.QuadRect in project Osmand by osmandapp.
the class MapillaryVectorLayer method drawPoints.
protected void drawPoints(Canvas canvas, RotatedTileBox tileBox, int tileX, int tileY, GeometryTile tile, Map<QuadPointDouble, Map> visiblePoints) {
int dzoom = tileBox.getZoom() - TILE_ZOOM;
int mult = (int) Math.pow(2.0, dzoom);
QuadRect tileBounds = tileBox.getTileBounds();
double px, py, tx, ty;
float x, y;
float pw = point.getWidth();
float ph = point.getHeight();
float pwd = pw / 2;
float phd = ph / 2;
for (Geometry g : tile.getData()) {
if (g instanceof Point && !g.isEmpty() && g.getUserData() != null && g.getUserData() instanceof HashMap) {
Point p = (Point) g;
px = p.getCoordinate().x / EXTENT;
py = p.getCoordinate().y / EXTENT;
tx = (tileX + px) * mult;
ty = (tileY + py) * mult;
if (tileBounds.contains(tx, ty, tx, ty)) {
if (settings.USE_MAPILLARY_FILTER.get()) {
if (filtered(p.getUserData()))
continue;
}
x = tileBox.getPixXFromTile(tileX + px, tileY + py, TILE_ZOOM);
y = tileBox.getPixYFromTile(tileX + px, tileY + py, TILE_ZOOM);
canvas.drawBitmap(point, x - pwd, y - phd, paintPoint);
visiblePoints.put(new QuadPointDouble(tileX + px, tileY + py), (Map) p.getUserData());
}
}
}
}
Aggregations