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

Commit

Permalink
clearer function naming
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Jan 18, 2017
1 parent 530e32b commit 6ddc216
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions platform/darwin/src/MGLStyle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ - (void)setStyleClasses:(NS_ARRAY_OF(NSString *) *)appliedClasses transitionDura
newAppliedClasses.push_back([appliedClass UTF8String]);
}

mbgl::style::TransitionOptions transition { { MGLDurationInSeconds(transitionDuration) } };
mbgl::style::TransitionOptions transition { { MGLDurationInSecondsFromTimeInterval(transitionDuration) } };
self.mapView.mbglMap->setTransitionOptions(transition);
self.mapView.mbglMap->setClasses(newAppliedClasses);
}
Expand Down Expand Up @@ -575,27 +575,27 @@ - (MGLImage *)imageForName:(NSString *)name
- (void)setTransitionDuration:(NSTimeInterval)duration
{
auto transitionOptions = self.mapView.mbglMap->getTransitionOptions();
transitionOptions.duration = MGLDurationInSeconds(duration);
transitionOptions.duration = MGLDurationInSecondsFromTimeInterval(duration);
self.mapView.mbglMap->setTransitionOptions(transitionOptions);
}

- (NSTimeInterval)transitionDuration
{
const mbgl::style::TransitionOptions transitionOptions = self.mapView.mbglMap->getTransitionOptions();
return MGLSecondsFromDuration(transitionOptions.duration.value_or(mbgl::Duration::zero()));
return MGLTimeIntervalFromDurationInSeconds(transitionOptions.duration.value_or(mbgl::Duration::zero()));
}

- (void)setTransitionDelay:(NSTimeInterval)delay
{
auto transitionOptions = self.mapView.mbglMap->getTransitionOptions();
transitionOptions.delay = MGLDurationInSeconds(delay);
transitionOptions.delay = MGLDurationInSecondsFromTimeInterval(delay);
self.mapView.mbglMap->setTransitionOptions(transitionOptions);
}

- (NSTimeInterval)transitionDelay
{
const mbgl::style::TransitionOptions transitionOptions = self.mapView.mbglMap->getTransitionOptions();
return MGLSecondsFromDuration(transitionOptions.delay.value_or(mbgl::Duration::zero()));
return MGLTimeIntervalFromDurationInSeconds(transitionOptions.delay.value_or(mbgl::Duration::zero()));
}

- (NSString *)description
Expand Down
4 changes: 2 additions & 2 deletions platform/darwin/src/NSDate+MGLAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
@interface NSDate (MGLAdditions)

/// Converts from a duration in seconds to a duration object usable in mbgl.
mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration);
mbgl::Duration MGLDurationInSecondsFromTimeInterval(NSTimeInterval duration);

/// Converts from an mbgl duration object to a duration in seconds.
NSTimeInterval MGLSecondsFromDuration(mbgl::Duration duration);
NSTimeInterval MGLTimeIntervalFromDurationInSeconds(mbgl::Duration duration);

@end
4 changes: 2 additions & 2 deletions platform/darwin/src/NSDate+MGLAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

@implementation NSDate (MGLAdditions)

mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
mbgl::Duration MGLDurationInSecondsFromTimeInterval(NSTimeInterval duration)
{
return std::chrono::duration_cast<mbgl::Duration>(std::chrono::duration<NSTimeInterval>(duration));
}

NSTimeInterval MGLSecondsFromDuration(mbgl::Duration duration)
NSTimeInterval MGLTimeIntervalFromDurationInSeconds(mbgl::Duration duration)
{
return duration.count();
}
Expand Down
24 changes: 12 additions & 12 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)pan
if (drift)
{
CGPoint offset = CGPointMake(velocity.x * self.decelerationRate / 4, velocity.y * self.decelerationRate / 4);
_mbglMap->moveBy({ offset.x, offset.y }, MGLDurationInSeconds(self.decelerationRate));
_mbglMap->moveBy({ offset.x, offset.y }, MGLDurationInSecondsFromTimeInterval(self.decelerationRate));
}

[self notifyGestureDidEndWithDrift:drift];
Expand Down Expand Up @@ -1316,7 +1316,7 @@ - (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinch

if (velocity && duration)
{
_mbglMap->setScale(newScale, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }, MGLDurationInSeconds(duration));
_mbglMap->setScale(newScale, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }, MGLDurationInSecondsFromTimeInterval(duration));
}

