Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MGLMapCamera misinterprets eye coordinate #12967

Closed
1ec5 opened this issue Sep 26, 2018 · 1 comment · Fixed by #12966
Closed

MGLMapCamera misinterprets eye coordinate #12967

1ec5 opened this issue Sep 26, 2018 · 1 comment · Fixed by #12966
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general

Comments

@1ec5
Copy link
Contributor

1ec5 commented Sep 26, 2018

+[MGLMapCamera cameraLookingAtCenterCoordinate:fromEyeCoordinate:eyeAltitude:] calculates a pitch in radians and passes it into -initWithCenterCoordinate:altitude:pitch:heading:, which expects the pitch in degrees, so the resulting MGLMapCamera has much less of a pitch than expected, the wrong heading, and a shorter viewing distance – so the eyeCoordinate parameter doesn’t have the intended effect. If the tangent happened to be negative, then MGLMapView would ignore the pitch altogether.

heading = std::atan((centerMeters.northing() - eyeMeters.northing()) /
(centerMeters.easting() - eyeMeters.easting()));
pitch = std::atan(eyeAltitude / groundDistance);

This significant discrepancy has apparently always been present in the MGLMapCamera implementation, since #2193. Unlike #12943, I think it would be tenable to fix the bug in-place, because the developer’s intent by using this method is pretty clear.

/cc @mapbox/maps-ios @d-prukop

@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general MapKit parity For feature parity with MapKit on iOS or macOS labels Sep 26, 2018
@1ec5
Copy link
Contributor Author

1ec5 commented Sep 27, 2018

If you pass the same coordinate twice into +[MGLMapCamera cameraLookingAtCenterCoordinate:fromEyeCoordinate:eyeAltitude:], the resulting camera incorrectly has a pitch of about 1.5° (a right angle in radians, but interpreted as degrees) instead of 0° and a heading of NaN instead of 0°.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant