Skip to content

Commit

Permalink
Merge pull request #3607 from osmandapp/rzr-old-routing
Browse files Browse the repository at this point in the history
Replace HH-options with single one use_old_routing (r4.7)
  • Loading branch information
alex-osm authored Apr 18, 2024
2 parents 5419f75 + e8b62a1 commit 1ef8450
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 33 deletions.
3 changes: 1 addition & 2 deletions Resources/Localizations/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,7 @@
"osm_editing_settings_descr" = "This plugin's settings are global and apply to all profiles.";

"osmand_depelopment_simulate_location_section" = "Simulate";
"osmand_depelopment_use_special_routing_hh+old" = "Use special routing (HH + old)";
"osmand_depelopment_use_special_routing_hh_only" = "Use special routing (HH only)";
"osmand_depelopment_use_old_routing" = "Use old routing (A*)";
"osmand_depelopment_use_discrete_autozoom" = "Discrete autozoom (old version)";

"simulate_in_progress" = "In progress";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ @implementation OAOsmandDevelopmentViewController
NSString *const kDisableVertexHillshade = @"kDisableVertexHillshade";
NSString *const kGenerateHillshadeKey = @"kGenerateHillshadeKey";
NSString *const kGenerateSlopeKey = @"kGenerateSlopeKey";
NSString *const kUseHHRouting = @"kUseHHRouting";
NSString *const kUseHHRoutingOnly = @"kUseHHRoutingOnly";
NSString *const kUseOldRouting = @"kUseOldRouting";
NSString *const kUseV1AutoZoom = @"kUseV1AutoZoom";

#pragma mark - Initialization
Expand Down Expand Up @@ -97,15 +96,9 @@ - (void)generateData
}];
[simulationSection addRowFromDictionary:@{
kCellTypeKey : [OASwitchTableViewCell getCellIdentifier],
kCellKeyKey : kUseHHRouting,
kCellTitleKey : OALocalizedString(@"osmand_depelopment_use_special_routing_hh+old"),
@"isOn" : @([[OAAppSettings sharedManager].useHHRouting get])
}];
[simulationSection addRowFromDictionary:@{
kCellTypeKey : [OASwitchTableViewCell getCellIdentifier],
kCellKeyKey : kUseHHRoutingOnly,
kCellTitleKey : OALocalizedString(@"osmand_depelopment_use_special_routing_hh_only"),
@"isOn" : @([[OAAppSettings sharedManager].useHHRoutingOnly get])
kCellKeyKey : kUseOldRouting,
kCellTitleKey : OALocalizedString(@"osmand_depelopment_use_old_routing"),
@"isOn" : @([[OAAppSettings sharedManager].useOldRouting get])
}];
[_data addSection:simulationSection];

Expand Down Expand Up @@ -192,10 +185,8 @@ - (void)onSwitchPressed:(UISwitch *)sender
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:switchView.tag & 0x3FF inSection:switchView.tag >> 10];
OATableRowData *item = [_data itemForIndexPath:indexPath];

if ([item.key isEqualToString:kUseHHRouting])
[[OAAppSettings sharedManager].useHHRouting set:sender.isOn];
else if ([item.key isEqualToString:kUseHHRoutingOnly])
[[OAAppSettings sharedManager].useHHRoutingOnly set:sender.isOn];
if ([item.key isEqualToString:kUseOldRouting])
[[OAAppSettings sharedManager].useOldRouting set:sender.isOn];
else if ([item.key isEqualToString:kUseV1AutoZoom])
[[OAAppSettings sharedManager].useV1AutoZoom set:sender.isOn];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ - (instancetype)init
- (BOOL)checkIfThereAreMissingMapsWithStart:(CLLocation *)start
targets:(NSArray<CLLocation *> *)targets
{
bool hhRoutingOnly = [[OAAppSettings sharedManager].useHHRoutingOnly get];
bool hhRouting = [[OAAppSettings sharedManager].useHHRouting get];
return [self checkIfThereAreMissingMaps:_ctx start:start targets:targets checkHHEditions:hhRoutingOnly || hhRouting];
bool oldRouting = [[OAAppSettings sharedManager].useOldRouting get];
return [self checkIfThereAreMissingMaps:_ctx start:start targets:targets checkHHEditions:!oldRouting];
}

