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

-[MGLMapView convertCoordinateBounds:toRectToView:] is unable to span the antimeridian #11609

Closed
1ec5 opened this issue Apr 5, 2018 · 1 comment
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS

Comments

@1ec5
Copy link
Contributor

1ec5 commented Apr 5, 2018

Even with the fix in #11265, the following code returns an empty rect at an invalid coordinate when the visible coordinate bounds span the antimeridian:

[mapView convertCoordinateBounds:mapView.visibleCoordinateBounds toRectToView:mapView];

/cc @julianrex

@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels Apr 5, 2018
@1ec5
Copy link
Contributor Author

1ec5 commented Apr 5, 2018

This code appears to need some of the wrapping/unwrapping logic introduced to -convertRect:toLatLngBoundsFromView: in #11265:

/// Converts a geographic bounding box to a rectangle in the view’s coordinate
/// system.
- (CGRect)convertLatLngBounds:(mbgl::LatLngBounds)bounds toRectToView:(nullable UIView *)view {
CGRect rect = { [self convertLatLng:bounds.southwest() toPointToView:view], CGSizeZero };
rect = MGLExtendRect(rect, [self convertLatLng:bounds.northeast() toPointToView:view]);
return rect;
}

/// Converts a geographic bounding box to a rectangle in the view’s coordinate
/// system.
- (NSRect)convertLatLngBounds:(mbgl::LatLngBounds)bounds toRectToView:(nullable NSView *)view {
NSRect rect = { [self convertLatLng:bounds.southwest() toPointToView:view], NSZeroSize };
rect = MGLExtendRect(rect, [self convertLatLng:bounds.northeast() toPointToView:view]);
return rect;
}

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
Projects
None yet
Development

No branches or pull requests

3 participants