Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nearest stop for Olympiiska bus stop #19797

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ private void updateNearbyRoutesBadges(int maxLocalRows, List<TransportStopRoute>
boolean moreLocalItems = localRoutesMoreTv.getVisibility() == View.VISIBLE;
if (maxLocalRows <= 5 && !moreLocalItems && nearbyRoutesSize > 0) {
String nearInDistance = getString(R.string.transport_nearby_routes) + " "
+ OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, app) + ":";
+ OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS_UI, app) + ":";
nearbyRoutesWithinTv.setText(nearInDistance);
int minBadgeWidth = getMinBadgeWidth(nearbyTransportStopRoutes);
int nearbyColumnsPerRow = getRoutesBadgesColumnsPerRow(nearInDistance, minBadgeWidth);
Expand Down
2 changes: 1 addition & 1 deletion OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ protected void buildTopInternal(View view) {
}
if (showNearbyTransportRoutes()) {
CollapsableView collapsableView = getCollapsableTransportStopRoutesView(view.getContext(), false, true);
String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, app);
String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS_UI, app);
buildRow(view, 0, null, routesWithingDistance, 0, true, collapsableView,
false, 0, false, null, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@

public class TransportStopController extends MenuController {

public static final int SHOW_STOPS_RADIUS_METERS = 150;
public static final int SHOW_STOPS_RADIUS_METERS_UI = 150;
public static final int SHOW_STOPS_RADIUS_METERS = SHOW_STOPS_RADIUS_METERS_UI * 6 / 5;
public static final int SHOW_SUBWAY_STOPS_FROM_ENTRANCES_RADIUS_METERS = 400;
public static final int MAX_DISTANCE_BETWEEN_AMENITY_AND_LOCAL_STOPS = 20;

private TransportStop transportStop;
private final List<TransportStopRoute> routesNearby = new ArrayList<>();
private final List<TransportStopRoute> routesOnTheSameExit = new ArrayList<>();
private TransportStopType topType;

public TransportStopController(@NonNull MapActivity mapActivity,
@NonNull PointDescription pointDescription,
@NonNull TransportStop transportStop) {
@NonNull PointDescription pointDescription,
@NonNull TransportStop transportStop) {
super(new TransportStopMenuBuilder(mapActivity, transportStop), pointDescription, mapActivity);
this.transportStop = transportStop;
processRoutes();
Expand Down Expand Up @@ -100,7 +102,12 @@ public boolean displayDistanceDirection() {
@NonNull
@Override
public String getNameStr() {
return transportStop.getName(getPreferredMapLang(), isTransliterateNames());
Amenity amenity = transportStop.getAmenity();
if (amenity == null) {
return transportStop.getName(getPreferredMapLang(), isTransliterateNames());
} else {
return amenity.getName(getPreferredMapLang(), isTransliterateNames());
}
}

@NonNull
Expand Down Expand Up @@ -131,9 +138,11 @@ private void processTransportStop(List<TransportStopRoute> routesOnTheSameExit,
ArrayList<TransportStop> nearbyTransportStops = new ArrayList<>(transportStop.getNearbyTransportStops());

addTransportStopRoutes(app, transportStopsSameExit, routesOnTheSameExit, useEnglishNames);
addTransportStopRoutes(app, nearbyTransportStops, routesNearby, useEnglishNames);

sortTransportStopRoutes(routesOnTheSameExit);
if (topType == null && !Algorithms.isEmpty(routesOnTheSameExit)) {
topType = routesOnTheSameExit.get(0).type;
}
addTransportStopRoutes(app, nearbyTransportStops, routesNearby, useEnglishNames);
sortTransportStopRoutes(routesNearby);
}
}
Expand Down Expand Up @@ -256,6 +265,7 @@ public static TransportStop findBestTransportStopForAmenity(OsmandApplication ap
stop.setTransportStopAggregated(stopAggregated);
String stopName = stop.getName().toLowerCase();
if (((stopName.contains(amenityName) || amenityName.contains(stopName))
&& MapUtils.getDistance(stop.getLocation(), loc) < MAX_DISTANCE_BETWEEN_AMENITY_AND_LOCAL_STOPS
&& (nearestStop == null
|| nearestStop.getLocation().equals(stop.getLocation())))
|| stop.getLocation().equals(loc)) {
Expand Down
Loading