- (BOOL)checkIfThereAreMissingMaps:(std::shared_ptr<RoutingContext>)ctx
Expand Down
3 changes: 1 addition & 2 deletions Sources/Helpers/OAAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,7 @@ typedef NS_ENUM(NSInteger, EOARateUsState)
@property (nonatomic) OACommonString *userUUID;
@property (nonatomic) OACommonLong *lastUUIDChangeTimestamp;

@property (nonatomic) OACommonBoolean *useHHRouting;
@property (nonatomic) OACommonBoolean *useHHRoutingOnly;
@property (nonatomic) OACommonBoolean *useOldRouting;

- (long) getLastGloblalSettingsModifiedTime;
- (void) setLastGlobalModifiedTime:(long)timestamp;
Expand Down
9 changes: 3 additions & 6 deletions Sources/Helpers/OAAppSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@
static NSString * const topWidgetPanelOrderOldKey = @"top_widget_panel_order";
static NSString * const bottomWidgetPanelOrderKeyOld = @"bottom_widget_panel_order";

static NSString * const useHHRoutingKey = @"useHHRoutingKey";
static NSString * const useHHRoutingOnlyKey = @"useHHRoutingOnlyKey";
static NSString * const useOldRoutingKey = @"useOldRoutingKey";

@implementation OACompassMode

Expand Down Expand Up @@ -4741,10 +4740,8 @@ - (instancetype) init
_mapScreenOrientation = [OACommonInteger withKey:mapScreenOrientationKey defValue:EOAScreenOrientationSystem];
[_profilePreferences setObject:_mapScreenOrientation forKey:@"map_screen_orientation"];

_useHHRouting = [[[OACommonBoolean withKey:useHHRoutingKey defValue:NO] makeGlobal] makeShared];
[_globalPreferences setObject:_useHHRouting forKey:@"use_hh_routing"];
_useHHRoutingOnly = [[[OACommonBoolean withKey:useHHRoutingOnlyKey defValue:NO] makeGlobal] makeShared];
[_globalPreferences setObject:_useHHRouting forKey:@"use_hh_routing_only"];
_useOldRouting = [[[OACommonBoolean withKey:useOldRoutingKey defValue:NO] makeGlobal] makeShared];
[_globalPreferences setObject:_useOldRouting forKey:@"use_old_routing"];

[self fetchImpassableRoads];

Expand Down
9 changes: 4 additions & 5 deletions Sources/Router/OARouteProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -852,12 +852,11 @@ - (OARouteCalculationResult *) calcOfflineRouteImpl:(OARouteCalculationParams *)
intY.push_back(get31TileNumberY(l.coordinate.latitude));
}

bool hhRoutingOnly = [[OAAppSettings sharedManager].useHHRoutingOnly get];
bool hhRouting = [[OAAppSettings sharedManager].useHHRouting get];
if (hhRouting || hhRoutingOnly)
bool oldRouting = [[OAAppSettings sharedManager].useOldRouting get];
if (!oldRouting)
{
router->setDefaultRoutingConfig();
router->USE_ONLY_HH_ROUTING = hhRoutingOnly;
// router->USE_ONLY_HH_ROUTING = hhRoutingOnly; // set true to debug HH routing
}

if (router->CALCULATE_MISSING_MAPS)
Expand All @@ -867,7 +866,7 @@ - (OARouteCalculationResult *) calcOfflineRouteImpl:(OARouteCalculationParams *)
_missingMapsCalculator = [MissingMapsCalculator new];
}
NSArray<CLLocation *> *targets = (inters.count > 0) ? [inters arrayByAddingObject:en] : @[en];
if ([_missingMapsCalculator checkIfThereAreMissingMaps:ctx start:st targets:targets checkHHEditions:hhRouting || hhRoutingOnly])
if ([_missingMapsCalculator checkIfThereAreMissingMaps:ctx start:st targets:targets checkHHEditions:!oldRouting])
{
OARouteCalculationResult *r = [[OARouteCalculationResult alloc] initWithErrorMessage:[_missingMapsCalculator getErrorMessage]];
r.missingMaps = _missingMapsCalculator.missingMaps;
Expand Down

0 comments on commit 1ef8450

Please sign in to comment.