diff --git a/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm b/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm index 4e1fddd53e..ff4ad5f561 100644 --- a/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm +++ b/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm @@ -33,6 +33,7 @@ #import "OATurnDrawable.h" #import "OATurnDrawable+cpp.h" #import "OAMapButtonsHelper.h" +#import "OACurrentStreetName.h" #import "OsmAnd_Maps-Swift.h" #define unitsKm OALocalizedString(@"km") @@ -574,17 +575,43 @@ - (CPManeuver *)createTurnManeuver:(CPTravelEstimates *)estimates directionInfo: maneuver.symbolImage = [turnDrawable toUIImage]; maneuver.initialTravelEstimates = estimates; maneuver.userInfo = @{ @"imminent" : @(directionInfo.imminent) }; - NSString *streetName = directionInfo.directionInfo.streetName; + NSString *streetName = [self defineStreetName:directionInfo]; + if (streetName) { - NSString *distanceString = [OAOsmAndFormatter getFormattedDistance:directionInfo.distanceTo withParams:[OsmAndFormatterParams useLowerBounds]]; - NSString *instruction = [NSString stringWithFormat:@"%@, %@", distanceString, streetName]; - maneuver.instructionVariants = @[instruction]; + if (estimates) { + maneuver.instructionVariants = @[streetName]; + } + else + { + NSString *distanceString = [OAOsmAndFormatter getFormattedDistance:directionInfo.distanceTo withParams:[OsmAndFormatterParams useLowerBounds]]; + NSString *instruction = [NSString stringWithFormat:@"%@, %@", distanceString, streetName]; + maneuver.instructionVariants = @[instruction]; + } } return maneuver; } +- (nullable NSString *)defineStreetName:(nullable OANextDirectionInfo *)nextDirInfo { + if (nextDirInfo) + { + OACurrentStreetName *currentStreetName = [_routingHelper getCurrentName:nextDirInfo]; + NSString *streetName = currentStreetName.text; + + if (streetName.length > 0) + { + NSString *exitRef = currentStreetName.exitRef; + if (exitRef.length == 0) { + return streetName; + } else { + return [NSString stringWithFormat:OALocalizedString(@"ltr_or_rtl_combine_via_comma"), exitRef, streetName]; + } + } + } + return nil; +} + // MARK: Location updates - (void) onLocationUpdate diff --git a/Sources/Controllers/Map/Widgets/OACurrentStreetName.mm b/Sources/Controllers/Map/Widgets/OACurrentStreetName.mm index 6fad75cb60..418bebe166 100644 --- a/Sources/Controllers/Map/Widgets/OACurrentStreetName.mm +++ b/Sources/Controllers/Map/Widgets/OACurrentStreetName.mm @@ -38,7 +38,6 @@ + (NSString *) getRouteSegmentStreetName:(std::shared_ptr &) + (OACurrentStreetName *) getCurrentName:(OANextDirectionInfo *)n { OARoutingHelper *routingHelper = OARoutingHelper.sharedInstance; - OAVoiceRouter *voiceRouter = routingHelper.getVoiceRouter; OACurrentStreetName *streetName = [[OACurrentStreetName alloc] init]; CLLocation *l = routingHelper.getLastFixedLocation; OAAnnounceTimeDistances *adt = [[routingHelper getVoiceRouter] getAnnounceTimeDistances]; @@ -47,7 +46,7 @@ + (OACurrentStreetName *) getCurrentName:(OANextDirectionInfo *)n if (l && l.speed >=0) speed = l.speed; // 1. turn is imminent - if (n.distanceTo > 0 && n.directionInfo && !n.directionInfo.turnType->isSkipToSpeak() && + if (n.distanceTo > 0 && n.directionInfo && !n.directionInfo.turnType->isSkipToSpeak() && [adt isTurnStateActive:[adt getSpeed:l] dist:n.distanceTo * 1.3 turnType:kStatePrepareTurn]) { NSString *nm = n.directionInfo.streetName;