use of net.osmand.data.TransportStop in project Osmand by osmandapp.
the class TransportStopsLayer method getFromPoint.
public void getFromPoint(RotatedTileBox tb, PointF point, List<? super TransportStop> res, List<TransportStop> objects) {
int ex = (int) point.x;
int ey = (int) point.y;
final int rp = getRadiusPoi(tb);
int radius = rp * 3 / 2;
try {
TreeSet<String> ms = new TreeSet<>();
for (int i = 0; i < objects.size(); i++) {
TransportStop n = objects.get(i);
if (n.getLocation() == null) {
continue;
}
int x = (int) tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
if (!ms.add(n.getName())) {
// only unique names
continue;
}
radius = rp;
res.add(n);
}
}
} catch (IndexOutOfBoundsException e) {
// that's really rare case, but is much efficient than introduce synchronized block
}
}
use of net.osmand.data.TransportStop in project Osmand by osmandapp.
the class TransportStopRoute method calculateZoom.
public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) {
RotatedTileBox cp = currentRotatedTileBox.copy();
boolean notContains = true;
while (cp.getZoom() > 12 && notContains) {
notContains = false;
List<TransportStop> sts = route.getForwardStops();
for (int i = startPosition; i < sts.size(); i++) {
TransportStop st = sts.get(startPosition);
if (!cp.containsLatLon(st.getLocation())) {
notContains = true;
break;
}
}
cp.setZoom(cp.getZoom() - 1);
}
return cp.getZoom();
}
Aggregations