Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MWMNavigationDashboardEntity.mm « NavigationDashboard « CustomViews « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3d2aa71e09dca946b61bf756b832099afa2d52d3 (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
#import "Common.h"
#import "MapsAppDelegate.h"
#import "MWMLocationManager.h"
#import "MWMNavigationDashboardEntity.h"

#include "Framework.h"
#include "geometry/distance_on_sphere.hpp"
#include "platform/measurement_utils.hpp"

using namespace routing::turns;

@implementation MWMNavigationDashboardEntity

- (void)updateWithFollowingInfo:(location::FollowingInfo const &)info
{
  [self configure:info];
}

- (void)configure:(location::FollowingInfo const &)info
{
  _timeToTarget = info.m_time;
  _targetDistance = @(info.m_distToTarget.c_str());
  _targetUnits = @(info.m_targetUnitsSuffix.c_str());
  _progress = info.m_completionPercent;
  auto & f = GetFramework();
  CLLocation * lastLocation = [MWMLocationManager lastLocation];
  if (lastLocation && f.GetRouter() == routing::RouterType::Pedestrian)
  {
    _isPedestrian = YES;
    string distance;
    CLLocationCoordinate2D const & coordinate = lastLocation.coordinate;
    ms::LatLon const & directionPos = info.m_pedestrianDirectionPos;
    //TODO: Not the best solution, but this solution is temporary and will be replaced in future
    MeasurementUtils::FormatDistance(ms::DistanceOnEarth(coordinate.latitude, coordinate.longitude,
                                          directionPos.lat, directionPos.lon), distance);
    istringstream is (distance);
    string dist;
    string units;
    is>>dist;
    is>>units;
    _nextTurnImage = nil;
    _distanceToTurn = @(dist.c_str());
    _turnUnits = @(units.c_str());
    _streetName = @"";
//    _lanes = {};
  }
  else
  {
    _isPedestrian = NO;
    _distanceToTurn = @(info.m_distToTurn.c_str());
    _turnUnits = @(info.m_turnUnitsSuffix.c_str());
    _streetName = @(info.m_targetName.c_str());
//    _lanes = info.m_lanes;
    _nextTurnImage = image(info.m_nextTurn, true);
  }

  TurnDirection const turn = info.m_turn;
  _turnImage = image(turn, false);
  BOOL const isRound = turn == TurnDirection::EnterRoundAbout ||
                       turn == TurnDirection::StayOnRoundAbout ||
                       turn == TurnDirection::LeaveRoundAbout;
  if (isRound)
    _roundExitNumber = info.m_exitNum;
  else
    _roundExitNumber = 0;
}

UIImage * image(routing::turns::TurnDirection t, bool isNextTurn)
{
  if (GetFramework().GetRouter() == routing::RouterType::Pedestrian)
    return [UIImage imageNamed:@"ic_direction"];

  NSString * imageName;
  switch (t)
  {
    case TurnDirection::TurnSlightRight:
      imageName = @"slight_right";
      break;
    case TurnDirection::TurnRight:
      imageName = @"simple_right";
      break;
    case TurnDirection::TurnSharpRight:
      imageName = @"sharp_right";
      break;
    case TurnDirection::TurnSlightLeft:
      imageName = @"slight_left";
      break;
    case TurnDirection::TurnLeft:
      imageName = @"simple_left";
      break;
    case TurnDirection::TurnSharpLeft:
      imageName = @"sharp_left";
      break;
    case TurnDirection::UTurnLeft:
      imageName = @"uturn_left";
      break;
    case TurnDirection::UTurnRight:
      imageName = @"uturn_right";
      break;
    case TurnDirection::ReachedYourDestination:
      imageName = @"finish_point";
      break;
    case TurnDirection::LeaveRoundAbout:
    case TurnDirection::EnterRoundAbout:
      imageName = @"round";
      break;
    case TurnDirection::GoStraight:
      imageName = @"straight";
      break;
    case TurnDirection::StartAtEndOfStreet:
    case TurnDirection::StayOnRoundAbout:
    case TurnDirection::TakeTheExit:
    case TurnDirection::Count:
    case TurnDirection::NoTurn:
      imageName = isNextTurn ? nil : @"straight";
      break;
  }
  if (!imageName)
    return nil;
  return [UIImage imageNamed:isNextTurn ? [imageName stringByAppendingString:@"_then"] : imageName];
}

@end