[self notifyGestureDidEndWithDrift:velocity && duration];
Expand Down Expand Up @@ -1375,7 +1375,7 @@ - (void)handleRotateGesture:(UIRotationGestureRecognizer *)rotate
CGFloat newRadians = radians + velocity * decelerationRate * 0.1;
CGFloat newDegrees = MGLDegreesFromRadians(newRadians) * -1;

_mbglMap->setBearing(newDegrees, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }, MGLDurationInSeconds(decelerationRate));
_mbglMap->setBearing(newDegrees, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }, MGLDurationInSecondsFromTimeInterval(decelerationRate));

[self notifyGestureDidEndWithDrift:YES];

Expand Down Expand Up @@ -1504,7 +1504,7 @@ - (void)handleDoubleTapGesture:(UITapGestureRecognizer *)doubleTap
CGPoint gesturePoint = [self anchorPointForGesture:doubleTap];

mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
_mbglMap->scaleBy(2, center, MGLDurationInSeconds(MGLAnimationDuration));
_mbglMap->scaleBy(2, center, MGLDurationInSecondsFromTimeInterval(MGLAnimationDuration));

__weak MGLMapView *weakSelf = self;

Expand Down Expand Up @@ -1532,7 +1532,7 @@ - (void)handleTwoFingerTapGesture:(UITapGestureRecognizer *)twoFingerTap
CGPoint gesturePoint = [self anchorPointForGesture:twoFingerTap];

mbgl::ScreenCoordinate center(gesturePoint.x, gesturePoint.y);
_mbglMap->scaleBy(0.5, center, MGLDurationInSeconds(MGLAnimationDuration));
_mbglMap->scaleBy(0.5, center, MGLDurationInSecondsFromTimeInterval(MGLAnimationDuration));

__weak MGLMapView *weakSelf = self;

Expand Down Expand Up @@ -2288,7 +2288,7 @@ - (void)_setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate edgePaddin
mbgl::AnimationOptions animationOptions;
if (duration)
{
animationOptions.duration.emplace(MGLDurationInSeconds(duration));
animationOptions.duration.emplace(MGLDurationInSecondsFromTimeInterval(duration));
animationOptions.easing.emplace(MGLUnitBezierForMediaTimingFunction(function));
}
if (completion)
Expand Down Expand Up @@ -2329,7 +2329,7 @@ - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated

_mbglMap->setZoom(zoomLevel,
MGLEdgeInsetsFromNSEdgeInsets(self.contentInset),
MGLDurationInSeconds(duration));
MGLDurationInSecondsFromTimeInterval(duration));
}

- (void)setMinimumZoomLevel:(double)minimumZoomLevel
Expand Down Expand Up @@ -2441,7 +2441,7 @@ - (void)_setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count
mbgl::AnimationOptions animationOptions;
if (duration > 0)
{
animationOptions.duration.emplace(MGLDurationInSeconds(duration));
animationOptions.duration.emplace(MGLDurationInSecondsFromTimeInterval(duration));
animationOptions.easing.emplace(MGLUnitBezierForMediaTimingFunction(function));
}
if (completion)
Expand Down Expand Up @@ -2489,13 +2489,13 @@ - (void)_setDirection:(CLLocationDirection)direction animated:(BOOL)animated
{
_mbglMap->setBearing(direction,
MGLEdgeInsetsFromNSEdgeInsets(self.contentInset),
MGLDurationInSeconds(duration));
MGLDurationInSecondsFromTimeInterval(duration));
}
else
{
CGPoint centerPoint = self.userLocationAnnotationViewCenter;
_mbglMap->setBearing(direction, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y },
MGLDurationInSeconds(duration));
MGLDurationInSecondsFromTimeInterval(duration));
}
}

Expand Down Expand Up @@ -2548,7 +2548,7 @@ - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration a
mbgl::AnimationOptions animationOptions;
if (duration > 0)
{
animationOptions.duration.emplace(MGLDurationInSeconds(duration));
animationOptions.duration.emplace(MGLDurationInSecondsFromTimeInterval(duration));
animationOptions.easing.emplace(MGLUnitBezierForMediaTimingFunction(function));
}
if (completion)
Expand Down Expand Up @@ -2594,7 +2594,7 @@ - (void)_flyToCamera:(MGLMapCamera *)camera edgePadding:(UIEdgeInsets)insets wit
mbgl::AnimationOptions animationOptions;
if (duration >= 0)
{
animationOptions.duration = MGLDurationInSeconds(duration);
animationOptions.duration = MGLDurationInSecondsFromTimeInterval(duration);
}
if (peakAltitude >= 0)
{
Expand Down

0 comments on commit 6ddc216

Please sign in to comment.