Skip to content

Commit 9aed2c3

Browse files
committed
Update the property and function names.
1 parent 32be609 commit 9aed2c3

8 files changed

+38
-26
lines changed

Sources/MapboxNavigation/CarPlayNavigationViewController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ open class CarPlayNavigationViewController: UIViewController, BuildingHighlighti
789789
}
790790

791791
if annotatesIntersectionsAlongRoute {
792-
navigationMapView?.updateIntersectionSignals(with: routeProgress)
792+
navigationMapView?.updateIntersectionAnnotations(with: routeProgress)
793793
}
794794

795795
navigationMapView?.updateRouteLine(routeProgress: routeProgress, coordinate: location.coordinate, shouldRedraw: legIndex != currentLegIndexMapped)
@@ -890,7 +890,7 @@ open class CarPlayNavigationViewController: UIViewController, BuildingHighlighti
890890
navigationMapView?.showWaypoints(on: progress.route, legIndex: legIndex)
891891

892892
if annotatesIntersectionsAlongRoute {
893-
navigationMapView?.updateIntersectionSignals(with: progress)
893+
navigationMapView?.updateIntersectionAnnotations(with: progress)
894894
}
895895
}
896896

@@ -1037,9 +1037,9 @@ open class CarPlayNavigationViewController: UIViewController, BuildingHighlighti
10371037
func updateIntersectionsAlongRoute() {
10381038
if annotatesIntersectionsAlongRoute {
10391039
navigationMapView?.updateIntersectionSymbolImages(styleType: styleManager?.currentStyleType)
1040-
navigationMapView?.updateIntersectionSignals(with: navigationService.routeProgress)
1040+
navigationMapView?.updateIntersectionAnnotations(with: navigationService.routeProgress)
10411041
} else {
1042-
navigationMapView?.removeIntersectionSignals()
1042+
navigationMapView?.removeIntersectionAnnotations()
10431043
}
10441044
}
10451045
}

Sources/MapboxNavigation/NavigationMapView+Annotations.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,20 @@ extension NavigationMapView {
395395

396396
// MARK: Intersection Signals Annotations
397397

398+
399+
/**
400+
Removes all the intersection annotations on current route.
401+
*/
402+
func removeIntersectionAnnotations() {
403+
let style = mapView.mapboxMap.style
404+
style.removeLayers([NavigationMapView.LayerIdentifier.intersectionAnnotationsLayer])
405+
style.removeSources([NavigationMapView.SourceIdentifier.intersectionAnnotationsSource])
406+
}
407+
398408
/**
399409
Updates the image assets in the map style for the route intersection signals.
410+
411+
- parameter styleType: The `StyleType` to choose `Day` or `Night` style of icon images for route intersection signals.
400412
*/
401413
func updateIntersectionSymbolImages(styleType: StyleType?) {
402414
let style = mapView.mapboxMap.style
@@ -428,9 +440,9 @@ extension NavigationMapView {
428440
}
429441
}
430442

431-
func updateIntersectionSignals(with routeProgress: RouteProgress) {
443+
func updateIntersectionAnnotations(with routeProgress: RouteProgress) {
432444
guard !routeProgress.routeIsComplete else {
433-
removeIntersectionSignals()
445+
removeIntersectionAnnotations()
434446
return
435447
}
436448
var featureCollection = FeatureCollection(features: [])
@@ -440,15 +452,15 @@ extension NavigationMapView {
440452
let stepIntersections = stepProgress.intersectionsIncludingUpcomingManeuverIntersection
441453

442454
for intersection in stepIntersections?.suffix(from: intersectionIndex) ?? [] {
443-
if let feature = signalFeature(from: intersection) {
455+
if let feature = intersectionFeature(from: intersection) {
444456
featureCollection.features.append(feature)
445457
}
446458
}
447459

448460
let style = mapView.mapboxMap.style
449461

450462
do {
451-
let sourceIdentifier = NavigationMapView.SourceIdentifier.intersectionSignalSource
463+
let sourceIdentifier = NavigationMapView.SourceIdentifier.intersectionAnnotationsSource
452464
if style.sourceExists(withId: sourceIdentifier) {
453465
try style.updateGeoJSONSource(withId: sourceIdentifier, geoJSON: .featureCollection(featureCollection))
454466
} else {
@@ -457,7 +469,7 @@ extension NavigationMapView {
457469
try style.addSource(source, id: sourceIdentifier)
458470
}
459471

460-
let layerIdentifier = NavigationMapView.LayerIdentifier.intersectionSignalLayer
472+
let layerIdentifier = NavigationMapView.LayerIdentifier.intersectionAnnotationsLayer
461473
guard !style.layerExists(withId: layerIdentifier) else { return }
462474

463475
var shapeLayer = SymbolLayer(id: layerIdentifier)
@@ -475,7 +487,7 @@ extension NavigationMapView {
475487
}
476488
}
477489

478-
private func signalFeature(from intersection: Intersection) -> Feature? {
490+
private func intersectionFeature(from intersection: Intersection) -> Feature? {
479491
var properties: JSONObject? = nil
480492
if intersection.railroadCrossing == true {
481493
properties = ["imageName": .string(ImageIdentifier.railroadCrossing)]

Sources/MapboxNavigation/NavigationMapView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ open class NavigationMapView: UIView {
14591459
LayerIdentifier.arrowLayer,
14601460
LayerIdentifier.arrowSymbolCasingLayer,
14611461
LayerIdentifier.arrowSymbolLayer,
1462-
LayerIdentifier.intersectionSignalLayer
1462+
LayerIdentifier.intersectionAnnotationsLayer
14631463
]
14641464
let uppermostSymbolLayers: [String] = [
14651465
LayerIdentifier.waypointCircleLayer,

Sources/MapboxNavigation/NavigationMapViewIdentifiers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension NavigationMapView {
1111
static let arrowSymbolCasingLayer = "\(identifier)_arrowSymbolCasingLayer"
1212
static let voiceInstructionLabelLayer = "\(identifier)_voiceInstructionLabelLayer"
1313
static let voiceInstructionCircleLayer = "\(identifier)_voiceInstructionCircleLayer"
14-
static let intersectionSignalLayer = "\(identifier)_trafficLayer"
14+
static let intersectionAnnotationsLayer = "\(identifier)_intersectionAnnotationsLayer"
1515
static let waypointCircleLayer = "\(identifier)_waypointCircleLayer"
1616
static let waypointSymbolLayer = "\(identifier)_waypointSymbolLayer"
1717
static let buildingExtrusionLayer = "\(identifier)_buildingExtrusionLayer"
@@ -26,7 +26,7 @@ extension NavigationMapView {
2626
static let arrowStrokeSource = "\(identifier)_arrowStrokeSource"
2727
static let arrowSymbolSource = "\(identifier)_arrowSymbolSource"
2828
static let voiceInstructionSource = "\(identifier)_instructionSource"
29-
static let intersectionSignalSource = "\(identifier)_trafficSource"
29+
static let intersectionAnnotationsSource = "\(identifier)_intersectionAnnotationsSource"
3030
static let waypointSource = "\(identifier)_waypointSource"
3131
static let routeDurationAnnotationsSource: String = "\(identifier)_routeDurationAnnotationsSource"
3232
static let continuousAlternativeRoutesDurationAnnotationsSource: String = "\(identifier)_continuousAlternativeRoutesDurationAnnotationsSource"

Sources/MapboxNavigation/NavigationViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,9 @@ open class NavigationViewController: UIViewController, NavigationStatusPresenter
886886
func updateIntersectionsAlongRoute() {
887887
if annotatesIntersectionsAlongRoute {
888888
navigationMapView?.updateIntersectionSymbolImages(styleType: styleManager?.currentStyleType)
889-
navigationMapView?.updateIntersectionSignals(with: navigationService.routeProgress)
889+
navigationMapView?.updateIntersectionAnnotations(with: navigationService.routeProgress)
890890
} else {
891-
navigationMapView?.removeIntersectionSignals()
891+
navigationMapView?.removeIntersectionAnnotations()
892892
}
893893
}
894894
}

Sources/MapboxNavigation/RouteLineController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ extension NavigationMapView {
5656
}
5757

5858
if annotatesIntersections {
59-
navigationMapView.updateIntersectionSignals(with: router.routeProgress)
59+
navigationMapView.updateIntersectionAnnotations(with: router.routeProgress)
6060
}
6161
}
6262

@@ -94,7 +94,7 @@ extension NavigationMapView {
9494
}
9595

9696
if annotatesIntersections {
97-
navigationMapView.updateIntersectionSignals(with: router.routeProgress)
97+
navigationMapView.updateIntersectionAnnotations(with: router.routeProgress)
9898
}
9999
}
100100

@@ -118,7 +118,7 @@ extension NavigationMapView {
118118
}
119119

120120
if annotatesIntersections {
121-
navigationMapView.updateIntersectionSignals(with: progress)
121+
navigationMapView.updateIntersectionAnnotations(with: progress)
122122
}
123123

124124
navigationMapView.updateRouteLine(routeProgress: progress, coordinate: location.coordinate, shouldRedraw: currentLegIndexMapped != legIndex)

Tests/MapboxNavigationTests/NavigationViewControllerTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,11 @@ class NavigationViewControllerTests: TestCase {
526526
"Failed to update the style of SpriteRepository singleton with the injected NavigationMapView.")
527527
}
528528

529-
func testUpdateIntersectionSignalsAlongRouteOnMap() {
529+
func testAnnotatesIntersectionsAlongRoute() {
530530
let navigationViewController = navigationViewControllerMock()
531531
let imageIdentifier = NavigationMapView.ImageIdentifier.trafficSignal
532-
let layerIdentifier = NavigationMapView.LayerIdentifier.intersectionSignalLayer
533-
let sourceIdentifier = NavigationMapView.SourceIdentifier.intersectionSignalSource
532+
let layerIdentifier = NavigationMapView.LayerIdentifier.intersectionAnnotationsLayer
533+
let sourceIdentifier = NavigationMapView.SourceIdentifier.intersectionAnnotationsSource
534534

535535
guard let style = navigationViewController.navigationMapView?.mapView.mapboxMap.style else {
536536
XCTFail("Failed to get the MapView style object.")

Tests/MapboxNavigationTests/RouteLineLayerPositionTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class RouteLineLayerPositionTests: TestCase {
245245
navigationMapView.showsRestrictedAreasOnRoute = false
246246
navigationMapView.routeLineTracksTraversal = true
247247
navigationMapView.updateIntersectionSymbolImages(styleType: .day)
248-
navigationMapView.updateIntersectionSignals(with: routeProgress)
248+
navigationMapView.updateIntersectionAnnotations(with: routeProgress)
249249

250250
expectedLayerSequence = [
251251
buildingLayer["id"]!,
@@ -258,7 +258,7 @@ class RouteLineLayerPositionTests: TestCase {
258258
NavigationMapView.LayerIdentifier.arrowLayer,
259259
NavigationMapView.LayerIdentifier.arrowSymbolCasingLayer,
260260
NavigationMapView.LayerIdentifier.arrowSymbolLayer,
261-
NavigationMapView.LayerIdentifier.intersectionSignalLayer,
261+
NavigationMapView.LayerIdentifier.intersectionAnnotationsLayer,
262262
roadExitLayer["id"]!,
263263
poiLabelLayer["id"]!,
264264
poiLabelCircleLayer["id"]!
@@ -284,7 +284,7 @@ class RouteLineLayerPositionTests: TestCase {
284284
layerPosition: .below(roadLabelLayer["id"]!))
285285
navigationMapView.removeRoutes()
286286
navigationMapView.removeArrow()
287-
navigationMapView.removeIntersectionSignals()
287+
navigationMapView.removeIntersectionAnnotations()
288288

289289
expectedLayerSequence = [
290290
buildingLayer["id"]!,
@@ -307,7 +307,7 @@ class RouteLineLayerPositionTests: TestCase {
307307
navigationMapView.show([multilegRoute])
308308
navigationMapView.showsRestrictedAreasOnRoute = true
309309
navigationMapView.routeLineTracksTraversal = false
310-
navigationMapView.updateIntersectionSignals(with: routeProgress)
310+
navigationMapView.updateIntersectionAnnotations(with: routeProgress)
311311

312312
expectedLayerSequence = [
313313
buildingLayer["id"]!,
@@ -321,7 +321,7 @@ class RouteLineLayerPositionTests: TestCase {
321321
NavigationMapView.LayerIdentifier.arrowLayer,
322322
NavigationMapView.LayerIdentifier.arrowSymbolCasingLayer,
323323
NavigationMapView.LayerIdentifier.arrowSymbolLayer,
324-
NavigationMapView.LayerIdentifier.intersectionSignalLayer,
324+
NavigationMapView.LayerIdentifier.intersectionAnnotationsLayer,
325325
roadExitLayer["id"]!,
326326
poiLabelLayer["id"]!,
327327
poiLabelCircleLayer["id"]!,

0 commit comments

Comments
 (0)