-
Notifications
You must be signed in to change notification settings - Fork 99
Refactor map objects selecting #4611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
||
- (NSString *) getGpxFileName; | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use macros in .h files
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- (NSString *)getGpxFileName;
|
||
- (void) commonInit | ||
{ | ||
_clickableTags = [NSSet setWithObjects:@"piste:type", @"piste:difficulty", @"mtb:scale", @"dirtbike:scale", nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[NSSet setWithArray:@[
@"piste:type",
@"piste:difficulty",
@"mtb:scale",
@"dirtbike:scale"
]];
- (void) commonInit | ||
{ | ||
_clickableTags = [NSSet setWithObjects:@"piste:type", @"piste:difficulty", @"mtb:scale", @"dirtbike:scale", nil]; | ||
_requiredTagsAny = [NSSet setWithObjects:@"name", @"ref", @"piste:name", @"mtb:name", nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
|
||
- (BOOL) isClickableWayTags:(NSDictionary<NSString *, NSString *> *)tags | ||
{ | ||
for (NSString *forbiddenKey in _forbiddenTags.allKeys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for-in loop over an NSDictionary iterates directly over its keys, similar to using allKeys, but more efficient because it avoids creating an intermediate array
{ | ||
for (NSString *forbiddenKey in _forbiddenTags.allKeys) | ||
{ | ||
NSString *forbiddenValue = _forbiddenTags[forbiddenKey]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add NSString *tagValue = tags[forbiddenKey];
travelGpx.file = file | ||
|
||
//TODO: delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: delete
@@ -2771,6 +2794,29 @@ + (NSString *) createNewFileName:(NSString *)oldName | |||
return newName; | |||
} | |||
|
|||
+ (NSString *) simplifyFileName:(NSString *)filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add example
Sources/POI/OAPOI.mm
Outdated
[supported addObjectsFromArray:[self getNames:CONTENT_TAG defTag:@"en"]]; | ||
[supported addObjectsFromArray:[self getNames:DESCRIPTION_TAG defTag:@"en"]]; | ||
[supported addObjectsFromArray:[self getNames:@"wiki_lang" defTag:@"en"]]; | ||
return supported; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[locales copy]; ?
Sources/POI/OAPOI.mm
Outdated
- (NSArray<NSString *> *) getAdditionalInfoKeys | ||
{ | ||
NSDictionary<NSString *, NSString *> *info = [self getAdditionalInfo]; | ||
return info == nil ? @[] : [info allKeys]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return info ? info.allKeys : @[];
Sources/POI/OAPOI.mm
Outdated
@@ -339,6 +412,67 @@ - (NSString *)getAdditionalInfo:(NSString *)key | |||
return [_values objectForKey:key]; | |||
} | |||
|
|||
- (NSMutableDictionary<NSString *, NSString *> *)getInternalAdditionalInfoMap | |||
{ | |||
return _values ? _values : [NSMutableDictionary new]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return _values ?: [NSMutableDictionary dictionary];
@@ -405,9 +405,9 @@ - (BOOL) isUniqueTravelGpx:(NSMutableArray<OASelectedMapObject *> *)selectedObje | |||
[selectedObject.provider isKindOfClass:OAGPXLayer.class]) | |||
{ | |||
NSArray *pair = (NSArray *)selectedObject.object; | |||
if ([pair[0] isKindOfClass:OATravelGpx.class]) | |||
if ([pair firstObject] && [[pair firstObject] isKindOfClass:OATravelGpx.class]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to extract [pair firstObject] into a let variable. Also, checking with if ([yourLet isKindOfClass:OATravelGpx.class]) {} is sufficient.
if ([obj isKindOfClass:OAOnlineOsmNoteWrapper.class]) | ||
{ | ||
OAOnlineOsmNoteWrapper *note = (OAOnlineOsmNoteWrapper *)obj; | ||
NSString *name = note.description ? note.description : @""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?: @"";
{ | ||
OAOnlineOsmNoteWrapper *note = (OAOnlineOsmNoteWrapper *)obj; | ||
NSString *name = note.description ? note.description : @""; | ||
NSString *typeName = note.typeName ? note.typeName : OALocalizedString(@"osn_bug_name"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
} | ||
|
||
let shortLinkTiles = amenity.getTagContent(TravelGpx.ROUTE_SHORTLINK_TILES) | ||
if let shortLinkTiles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let shortLinkTiles = amenity.getTagContent(TravelGpx.ROUTE_SHORTLINK_TILES) {}
} | ||
|
||
if activityType == nil || activityType!.isEmpty { | ||
for key in amenity.getAdditionalInfoKeys() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where key.hasPrefix(Self.ROUTE_ACTIVITY_TYPE)
|
||
|
||
func isTravelGpxTags(_ tags: [String: String]) -> Bool { | ||
return tags[ROUTE_ID] != nil && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove return
Sources/Helpers/OAUtilities.m
Outdated
@@ -175,6 +175,15 @@ - (void) rLineToX:(CGFloat)x y:(CGFloat)y | |||
|
|||
@end | |||
|
|||
@implementation NSArray (util) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- (BOOL)isEmpty {
return !array || array.count == 0;
}
if ([myArray isEmpty]) {
// ...
}
Sources/Helpers/OAUtilities.m
Outdated
|
||
+ (BOOL)isEmpty:(NSDictionary *)dictionary | ||
{ | ||
return !dictionary || dictionary.count == 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
Sources/Helpers/OAUtilities.m
Outdated
@@ -495,6 +513,11 @@ - (void) setMinLineHeight:(CGFloat)height alignment:(NSTextAlignment)alignment f | |||
|
|||
@implementation NSString (util) | |||
|
|||
+ (BOOL)isEmpty:(NSString *)string | |||
{ | |||
return !string || string.length == 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
@@ -0,0 +1,38 @@ | |||
// | |||
// OAPlaceDetailsObject.h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It became BaseDetailsObject in java recently altogether with some code refactoring. So looks like new changes in Android code should be reviewed and introduced in iOS.
issue
skipped for now:
TravelGpx
ClickableWay