diff --git a/Sources/Controllers/TargetMenu/OATransportStopsBaseController.mm b/Sources/Controllers/TargetMenu/OATransportStopsBaseController.mm index 9df413e5a7..5eda9d909d 100644 --- a/Sources/Controllers/TargetMenu/OATransportStopsBaseController.mm +++ b/Sources/Controllers/TargetMenu/OATransportStopsBaseController.mm @@ -206,12 +206,12 @@ - (OATransportStop *) findNearestTransportStopForAmenity:(OAPOI *)amenity NSString *stopName = [[stop name] lowercaseString]; auto dist = OsmAnd::Utilities::distance(stop.longitude, stop.latitude, lon, lat); - if (([stopName containsString:amenityName] || [amenityName containsString:stopName]) + if ((([stopName containsString:amenityName] || [amenityName containsString:stopName]) && dist < MAX_DISTANCE_BETWEEN_AMENITY_AND_LOCAL_STOPS && (!nearestStop - || [OAUtilities isCoordEqual:[nearestStop getLocation].coordinate destLat:[stop getLocation].coordinate] - || [OAUtilities isCoordEqual:[stop getLocation].coordinate destLat:CLLocationCoordinate2DMake(lat, lon)]) - ) + || [OAUtilities isCoordEqual:[nearestStop getLocation].coordinate destLat:[stop getLocation].coordinate])) + || [OAUtilities isCoordEqual:[stop getLocation].coordinate destLat:CLLocationCoordinate2DMake(lat, lon)] + || [stop isConnectedToStop:amenity.obfId]) { [stopAggregated addLocalTransportStop:stop]; if (!nearestStop) diff --git a/Sources/Transport/OATransportStop.h b/Sources/Transport/OATransportStop.h index c6a33c7af5..8a594e92c3 100644 --- a/Sources/Transport/OATransportStop.h +++ b/Sources/Transport/OATransportStop.h @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)findAmenityDataIfNeeded; - (NSString *)getStopObjectName:(NSString *)lang transliterate:(BOOL)transliterate; +- (BOOL)isConnectedToStop:(uint64_t)stopId; @end diff --git a/Sources/Transport/OATransportStop.mm b/Sources/Transport/OATransportStop.mm index 2ee96d90fe..c1328fbb9e 100644 --- a/Sources/Transport/OATransportStop.mm +++ b/Sources/Transport/OATransportStop.mm @@ -15,10 +15,13 @@ #include #include +#include #include #include #include +static NSString *CONNECTED_STOP_IDS = @"osmand:connected_stop_ids"; + @interface OATransportStop() @@ -35,6 +38,7 @@ @implementation OATransportStop - (instancetype)initWithStop:(std::shared_ptr)stop { + self = [super init]; if (self) { _stop = stop; @@ -46,6 +50,10 @@ - (instancetype)initWithStop:(std::shared_ptr)stop self.latitude = stop->location.latitude; self.longitude = stop->location.longitude; self.stopId = stop->id.id; + for (const auto& entry : OsmAnd::rangeOf(OsmAnd::constOf(stop->localizedNames))) + { + self.localizedNames[entry.key().toNSString()] = entry.value().toNSString(); + } NSMutableArray *extiLocations = [NSMutableArray new]; const auto stopExits = stop->exits; @@ -114,6 +122,21 @@ - (NSString *)getStopObjectName:(NSString *)lang transliterate:(BOOL)translitera return qName.toNSString(); } +- (BOOL)isConnectedToStop:(uint64_t)stopId +{ + NSString *connectedStopIds = self.localizedNames[CONNECTED_STOP_IDS]; + if (connectedStopIds) + { + NSString *idString = [@(stopId) stringValue]; + for (NSString *connectedStopId in [connectedStopIds componentsSeparatedByString:@","]) + { + if ([idString isEqualToString:connectedStopId]) + return YES; + } + } + return NO; +} + - (BOOL)isEqual:(OATransportStop *)object { if (self == object)