Guest User

Untitled

a guest
Feb 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.35 KB | None | 0 0
  1. for i in 1...numOfLanes {
  2.  
  3. import UIKit
  4. import NMAKit
  5.  
  6. //
  7. // ViewController.swift
  8. // Next Gen Lane Guidance
  9. //
  10. // Created by Jason on 2/8/18.
  11. // Copyright © 2018 Jason. All rights reserved.
  12. //
  13.  
  14. /*
  15. ViewController manages the view for the lane guidance app.
  16. */
  17.  
  18. class ViewController: UIViewController, LaneGuidanceModelDelegate {
  19.  
  20. // UI elements
  21. @IBOutlet weak var mapView: NMAMapView!
  22. @IBOutlet weak var currentManeuverInstructionLabel: UILabel!
  23. @IBOutlet weak var nextRoadLabel: UILabel!
  24. @IBOutlet weak var currentManeuverGraphicBox: UIView!
  25. @IBOutlet weak var distToCurrentManeuver: UILabel!
  26. @IBOutlet weak var laneGuidanceBox: UIView!
  27. @IBOutlet weak var navStartStopButtonLabel: UIButton!
  28.  
  29. /// Start/stop button state (true = pressed to start route calculation, false = no route calculated)
  30. var navStartStopButtonState : Bool = false
  31. /// Data model
  32. var laneGuidanceDataModel : LaneGuidanceDataModel? = nil
  33. /// Previous maneuver graphic
  34. var prevManeuverGraphic = CAShapeLayer()
  35. /// Previous set of lane guidance maneuvers
  36. var prevLaneGuidanceBanner = UIStackView()
  37. /// Route element where current maneuver happens
  38. var routeElementsForCurrentManeuver : [NMARouteElement]? = nil
  39. /// Complete dictionary of direction graphics
  40. var directionArrowDictionary : [NMALaneInformationDirection : CAShapeLayer] = [:]
  41.  
  42. /// Complete list of all possible directions a lane may point in
  43. let possibleLaneDirections : [NMALaneInformationDirection]
  44. = [NMALaneInformationDirection.left,
  45. NMALaneInformationDirection.mergeLanes,
  46. NMALaneInformationDirection.mergeLeft,
  47. NMALaneInformationDirection.mergeRight,
  48. NMALaneInformationDirection.right,
  49. NMALaneInformationDirection.secondLeft,
  50. NMALaneInformationDirection.secondRight,
  51. NMALaneInformationDirection.sharpLeft,
  52. NMALaneInformationDirection.sharpRight,
  53. NMALaneInformationDirection.slightlyLeft,
  54. NMALaneInformationDirection.slightlyRight,
  55. NMALaneInformationDirection.straight,
  56. NMALaneInformationDirection.uTurnLeft,
  57. NMALaneInformationDirection.uTurnRight]
  58.  
  59. /**
  60. Notifies the view controller that its view is about to be added to a view hierarchy.
  61.  
  62. - Parameter animated: If true, the view is being added to the window using an animation.
  63. */
  64. override func viewWillAppear(_ animated: Bool) {
  65. super.viewWillAppear(animated)
  66.  
  67. laneGuidanceDataModel = LaneGuidanceDataModel()
  68. laneGuidanceDataModel!.delegate = self
  69.  
  70. /// Set label on navigation control button
  71. navStartStopButtonLabel.setTitle("Start Navigation", for: .normal)
  72. /// Turn off voice guidance
  73. laneGuidanceDataModel!.setVoiceGuidance(activeState: false)
  74.  
  75.  
  76. }
  77.  
  78. /**
  79. Starts/stops navigations.
  80.  
  81. To start turn-by-turn navigation, a concrete route object is required. We will create a route from point A to point B. The route calculation requires local map data. Unless there is pre-downloaded map data on the device by utilizing MapLoader APIs, it is not recommended to trigger the route calculation immediately after the MapEngine is initialized. This is why we have routing triggered by a button press.
  82.  
  83. - Parameter sender: Button that was pressed?
  84. */
  85. @IBAction func navStartStopButton(_ sender: Any) {
  86. if navStartStopButtonState == false {
  87. /// If guided navigation is off (and it is now turning on) ...
  88.  
  89. navStartStopButtonState = true
  90.  
  91. /// Create route
  92. laneGuidanceDataModel!.createRoute()
  93.  
  94. /// Change button from "Start Navigation" to "Stop Navigation"
  95. navStartStopButtonLabel.setTitle("Stop Navigation", for: .normal)
  96.  
  97. setPositionSource()
  98. }
  99. else {
  100. /// If guided navigation is on (and it is now turning off) ...
  101.  
  102. navStartStopButtonState = false
  103.  
  104. /// Remove old lane guidance info from screen
  105. prevLaneGuidanceBanner.removeFromSuperview()
  106.  
  107. /// Stop guidance
  108. laneGuidanceDataModel!.stopNavigation()
  109.  
  110. /// Remove route from screen
  111. clearRoute(mapRoute: laneGuidanceDataModel!.getMapRoute())
  112.  
  113. /// Reset tilt to 0 (birds eye view)
  114. mapView.tilt = 0
  115.  
  116. /// Orient map north up
  117. mapView.set(orientation: 0, animation: .none)
  118.  
  119. /// Show entire route on screen
  120. mapView.set(boundingBox: laneGuidanceDataModel!.geoBoundingBox!, animation: .linear)
  121.  
  122. /// Change button from "Stop Navigation" to "Start Navigation"
  123. navStartStopButtonLabel.setTitle("Start Navigation", for: .normal)
  124.  
  125. /// Position point around which movements/animations are centered to center of screen
  126. mapView.transformCenter = CGPoint(x: 0, y: 0)
  127. }
  128.  
  129. }
  130.  
  131. /**
  132. Receive callback from the navigation manager as to whether a route was successfully created.
  133.  
  134. - Parameter routeFound: True if navigation manager found route.
  135. */
  136. func didCreateRoute(routeFound: Bool) {
  137. if(routeFound == true) {
  138. plotRoute(mapRoute: laneGuidanceDataModel!.getMapRoute(), geoBoundingBox: laneGuidanceDataModel!.getGeoBoundingBox())
  139. }
  140. }
  141.  
  142. /**
  143. Plot a route on the screen.
  144.  
  145. - Parameter mapRoute: Route to plot.
  146. - Parameter geoBoundingBox: Window to use when plotting route on screen.
  147. */
  148. func plotRoute(mapRoute : NMAMapRoute, geoBoundingBox : NMAGeoBoundingBox) {
  149. mapView.add(mapObject: mapRoute) // Add the route onto the map
  150.  
  151. /// NOTE: For an unknown reason, the only way I can seem to get the following two commands to work is to put the orientation command first and to set the animation for both to "none." */
  152.  
  153. /// Orient map north up
  154. mapView.set(orientation: 0, animation: .none)
  155. /// Show entire route on screen
  156. mapView.set(boundingBox: geoBoundingBox, animation: .linear)
  157. }
  158.  
  159. /**
  160. Clear route from the screen.
  161.  
  162. - Parameter mapRoute: Route to clear.
  163. */
  164. func clearRoute(mapRoute : NMAMapRoute) {
  165. mapView.remove(mapObject: mapRoute)
  166. }
  167.  
  168. /**
  169. Present the user with a decision: real world navigation or simulated navigation?
  170. */
  171. func setPositionSource() {
  172.  
  173. /// Create an action sheet that enables user to choose between real world and simulated turn-by-turn navigation
  174. let alertController = UIAlertController(title: "Choose Navigation Mode", message: "Please choose a mode", preferredStyle: .actionSheet)
  175.  
  176. /// Option 1: Real world navigation
  177. let navAction = UIAlertAction(title: "Real World Nav", style: .default, handler: { (action: UIAlertAction) in
  178. self.laneGuidanceDataModel!.startPositioning(simulation: false)
  179.  
  180. self.startJourney()
  181. })
  182.  
  183. /// Option 2: Simulated navigation
  184. let simulationAction = UIAlertAction(title: "Simulated Nav", style: .default, handler: { (action: UIAlertAction) in
  185. self.laneGuidanceDataModel!.startPositioning(simulation: true)
  186.  
  187. self.startJourney()
  188. })
  189.  
  190. /// Add two actions to action sheet
  191. alertController.addAction(navAction)
  192. alertController.addAction(simulationAction)
  193.  
  194. /// Present the action sheet to user
  195. present(alertController, animated: true, completion: nil)
  196. }
  197.  
  198. /**
  199. Present the user with a GO button.
  200. */
  201. func startJourney() {
  202.  
  203. /// Display position indicator on map
  204. mapView.positionIndicator.isVisible = true
  205.  
  206. /// Position point around which movements/animations are centered to bottom of screen to leave room for maneuver info at top of screen
  207. mapView.transformCenter = CGPoint(x: 0.5, y: 0.9)
  208.  
  209. /// Create an action sheet
  210. let alertController = UIAlertController(title: "Start of the Journey", message: "Press GO to Start!", preferredStyle: .actionSheet)
  211.  
  212. let go = UIAlertAction(title: "GO", style: .default, handler: { (action: UIAlertAction) in
  213. print("Journey started.")
  214. /// Configure navigation manager to launch navigation on current map
  215. self.laneGuidanceDataModel!.getNavManager().map = self.mapView
  216. /// Start following route
  217. self.laneGuidanceDataModel!.startNavigation()
  218. })
  219.  
  220. /// Add action to action sheet
  221. alertController.addAction(go)
  222.  
  223. /// Present the action sheet to user
  224. present(alertController, animated: true, completion: nil)
  225.  
  226.  
  227. }
  228.  
  229.  
  230.  
  231. /**
  232. Update maneuver info on screen.
  233.  
  234. - Parameter currentManeuver: Details of current maneuver.
  235. */
  236. func updateManeuverDisplay(currentManeuver: NMAManeuver) {
  237. print("New maneuver information received.")
  238.  
  239. /// Remove previous maneuver graphic from screen
  240. prevManeuverGraphic.removeFromSuperlayer()
  241.  
  242. /// Clear route elements for current maneuver
  243. routeElementsForCurrentManeuver = nil
  244.  
  245. /// Update maneuver instruction, next road, and distance to current maneuver on screen
  246. // TODO: ADD CODE.
  247.  
  248. /// Update maneuver graphic
  249. // TODO: ADD CODE.
  250. }
  251.  
  252.  
  253. /**
  254. Update lane guidance info on screen.
  255.  
  256. - Parameter laneInformations: Lane reconfiguration information.
  257. - Parameter roadElement: Road element where lane reconfiguration takes place.
  258. */
  259. func updateLaneGuidanceDisplay(laneInformations: [NMALaneInformation], roadElement: NMARoadElement?) {
  260.  
  261. /// Remove old lane guidance info from screen
  262. prevLaneGuidanceBanner.removeFromSuperview()
  263.  
  264. /// Set up lane guidance banner
  265. let laneGuidanceBanner = UIStackView()
  266. laneGuidanceBanner.axis = UILayoutConstraintAxis.horizontal
  267. laneGuidanceBanner.distribution = UIStackViewDistribution.equalSpacing
  268. laneGuidanceBanner.alignment = UIStackViewAlignment.center
  269. laneGuidanceBanner.spacing = 16.0
  270.  
  271. /// Create array of views to store lane direction graphics
  272. var laneViews = [UIView]()
  273.  
  274. /// Populate lane guidance banner
  275. let numOfLanes = laneInformations.count
  276.  
  277.  
  278. for i in 1...numOfLanes {
  279. createDirectionArrowDictionary()
  280.  
  281.  
  282. /// For all lanes at given route cross section (i.e. position along route)...
  283.  
  284. print("Lane: (i)")
  285.  
  286. /// Create new view for (i-1)th lane
  287. laneViews += [UIView()]
  288.  
  289. /// Set color and size of lane view
  290. laneViews[i - 1].backgroundColor = UIColor.blue
  291. laneViews[i - 1].heightAnchor.constraint(equalToConstant: 46).isActive = true
  292. laneViews[i - 1].widthAnchor.constraint(equalToConstant: 46).isActive = true
  293.  
  294. /// Add direction arrows to lane views
  295. for j in 1...possibleLaneDirections.count {
  296. if laneInformations[i - 1].directions.contains(possibleLaneDirections[j - 1]) {
  297.  
  298. /// Print string representation of lane direction to debug window
  299. print(possibleLaneDirections[j - 1].getString())
  300.  
  301. /// Get arrow and recommendation
  302. let (currentArrow, recommendation) = getDirectionArrow(laneDirection: possibleLaneDirections[j - 1], roadElement: roadElement!)
  303.  
  304. /// Set arrow color to white if recommended and light gray if not
  305. if recommendation == true {
  306. currentArrow.strokeColor = UIColor.white.cgColor
  307. }
  308. else {
  309. currentArrow.strokeColor = UIColor.lightGray.cgColor
  310. }
  311.  
  312. /// Set line width for arrow
  313. currentArrow.lineWidth = 2.0
  314.  
  315. /// Make sure there's no fill
  316. currentArrow.fillColor = nil
  317.  
  318. /// Add arrow as sublayer of lane view
  319. laneViews[i - 1].layer.addSublayer(currentArrow)
  320. }
  321. }
  322.  
  323. /// Add lane views to lane guidance banner
  324. laneGuidanceBanner.addArrangedSubview(laneViews[i - 1])
  325. }
  326.  
  327. /// Turn OFF auto layout
  328. laneGuidanceBanner.translatesAutoresizingMaskIntoConstraints = false
  329.  
  330. /// Add lane guidance banner to screen
  331. laneGuidanceBox.addSubview(laneGuidanceBanner)
  332.  
  333. /// Distribute lane guidance views evenly around vertical centerline of screen
  334. laneGuidanceBanner.centerXAnchor.constraint(equalTo: laneGuidanceBox.centerXAnchor).isActive = true
  335. laneGuidanceBanner.centerYAnchor.constraint(equalTo: laneGuidanceBox.centerYAnchor).isActive = true
  336.  
  337. /// Keep track of lane guidance info so it can be cleared when new lane guidance info becomes available
  338. prevLaneGuidanceBanner = laneGuidanceBanner
  339. }
  340.  
  341. /**
  342. Get direction arrow.
  343.  
  344. - Parameter laneDirection: Direction of interest.
  345. - Parameter roadElement: Road element where lane reconfiguration takes place.
  346.  
  347. - Returns CAShapeLayer: Graphical representation of direction arrow.
  348. - Returns recommendation: True if current direction is recommended for driver to stay on route.
  349. */
  350. func getDirectionArrow(laneDirection : NMALaneInformationDirection, roadElement: NMARoadElement) -> (CAShapeLayer, Bool) {
  351.  
  352. // If road element for lane reconfiguration is contained in route element for current maneuver, then we can be reasonably sure that recommended lane direction corresponds with maneuver.
  353. // TODO: ADD CODE THAT CHECKS THIS.
  354.  
  355. print("Retrieving (laneDirection) arrow...")
  356. return (directionArrowDictionary[laneDirection]!, true)
  357. }
  358.  
  359. /**
  360. Create dictionary of direction arrows.
  361. */
  362. func createDirectionArrowDictionary() {
  363.  
  364. // Left Arrow
  365.  
  366. let leftArrow = CAShapeLayer()
  367. let path1 = UIBezierPath()
  368. path1.move(to: CGPoint(x: 23, y: 43))
  369. path1.addLine(to: CGPoint(x: 23, y: 23))
  370. path1.addLine(to: CGPoint(x: 7, y: 23))
  371. path1.move(to: CGPoint(x: 11, y: 27))
  372. path1.addLine(to: CGPoint(x: 3, y: 23))
  373. path1.addLine(to: CGPoint(x: 11, y: 19))
  374. path1.close()
  375. leftArrow.path = path1.cgPath
  376.  
  377. directionArrowDictionary[NMALaneInformationDirection.left] = leftArrow
  378.  
  379.  
  380. // Merge Lanes Arrow
  381.  
  382. let mergeLanesArrow = CAShapeLayer()
  383. let path2 = UIBezierPath()
  384. path2.move(to: CGPoint(x: 11, y: 43))
  385. path2.addLine(to: CGPoint(x: 11, y: 27))
  386. path2.addLine(to: CGPoint(x: 23, y: 19))
  387. path2.addLine(to: CGPoint(x: 35, y: 27))
  388. path2.addLine(to: CGPoint(x: 35, y: 43))
  389. path2.move(to: CGPoint(x: 23, y: 19))
  390. path2.addLine(to: CGPoint(x: 23, y: 7))
  391. path2.move(to: CGPoint(x: 19, y: 11))
  392. path2.addLine(to: CGPoint(x: 23, y: 3))
  393. path2.addLine(to: CGPoint(x: 27, y: 11))
  394. path2.close()
  395. mergeLanesArrow.path = path2.cgPath
  396.  
  397. directionArrowDictionary[NMALaneInformationDirection.mergeLanes] = mergeLanesArrow
  398.  
  399.  
  400. // Merge Left Arrow
  401.  
  402. let mergeLeftArrow = CAShapeLayer()
  403. let path3 = UIBezierPath()
  404. path3.move(to: CGPoint(x: 23, y: 43))
  405. path3.addLine(to: CGPoint(x: 23, y: 27))
  406. path3.addLine(to: CGPoint(x: 11, y: 19))
  407. path3.addLine(to: CGPoint(x: 11, y: 7))
  408. path3.move(to: CGPoint(x: 7, y: 11))
  409. path3.addLine(to: CGPoint(x: 15, y: 11))
  410. path3.addLine(to: CGPoint(x: 11, y: 3))
  411. path3.close()
  412. mergeLeftArrow.path = path3.cgPath
  413.  
  414. directionArrowDictionary[NMALaneInformationDirection.mergeLeft] = mergeLeftArrow
  415.  
  416.  
  417. // Merge Right Arrow
  418.  
  419. let mergeRightArrow = CAShapeLayer()
  420. let path4 = UIBezierPath()
  421. path4.move(to: CGPoint(x: 23, y: 43))
  422. path4.addLine(to: CGPoint(x: 23, y: 27))
  423. path4.addLine(to: CGPoint(x: 35, y: 19))
  424. path4.addLine(to: CGPoint(x: 35, y: 7))
  425. path4.move(to: CGPoint(x: 31, y: 11))
  426. path4.addLine(to: CGPoint(x: 39, y: 11))
  427. path4.addLine(to: CGPoint(x: 35, y: 3))
  428. path4.close()
  429. mergeRightArrow.path = path4.cgPath
  430.  
  431. directionArrowDictionary[NMALaneInformationDirection.mergeRight] = mergeRightArrow
  432.  
  433.  
  434. // Right Arrow
  435.  
  436. let rightArrow = CAShapeLayer()
  437. let path5 = UIBezierPath()
  438. path5.move(to: CGPoint(x: 23, y: 43))
  439. path5.addLine(to: CGPoint(x: 23, y: 23))
  440. path5.addLine(to: CGPoint(x: 39, y: 23))
  441. path5.move(to: CGPoint(x: 35, y: 27))
  442. path5.addLine(to: CGPoint(x: 43, y: 23))
  443. path5.addLine(to: CGPoint(x: 35, y: 19))
  444. path5.close()
  445. rightArrow.path = path5.cgPath
  446.  
  447. directionArrowDictionary[NMALaneInformationDirection.right] = rightArrow
  448.  
  449.  
  450. // Second Left Arrow
  451.  
  452. let secondLeftArrow = CAShapeLayer()
  453. let path6 = UIBezierPath()
  454. path6.move(to: CGPoint(x: 23, y: 43))
  455. path6.addLine(to: CGPoint(x: 23, y: 23))
  456. path6.addLine(to: CGPoint(x: 7, y: 23))
  457. path6.move(to: CGPoint(x: 11, y: 27))
  458. path6.addLine(to: CGPoint(x: 3, y: 23))
  459. path6.addLine(to: CGPoint(x: 11, y: 19))
  460. path6.close()
  461. path6.move(to: CGPoint(x: 23, y: 23))
  462. path6.addLine(to: CGPoint(x: 23, y: 9))
  463. path6.addLine(to: CGPoint(x: 7, y: 9))
  464. path6.move(to: CGPoint(x: 11, y: 13))
  465. path6.addLine(to: CGPoint(x: 3, y: 9))
  466. path6.addLine(to: CGPoint(x: 11, y: 5))
  467. path6.close()
  468. secondLeftArrow.path = path6.cgPath
  469.  
  470. directionArrowDictionary[NMALaneInformationDirection.secondLeft] = secondLeftArrow
  471.  
  472.  
  473. // Second Right Arrow
  474.  
  475. let secondRightArrow = CAShapeLayer()
  476. let path7 = UIBezierPath()
  477. path7.move(to: CGPoint(x: 23, y: 43))
  478. path7.addLine(to: CGPoint(x: 23, y: 23))
  479. path7.addLine(to: CGPoint(x: 39, y: 23))
  480. path7.move(to: CGPoint(x: 35, y: 27))
  481. path7.addLine(to: CGPoint(x: 43, y: 23))
  482. path7.addLine(to: CGPoint(x: 35, y: 19))
  483. path7.close()
  484. path7.move(to: CGPoint(x: 23, y: 23))
  485. path7.addLine(to: CGPoint(x: 23, y: 9))
  486. path7.addLine(to: CGPoint(x: 35, y: 9))
  487. path7.move(to: CGPoint(x: 35, y: 13))
  488. path7.addLine(to: CGPoint(x: 43, y: 9))
  489. path7.addLine(to: CGPoint(x: 35, y: 5))
  490. path7.close()
  491. secondRightArrow.path = path7.cgPath
  492.  
  493. directionArrowDictionary[NMALaneInformationDirection.secondRight] = secondRightArrow
  494.  
  495.  
  496. // Sharp Left Arrow
  497.  
  498. let sharpLeftArrow = CAShapeLayer()
  499. let path8 = UIBezierPath()
  500. path8.move(to: CGPoint(x: 23, y: 43))
  501. path8.addLine(to: CGPoint(x: 23, y: 23))
  502. path8.addLine(to: CGPoint(x: 13.1, y: 32.9))
  503. path8.move(to: CGPoint(x: 17.3, y: 34.3))
  504. path8.addLine(to: CGPoint(x: 11.7, y: 28.7))
  505. path8.addLine(to: CGPoint(x: 8.9, y: 37.1))
  506. path8.close()
  507. sharpLeftArrow.path = path8.cgPath
  508.  
  509. directionArrowDictionary[NMALaneInformationDirection.sharpLeft] = sharpLeftArrow
  510.  
  511.  
  512. // Sharp Right Arrow
  513.  
  514. let sharpRightArrow = CAShapeLayer()
  515. let path9 = UIBezierPath()
  516. path9.move(to: CGPoint(x: 23, y: 43))
  517. path9.addLine(to: CGPoint(x: 23, y: 23))
  518. path9.addLine(to: CGPoint(x: 32.9, y: 32.9))
  519. path9.move(to: CGPoint(x: 28.7, y: 34.3))
  520. path9.addLine(to: CGPoint(x: 34.3, y: 28.7))
  521. path9.addLine(to: CGPoint(x: 37.1, y: 37.1))
  522. path9.close()
  523. sharpRightArrow.path = path9.cgPath
  524.  
  525. directionArrowDictionary[NMALaneInformationDirection.sharpRight] = sharpRightArrow
  526.  
  527.  
  528. // Slightly Left Arrow
  529.  
  530. let slightlyLeftArrow = CAShapeLayer()
  531. let path10 = UIBezierPath()
  532. path10.move(to: CGPoint(x: 23, y: 43))
  533. path10.addLine(to: CGPoint(x: 23, y: 23))
  534. path10.addLine(to: CGPoint(x: 13.2, y: 13.2))
  535. path10.move(to: CGPoint(x: 11.8, y: 17.5))
  536. path10.addLine(to: CGPoint(x: 9, y: 9))
  537. path10.addLine(to: CGPoint(x: 17.5, y: 11.8))
  538. path10.close()
  539. slightlyLeftArrow.path = path10.cgPath
  540.  
  541. directionArrowDictionary[NMALaneInformationDirection.slightlyLeft] = slightlyLeftArrow
  542.  
  543.  
  544. // Slightly Right Arrow
  545.  
  546. let slightlyRightArrow = CAShapeLayer()
  547. let path11 = UIBezierPath()
  548. path11.move(to: CGPoint(x: 23, y: 43))
  549. path11.addLine(to: CGPoint(x: 23, y: 23))
  550. path11.addLine(to: CGPoint(x: 32.8, y: 13.2))
  551. path11.move(to: CGPoint(x: 34.2, y: 17.5))
  552. path11.addLine(to: CGPoint(x: 37, y: 9))
  553. path11.addLine(to: CGPoint(x: 28.5, y: 11.8))
  554. path11.close()
  555. slightlyRightArrow.path = path11.cgPath
  556.  
  557. directionArrowDictionary[NMALaneInformationDirection.slightlyRight] = slightlyRightArrow
  558.  
  559.  
  560. // Straight Arrow
  561.  
  562. let straightArrow = CAShapeLayer()
  563. let path12 = UIBezierPath()
  564. path12.move(to: CGPoint(x: 23, y: 43))
  565. path12.addLine(to: CGPoint(x: 23, y: 9))
  566. path12.move(to: CGPoint(x: 19, y: 11))
  567. path12.addLine(to: CGPoint(x: 27, y: 11))
  568. path12.addLine(to: CGPoint(x: 23, y: 3))
  569. path12.close()
  570. straightArrow.path = path12.cgPath
  571.  
  572. directionArrowDictionary[NMALaneInformationDirection.straight] = straightArrow
  573.  
  574.  
  575. // U Turn Left Arrow
  576.  
  577. let uTurnLeftArrow = CAShapeLayer()
  578. let path13 = UIBezierPath()
  579. path13.move(to: CGPoint(x: 23, y: 43))
  580. path13.addLine(to: CGPoint(x: 23, y: 23))
  581. path13.addLine(to: CGPoint(x: 8, y: 23))
  582. path13.addLine(to: CGPoint(x: 8, y: 35))
  583. path13.move(to: CGPoint(x: 4, y: 35))
  584. path13.addLine(to: CGPoint(x: 12, y: 35))
  585. path13.addLine(to: CGPoint(x: 8, y: 43))
  586. path13.close()
  587. uTurnLeftArrow.path = path13.cgPath
  588.  
  589. directionArrowDictionary[NMALaneInformationDirection.uTurnLeft] = uTurnLeftArrow
  590.  
  591.  
  592. // U Turn Right Arrow
  593.  
  594. let uTurnRightArrow = CAShapeLayer()
  595. let path14 = UIBezierPath()
  596. path14.move(to: CGPoint(x: 23, y: 43))
  597. path14.addLine(to: CGPoint(x: 23, y: 23))
  598. path14.addLine(to: CGPoint(x: 38, y: 23))
  599. path14.addLine(to: CGPoint(x: 38, y: 35))
  600. path14.move(to: CGPoint(x: 34, y: 35))
  601. path14.addLine(to: CGPoint(x: 42, y: 35))
  602. path14.addLine(to: CGPoint(x: 38, y: 43))
  603. path14.close()
  604. uTurnRightArrow.path = path14.cgPath
  605.  
  606. directionArrowDictionary[NMALaneInformationDirection.uTurnRight] = uTurnRightArrow
  607. }
  608.  
  609. /**
  610. Create dictionary of maneuver information.
  611. */
  612. func createManeuverDictionary() {
  613.  
  614. }
  615.  
  616.  
  617. }
Add Comment
Please, Sign In to add comment