Skip to content

Commit

Permalink
Merge pull request osmandapp#19797 from osmandapp/fix_19715_PT_Olimpi…
Browse files Browse the repository at this point in the history
…iska

 Add nearest stop for Olympiiska bus stop
  • Loading branch information
Chumva authored May 9, 2024
2 parents 6d8720e + 12e63ae commit 76c4d07
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
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

0 comments on commit 76c4d07

Please sign in to comment.