Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building extrusion highlights #2535

Merged
merged 52 commits into from
Aug 15, 2020
Merged

Building extrusion highlights #2535

merged 52 commits into from
Aug 15, 2020

Conversation

d-prukop
Copy link
Contributor

Added the ability to highlight buildings in the NavigationMapView using a geographic coordinate.

@avi-c
Copy link
Contributor

avi-c commented Aug 10, 2020

Do we want to squash the commit history?

MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
MapboxNavigation.xcodeproj/project.pbxproj Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
@MaximAlien
Copy link
Contributor

Here are some results which contain changes made by Dave and arrival tweaks:
output output2

MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
return nil
}

private func highlightBuildings(_ buildings: [(identifier: UInt64, highlightColor: UIColor)]?, in3D: Bool, extrudeAll: Bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since extrudeAll feature is not really supported I propose to remove it completely. If needed we can add it in future, but for now it'll simplify current logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep this capability in for further design and UX experimentation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the Android implementation have the ability to highlight multiple buildings in different colors at the same time? If not, we should ticket that out as tail work in the mapbox/mapbox-navigation-android repository.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @d-prukop can provide more info on this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality isn’t exposed in the public API, so we’re maintaining it in the codebase for no obvious benefit. In general, we should remove edge cases like these that applications can’t possibly trigger, so that they don’t bitrot and also don’t contribute to low code coverage.

MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
@MaximAlien
Copy link
Contributor

MaximAlien commented Aug 13, 2020

Overall this looks good to me. We expose public highlightDestinationBuildings property in NavigationViewController which allows to highlight buildings upon arrival. We also give the ability to call highlightBuildings(for:in3D:) and unhighlightBuildings methods inside NavigationMapView. There are still some issues I've found:

  1. Issue with zooming in when arriving to intermediate waypoint. When arriving to final destination zoom-in works correctly (Building is not highlighted when approaching intermediate waypoint. #2541).
  2. Issue with adding layer back in case of style updates (marked by FIXME) (Route and highlighted building are removed after changing style. #2545).
  3. Issue with not highlighting buildings when they're not currently visible on map (Buildings are not highlighted if they were not visible on map at the time of arrival. #2553).
  4. Crash when adding final destination to the same building (can reproduce it only when running internal sample).
  5. ViewController.swift - in case if we get waypoints limit buildings are not removed.
  6. Flickering in some cases when pressing map view (Flickering when highlighting building. #2552).
  7. navigationDayStyleURL should be used by default (Standalone and NavigationMapView inside NavigationViewController should use the same styleURL. #2551).

They can be taken care in scope of other PRs.

PR which adds showcase sample can be found here. I'll also add it to documentation as well.

@1ec5, please feel free to take a look and let us know whether you have any comments. Many thanks to @d-prukop for hard work on this PR.

CHANGELOG.md Outdated Show resolved Hide resolved
MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
Example/ViewController.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationViewController.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
Comment on lines 1473 to 1475
let fillExtrusionHeightStops = [0: NSExpression(forConstantValue: 0),
13: NSExpression(forConstantValue: 0),
13.25: NSExpression(format: highlightedBuildingHeightExpression)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the purpose of these stops is to make the buildings appear to grow out of the ground when they first appear. But if somehow the camera stays put at z13.1, the buildings will stay short. Can we accomplish the same effect without the edge case by setting fillExtrusionHeight to TERNARY($zoomLevel > 13.25, %@, 0) and relying on the duration in fillExtrusionHeightTransition to make the buildings’ appearance less sudden?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some tests with changed fillExtrusionHeight and do not see any significant difference. Maybe @d-prukop or @avi-c can comment on this one?

MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
@@ -262,6 +266,8 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
addGestureRecognizer(mapTapGesture)

installUserCourseView()

styleURL = MGLStyle.navigationDayStyleURL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This overrides the style URL explicitly passed into init(frame:styleURL:) and possibly also init(coder:). I think we should move it into init(frame:) and find a way to only conditionally set it in init(coder:). This might be why we hadn’t customized NavigationMapView’s default style URL up to now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. There is one really strange issue with new approach though. When I add let styleURL = decoder.decodeObject(of: [URL.self], forKey: "styleURL") as? URL anywhere in the code in NavigationMapView Xcode gets Segmentation fault: 11 error during build. I think it'd be better to create separate ticket to handle this, because of mentioned issue and to prevent any side effects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL is a pure Swift type, so it’s incompatible with NSCoder.decodeObject(of:forKey:). But it should work with TopLevelDecoder.decode(_:from:).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting finding, on the other hand seems that TopLevelDecoder.decode(_:from:) is still part of Combine. In any case I'll consider this approach as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I meant KeyedDecodingContainer.decode(_:). We need to create a local decoding container in order to decode that key.

MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
MapboxNavigation/NavigationMapView.swift Outdated Show resolved Hide resolved
@MaximAlien MaximAlien self-assigned this Aug 14, 2020
@MaximAlien MaximAlien added feature New feature request. UI Work related to visual components, Android Auto, Camera, 3D, voice, etc. labels Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request. UI Work related to visual components, Android Auto, Camera, 3D, voice, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants