Skip to content

Commit

Permalink
Merge pull request #1378 from mapbox/1ec5-delegate-objc-1375
Browse files Browse the repository at this point in the history
Clean up NavigationMapViewDelegate method names
  • Loading branch information
Bobby Sudekum authored May 9, 2018
2 parents 1f52631 + dbb4c93 commit 554c402
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
12 changes: 5 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
### Other changes

* `DistanceFormatter`, `ReplayLocationManager`, `SimulatedLocationManager`, `LanesView`, and `ManueverView` are now subclassable. ([#1345](https://github.com/mapbox/mapbox-navigation-ios/pull/1345]))
* Renamed methods on `NavigationMapViewDelegate` ([#1364](https://github.com/mapbox/mapbox-navigation-ios/pull/1364), [#1338](https://github.com/mapbox/mapbox-navigation-ios/pull/1338), [#1318](https://github.com/mapbox/mapbox-navigation-ios/pull/1318)):
- `NavigationMapViewDelegate.navigationMapView(_:shapeDescribingRoute:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:shapeDescribing:)`.
- `NavigationMapViewDelegate.navigationMapView(_:shapeDescribingWaypoints:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:simplifiedShapeDescribingRoute:)`.
- `NavigationMapViewDelegate.navigationMapView(_:shapeDescribingWaypoints:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:shapeFor:legIndex:)`.
- `NavigationMapViewDelegate.navigationMapView(_:imageForAnnotation:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:imageFor:)`.
- `NavigationMapViewDelegate.navigationMapView(_:viewForAnnotation:)` renamed to `NavigationMapViewDelegate.navigationMapView(_:viewFor:)`.
- `NavigationViewControllerDelegate.navigationViewControllerDidCancelNavigation(_:)` to `NavigationViewControllerDelegate.navigationViewControllerDidDismiss(_:byCanceling:)`
* Renamed several `NavigationMapViewDelegate` methods ([#1364](https://github.com/mapbox/mapbox-navigation-ios/pull/1364), [#1338](https://github.com/mapbox/mapbox-navigation-ios/pull/1338), [#1318](https://github.com/mapbox/mapbox-navigation-ios/pull/1318), [#1378](https://github.com/mapbox/mapbox-navigation-ios/pull/1378)):
* `NavigationViewControllerDelegate.navigationViewControllerDidCancelNavigation(_:)` to `NavigationViewControllerDelegate.navigationViewControllerDidDismiss(_:byCanceling:)`
* `NavigationMapViewDelegate.navigationMapView(_:shapeDescribing:)` to `NavigationMapViewDelegate.navigationMapView(_:shapeFor:)`.
* `NavigationMapViewDelegate.navigationMapView(_:simplifiedShapeDescribing:)` to `NavigationMapViewDelegate.navigationMapView(_:simplifiedShapeFor:)`.
* `-[MBNavigationMapViewDelegate navigationMapView:shapeDescribingWaypoints:legIndex:]` to `-[MBNavigationMapViewDelegate navigationMapView:shapeForWaypoints:legIndex:]` in Objective-C.

## v0.16.2 (April 13, 2018)

Expand Down
30 changes: 15 additions & 15 deletions MapboxNavigation/NavigationMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
guard let style = style else { return }
guard let activeRoute = routes.first else { return }

let mainPolyline = navigationMapDelegate?.navigationMapView?(self, shapeDescribing: activeRoute) ?? shape(describing: activeRoute, legIndex: legIndex)
let mainPolylineSimplified = navigationMapDelegate?.navigationMapView?(self, simplifiedShapeDescribing: activeRoute) ?? shape(describingCasing: activeRoute, legIndex: legIndex)
let mainPolyline = navigationMapDelegate?.navigationMapView?(self, shapeFor: activeRoute) ?? shape(for: activeRoute, legIndex: legIndex)
let mainPolylineSimplified = navigationMapDelegate?.navigationMapView?(self, simplifiedShapeFor: activeRoute) ?? shape(forCasingOf: activeRoute, legIndex: legIndex)

if let source = style.source(withIdentifier: sourceIdentifier) as? MGLShapeSource,
let sourceSimplified = style.source(withIdentifier: sourceCasingIdentifier) as? MGLShapeSource {
Expand Down Expand Up @@ -811,19 +811,19 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
return candidates
}

func shape(describing route: Route, legIndex: Int?) -> MGLShape? {
func shape(for route: Route, legIndex: Int?) -> MGLShape? {
guard let coordinates = route.coordinates else { return nil }

var linesPerLeg: [[MGLPolylineFeature]] = []

for (index, leg) in route.legs.enumerated() {
// If there is no congestion, don't try and add it
guard let legCongestion = leg.segmentCongestionLevels else {
return shape(describingCasing: route, legIndex: legIndex)
return shape(forCasingOf: route, legIndex: legIndex)
}

guard legCongestion.count + 1 <= coordinates.count else {
return shape(describingCasing: route, legIndex: legIndex)
return shape(forCasingOf: route, legIndex: legIndex)
}

// The last coord of the preceding step, is shared with the first coord of the next step.
Expand Down Expand Up @@ -871,7 +871,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
return MGLShapeCollectionFeature(shapes: Array(linesPerLeg.joined()))
}

func shape(describingCasing route: Route, legIndex: Int?) -> MGLShape? {
func shape(forCasingOf route: Route, legIndex: Int?) -> MGLShape? {
var linesPerLeg: [MGLPolylineFeature] = []

for (index, leg) in route.legs.enumerated() {
Expand Down Expand Up @@ -1150,31 +1150,31 @@ public protocol NavigationMapViewDelegate: class {

/**
Asks the receiver to return an MGLShape that describes the geometry of the route.
- note: The returned value represents the route in full detail. For example, individual `MGLPolyline` objects in an `MGLShapeCollectionFeature` object can represent traffic congestion segments. For improved performance, you should also implement `navigationMapView(_:simplifiedShapeDescribing:)`, which defines the overall route as a single feature.
- note: The returned value represents the route in full detail. For example, individual `MGLPolyline` objects in an `MGLShapeCollectionFeature` object can represent traffic congestion segments. For improved performance, you should also implement `navigationMapView(_:simplifiedShapeFor:)`, which defines the overall route as a single feature.
- parameter mapView: The NavigationMapView.
- parameter route: The route that the sender is asking about.
- returns: Optionally, a `MGLShape` that defines the shape of the route, or `nil` to use default behavior.
*/
@objc(navigationMapView:shapeDescribing:)
optional func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape?
@objc(navigationMapView:shapeForRoute:)
optional func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape?

/**
Asks the receiver to return an MGLShape that describes the geometry of the route at lower zoomlevels.
- note: The returned value represents the simplfied route. It is designed to be used with `navigationMapView(_:shapeDescribing:), and if used without its parent method, can cause unexpected behavior.
- note: The returned value represents the simplfied route. It is designed to be used with `navigationMapView(_:shapeFor:), and if used without its parent method, can cause unexpected behavior.
- parameter mapView: The NavigationMapView.
- parameter route: The route that the sender is asking about.
- returns: Optionally, a `MGLShape` that defines the shape of the route at lower zoomlevels, or `nil` to use default behavior.
*/
@objc(navigationMapView:simplifiedShapeDescribing:)
optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape?
@objc(navigationMapView:simplifiedShapeForRoute:)
optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape?

/**
Asks the receiver to return an MGLShape that describes the geometry of the waypoint.
- parameter mapView: The NavigationMapView.
- parameter waypoints: The waypoints to be displayed on the map.
- returns: Optionally, a `MGLShape` that defines the shape of the waypoint, or `nil` to use default behavior.
*/
@objc(navigationMapView:shapeFor:legIndex:)
@objc(navigationMapView:shapeForWaypoints:legIndex:)
optional func navigationMapView(_ mapView: NavigationMapView, shapeFor waypoints: [Waypoint], legIndex: Int) -> MGLShape?

/**
Expand All @@ -1183,7 +1183,7 @@ public protocol NavigationMapViewDelegate: class {
- parameter annotation: The annotation to be styled.
- returns: Optionally, a `MGLAnnotationImage` that defines the image used for the annotation.
*/
@objc(navigationMapView:imageFor:)
@objc(navigationMapView:imageForAnnotation:)
optional func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage?

/**
Expand All @@ -1192,7 +1192,7 @@ public protocol NavigationMapViewDelegate: class {
- parameter annotation: The annotation to be styled.
- returns: Optionally, a `MGLAnnotationView` that defines the view used for the annotation.
*/
@objc(navigationMapView:viewFor:)
@objc(navigationMapView:viewForAnnotation:)
optional func navigationMapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView?

/**
Expand Down
16 changes: 9 additions & 7 deletions MapboxNavigation/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,16 @@ public protocol NavigationViewControllerDelegate {
If this method is unimplemented, the navigation map view represents the route line using an `MGLPolylineFeature` based on `route`’s `coordinates` property.
*/
@objc optional func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape?
@objc(navigationMapView:shapeForRoute:)
optional func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape?

/**
Returns an `MGLShape` that represents the path of the route line’s casing.
If this method is unimplemented, the navigation map view represents the route line’s casing using an `MGLPolylineFeature` identical to the one returned by `navigationMapView(_:shapeDescribing:)`.
If this method is unimplemented, the navigation map view represents the route line’s casing using an `MGLPolylineFeature` identical to the one returned by `navigationMapView(_:shapeFor:)`.
*/
@objc optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape?
@objc(navigationMapView:simplifiedShapeForRoute:)
optional func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape?

/*
Returns an `MGLStyleLayer` that marks the location of each destination along the route when there are multiple destinations. The returned layer is added to the map below the layer returned by `navigationMapView(_:waypointSymbolStyleLayerWithIdentifier:source:)`.
Expand Down Expand Up @@ -478,12 +480,12 @@ extension NavigationViewController: RouteMapViewControllerDelegate {
delegate?.navigationMapView?(mapView, didTap: route)
}

@objc public func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, shapeDescribing: route)
@objc public func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, shapeFor: route)
}

@objc public func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, shapeDescribing: route)
@objc public func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, shapeFor: route)
}

public func navigationMapView(_ mapView: NavigationMapView, waypointStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
Expand Down
8 changes: 4 additions & 4 deletions MapboxNavigation/RouteMapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -671,16 +671,16 @@ extension RouteMapViewController: NavigationViewDelegate {
return delegate?.navigationMapView?(mapView, shapeFor: waypoints, legIndex: legIndex)
}

func navigationMapView(_ mapView: NavigationMapView, shapeDescribing route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, shapeDescribing: route)
func navigationMapView(_ mapView: NavigationMapView, shapeFor route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, shapeFor: route)
}

func navigationMapView(_ mapView: NavigationMapView, didSelect route: Route) {
delegate?.navigationMapView?(mapView, didSelect: route)
}

func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeDescribing route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, simplifiedShapeDescribing: route)
func navigationMapView(_ mapView: NavigationMapView, simplifiedShapeFor route: Route) -> MGLShape? {
return delegate?.navigationMapView?(mapView, simplifiedShapeFor: route)
}

func navigationMapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? {
Expand Down

0 comments on commit 554c402

Please sign in to comment.