use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.
the class TransportStopController method addRoutes.
private void addRoutes(List<TransportStopRoute> routes, boolean useEnglishNames, TransportIndexRepository t, TransportStop s, TransportStop refStop, int dist) {
Collection<TransportRoute> rts = t.getRouteForStop(s);
if (rts != null) {
for (TransportRoute rs : rts) {
TransportStopType type = TransportStopType.findType(rs.getType());
if (topType == null && type != null && type.isTopType()) {
topType = type;
}
if (!containsRef(routes, rs)) {
TransportStopRoute r = new TransportStopRoute();
r.type = type;
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
r.route = rs;
r.refStop = refStop;
r.stop = s;
r.distance = dist;
routes.add(r);
}
}
}
}
use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.
the class AmenityMenuController method addRoutes.
private void addRoutes(boolean useEnglishNames, TransportIndexRepository t, TransportStop s, int dist, boolean isSubwayEntrance) {
Collection<TransportRoute> rts = t.getRouteForStop(s);
if (rts != null) {
for (TransportRoute rs : rts) {
if (!containsRef(rs)) {
TransportStopType type = TransportStopType.findType(rs.getType());
if (isSubwayEntrance && type != TransportStopType.SUBWAY && dist > 150) {
continue;
}
TransportStopRoute r = new TransportStopRoute();
r.type = type;
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
r.route = rs;
r.stop = s;
r.distance = dist;
this.routes.add(r);
}
}
}
}
use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.
the class AmenityMenuController method processTransportStop.
private void processTransportStop() {
routes = new ArrayList<>();
List<TransportIndexRepository> reps = getMapActivity().getMyApplication().getResourceManager().searchTransportRepositories(amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude());
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
boolean isSubwayEntrance = amenity.getSubType().equals("subway_entrance");
for (TransportIndexRepository t : reps) {
ArrayList<TransportStop> ls = new ArrayList<>();
QuadRect ll = MapUtils.calculateLatLonBbox(amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), isSubwayEntrance ? 400 : 150);
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
for (TransportStop tstop : ls) {
addRoutes(useEnglishNames, t, tstop, (int) MapUtils.getDistance(tstop.getLocation(), amenity.getLocation()), isSubwayEntrance);
}
}
Collections.sort(routes, new Comparator<TransportStopRoute>() {
@Override
public int compare(TransportStopRoute o1, TransportStopRoute o2) {
if (o1.distance != o2.distance) {
return Algorithms.compare(o1.distance, o2.distance);
}
int i1 = Algorithms.extractFirstIntegerNumber(o1.desc);
int i2 = Algorithms.extractFirstIntegerNumber(o2.desc);
if (i1 != i2) {
return Algorithms.compare(i1, i2);
}
return o1.desc.compareTo(o2.desc);
}
});
builder.setRoutes(routes);
}
use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.
the class TransportStopController method processTransportStop.
public List<TransportStopRoute> processTransportStop() {
ArrayList<TransportStopRoute> routes = new ArrayList<>();
List<TransportIndexRepository> reps = getMapActivity().getMyApplication().getResourceManager().searchTransportRepositories(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude());
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
for (TransportIndexRepository t : reps) {
if (t.acceptTransportStop(transportStop)) {
boolean empty = transportStop.getReferencesToRoutes() == null || transportStop.getReferencesToRoutes().length == 0;
if (!empty) {
addRoutes(routes, useEnglishNames, t, transportStop, transportStop, 0);
}
ArrayList<TransportStop> ls = new ArrayList<>();
QuadRect ll = MapUtils.calculateLatLonBbox(transportStop.getLocation().getLatitude(), transportStop.getLocation().getLongitude(), SHOW_STOPS_RADIUS_METERS);
t.searchTransportStops(ll.top, ll.left, ll.bottom, ll.right, -1, ls, null);
for (TransportStop tstop : ls) {
if (tstop.getId().longValue() != transportStop.getId().longValue() || empty) {
addRoutes(routes, useEnglishNames, t, tstop, transportStop, (int) MapUtils.getDistance(tstop.getLocation(), transportStop.getLocation()));
}
}
}
}
Collections.sort(routes, new Comparator<TransportStopRoute>() {
@Override
public int compare(TransportStopRoute o1, TransportStopRoute o2) {
if (o1.distance != o2.distance) {
return Algorithms.compare(o1.distance, o2.distance);
}
int i1 = Algorithms.extractFirstIntegerNumber(o1.desc);
int i2 = Algorithms.extractFirstIntegerNumber(o2.desc);
if (i1 != i2) {
return Algorithms.compare(i1, i2);
}
return o1.desc.compareTo(o2.desc);
}
});
return routes;
}
use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.
the class MapContextMenuFragment method createTransportStopRouteAdapter.
private TransportStopRouteAdapter createTransportStopRouteAdapter(List<TransportStopRoute> routes) {
final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), routes, nightMode);
adapter.setListener(new TransportStopRouteAdapter.OnClickListener() {
@Override
public void onClick(int position) {
TransportStopRoute route = adapter.getItem(position);
if (route != null) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, route.getDescription(getMapActivity().getMyApplication(), false));
menu.show(menu.getLatLon(), pd, route);
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(route);
int cz = route.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
}
}
});
return adapter;
}
Aggregations