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

Commit

Permalink
refs #5983: fix dumb stack variable error
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Aug 18, 2016
1 parent 5b3249f commit d1ff807
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
14 changes: 6 additions & 8 deletions platform/darwin/src/MGLGeometry_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ NS_INLINE mbgl::LatLngBounds MGLLatLngBoundsFromCoordinateBounds(MGLCoordinateBo
MGLLatLngFromLocationCoordinate2D(coordinateBounds.ne));
}

NS_INLINE CLLocationCoordinate2D* MGLLocationCoordinatesFromCoordinateBounds(MGLCoordinateBounds coordinateBounds) {
CLLocationCoordinate2D coordinates[] = {
{coordinateBounds.ne.latitude, coordinateBounds.sw.longitude},
coordinateBounds.sw,
{coordinateBounds.sw.latitude, coordinateBounds.ne.longitude},
coordinateBounds.ne,
};
return coordinates;
NS_INLINE void MGLLocationCoordinatesFromCoordinateBounds(MGLCoordinateBounds coordinateBounds, CLLocationCoordinate2D *coordinates) {
assert(sizeof(coordinates) == 4 * sizeof(CLLocationCoordinate2D));
coordinates[0] = { coordinateBounds.ne.latitude, coordinateBounds.sw.longitude };
coordinates[1] = coordinateBounds.sw;
coordinates[2] = { coordinateBounds.sw.latitude, coordinateBounds.ne.longitude };
coordinates[3] = coordinateBounds.ne;
}

#if TARGET_OS_IPHONE
Expand Down
21 changes: 15 additions & 6 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2340,12 +2340,15 @@ - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEd
edgePadding:insets
direction:self.direction]) return;

CLLocationCoordinate2D *coordinates = MGLLocationCoordinatesFromCoordinateBounds(bounds);
CLLocationCoordinate2D *coordinates = (CLLocationCoordinate2D *)malloc(4 * sizeof(CLLocationCoordinate2D));
MGLLocationCoordinatesFromCoordinateBounds(bounds, coordinates);

[self setVisibleCoordinates:coordinates
count:sizeof(coordinates) / sizeof(coordinates[0])
count:4
edgePadding:insets
animated:animated];

free(coordinates);
}

- (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction animated:(BOOL)animated
Expand All @@ -2354,13 +2357,16 @@ - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEd
edgePadding:insets
direction:direction]) return;

CLLocationCoordinate2D *coordinates = MGLLocationCoordinatesFromCoordinateBounds(bounds);
CLLocationCoordinate2D *coordinates = (CLLocationCoordinate2D *)malloc(4 * sizeof(CLLocationCoordinate2D));
MGLLocationCoordinatesFromCoordinateBounds(bounds, coordinates);

[self setVisibleCoordinates:coordinates
count:sizeof(coordinates) / sizeof(coordinates[0])
count:4
edgePadding:insets
direction:direction
animated:animated];

free(coordinates);
}

- (void)setVisibleCoordinates:(CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated
Expand Down Expand Up @@ -2781,13 +2787,16 @@ - (BOOL)viewportWouldChangeWithCenterCoordinate:(CLLocationCoordinate2D)centerCo

- (BOOL)viewportWouldChangeWithVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction
{
CLLocationCoordinate2D *coordinates = MGLLocationCoordinatesFromCoordinateBounds(bounds);
CLLocationCoordinate2D *coordinates = (CLLocationCoordinate2D *)malloc(4 * sizeof(CLLocationCoordinate2D));
MGLLocationCoordinatesFromCoordinateBounds(bounds, coordinates);

const mbgl::CameraOptions cameraOptions = [self cameraOptionsForVisibleCoordinates:coordinates
count:sizeof(coordinates) / sizeof(coordinates[0])
count:4
edgePadding:insets
direction:direction];

free(coordinates);

return [self viewportWouldChangeWithCamera:[self cameraForCameraOptions:cameraOptions]];
}

Expand Down

0 comments on commit d1ff807

Please sign in to comment.