From 18086bc362f573938d43dcff98e5650c51949408 Mon Sep 17 00:00:00 2001 From: Aleksandr Panchenko Date: Mon, 12 Aug 2024 14:17:35 +0300 Subject: [PATCH 1/3] fix instructionVariants --- .../CarPlay/OACarPlayDashboardInterfaceController.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm b/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm index 4e1fddd53e..1346412902 100644 --- a/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm +++ b/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm @@ -577,9 +577,15 @@ - (CPManeuver *)createTurnManeuver:(CPTravelEstimates *)estimates directionInfo: NSString *streetName = directionInfo.directionInfo.streetName; 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; From 8cbee1b9fdb07bfcb363497b1c0ebc3f439e4ef6 Mon Sep 17 00:00:00 2001 From: Aleksandr Panchenko Date: Mon, 12 Aug 2024 18:12:03 +0300 Subject: [PATCH 2/3] add defineStreetName --- .../OACarPlayDashboardInterfaceController.mm | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm b/Sources/CarPlay/OACarPlayDashboardInterfaceController.mm index 1346412902..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,7 +575,8 @@ - (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) { if (estimates) { @@ -591,6 +593,25 @@ - (CPManeuver *)createTurnManeuver:(CPTravelEstimates *)estimates directionInfo: 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 From 1edd8ac4ce60fe342fad0b29b4d06648f33f598b Mon Sep 17 00:00:00 2001 From: Aleksandr Panchenko Date: Tue, 13 Aug 2024 09:19:32 +0300 Subject: [PATCH 3/3] remove unused code --- Sources/Controllers/Map/Widgets/OACurrentStreetName.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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;