summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLSendLocation.m
blob: 211ce2e96cf57638ea382e449b01f9ba7562425b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
//  SDLSendLocation.m
//  SmartDeviceLink

#import "SDLSendLocation.h"

#import "SDLNames.h"


@implementation SDLSendLocation

- (instancetype)init {
    self = [super initWithName:NAMES_SendLocation];
    if (!self) {
        return nil;
    }

    return self;
}

- (instancetype)initWithDictionary:(NSMutableDictionary *)dict {
    self = [super initWithDictionary:dict];
    if (!self) {
        return nil;
    }

    return self;
}

- (instancetype)initWithLongitude:(CGFloat)longitude latitude:(CGFloat)latitude locationName:(NSString *)locationName locationDescription:(NSString *)locationDescription address:(NSArray *)address phoneNumber:(NSString *)phoneNumber image:(SDLImage *)image {
    self = [self init];
    if (!self) {
        return nil;
    }
    
    self.longitudeDegrees = @(longitude);
    self.latitudeDegrees = @(latitude);
    self.locationName = locationName;
    self.locationDescription = locationDescription;
    self.addressLines = address;
    self.phoneNumber = phoneNumber;
    self.locationImage = image;
    
    return self;
}

- (void)setLongitudeDegrees:(NSNumber *)longitudeDegrees {
    if (longitudeDegrees != nil) {
        parameters[NAMES_longitudeDegrees] = longitudeDegrees;
    } else {
        [parameters removeObjectForKey:NAMES_longitudeDegrees];
    }
}

- (NSNumber *)longitudeDegrees {
    return parameters[NAMES_longitudeDegrees];
}

- (void)setLatitudeDegrees:(NSNumber *)latitudeDegrees {
    if (latitudeDegrees != nil) {
        parameters[NAMES_latitudeDegrees] = latitudeDegrees;
    } else {
        [parameters removeObjectForKey:NAMES_latitudeDegrees];
    }
}

- (NSNumber *)latitudeDegrees {
    return parameters[NAMES_latitudeDegrees];
}

- (void)setLocationName:(NSString *)locationName {
    if (locationName != nil) {
        parameters[NAMES_locationName] = locationName;
    } else {
        [parameters removeObjectForKey:NAMES_locationName];
    }
}

- (NSString *)locationName {
    return parameters[NAMES_locationName];
}

- (void)setAddressLines:(NSArray *)addressLines {
    if (addressLines != nil) {
        parameters[NAMES_addressLines] = addressLines;
    } else {
        [parameters removeObjectForKey:NAMES_addressLines];
    }
}

- (NSString *)locationDescription {
    return parameters[NAMES_locationDescription];
}

- (void)setLocationDescription:(NSString *)locationDescription {
    if (locationDescription != nil) {
        parameters[NAMES_locationDescription] = locationDescription;
    } else {
        [parameters removeObjectForKey:NAMES_locationDescription];
    }
}

- (NSArray *)addressLines {
    return parameters[NAMES_addressLines];
}

- (void)setPhoneNumber:(NSString *)phoneNumber {
    if (phoneNumber != nil) {
        parameters[NAMES_phoneNumber] = phoneNumber;
    } else {
        [parameters removeObjectForKey:NAMES_phoneNumber];
    }
}

- (NSString *)phoneNumber {
    return parameters[NAMES_phoneNumber];
}

- (void)setLocationImage:(SDLImage *)locationImage {
    if (locationImage != nil) {
        parameters[NAMES_locationImage] = locationImage;
    } else {
        [parameters removeObjectForKey:NAMES_locationImage];
    }
}

- (SDLImage *)locationImage {
    id obj = parameters[NAMES_locationImage];
    if (obj == nil || [obj isKindOfClass:[SDLImage class]]) {
        return (SDLImage *)obj;
    } else {
        return [[SDLImage alloc] initWithDictionary:obj];
    }
}

@end