-
Notifications
You must be signed in to change notification settings - Fork 1
/
FT2GMapsLeg.m
45 lines (37 loc) · 1.28 KB
/
FT2GMapsLeg.m
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
//
// FT2GMapsLeg.m
// Mercedes Map Test
//
// Created by Baldoph Pourprix on 10/04/2013.
// Copyright (c) 2013 Fuerte Int. All rights reserved.
//
#import "FT2GMapsLeg.h"
#import "FT2GMapsLocation.h"
#import "FT2GMapsHelper.h"
#import "FT2GMapsStep.h"
@implementation FT2GMapsLeg
- (id)initWithDictionary:(NSDictionary *)dict
{
self = [super init];
if (self) {
_distanceString = dict[@"distance"][@"text"];
_distanceMeters = [dict[@"distance"][@"value"] integerValue];
_durationString = dict[@"duration"][@"text"];
_durationSeconds = [dict[@"duration"][@"value"] integerValue];
_startLocation = [[FT2GMapsLocation alloc] init];
_startLocation.address = dict[@"start_address"];
_startLocation.coordinates = coordinatesForDictionary(dict[@"start_location"]);
_endLocation = [[FT2GMapsLocation alloc] init];
_endLocation.address = dict[@"end_address"];
_endLocation.coordinates = coordinatesForDictionary(dict[@"end_location"]);
NSMutableArray *steps = [NSMutableArray new];
NSArray *stepsArray = dict[@"steps"];
[stepsArray enumerateObjectsUsingBlock:^(NSDictionary *stepDict, NSUInteger idx, BOOL *stop) {
FT2GMapsStep *step = [[FT2GMapsStep alloc] initWithDictionary:stepDict];
[steps addObject:step];
}];
_steps = steps.copy;
}
return self;
}
@end