[core] Transform{State}: s/angle/bearing/

This commit is contained in:
Bruno de Oliveira Abinader
2019-03-01 09:58:58 +02:00
parent 73ac3c784f
commit ba7427b4ac
37 changed files with 151 additions and 135 deletions

View File

@@ -22,7 +22,7 @@ static void TileCoverPitchedViewport(benchmark::State& state) {
Transform transform;
transform.resize({ 512, 512 });
// slightly offset center so that tile order is better defined
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.1, -0.1 }).withZoom(8.0).withAngle(5.0).withPitch(40.0));
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.1, -0.1 }).withZoom(8.0).withBearing(5.0).withPitch(40.0));
std::size_t length = 0;
while (state.KeepRunning()) {

View File

@@ -94,7 +94,7 @@ int main(int argc, char *argv[]) {
map.jumpTo(CameraOptions()
.withCenter(LatLng { lat, lon })
.withZoom(zoom)
.withAngle(bearing)
.withBearing(bearing)
.withPitch(pitch));
if (debug) {

View File

@@ -19,7 +19,7 @@ struct CameraOptions {
CameraOptions& withPadding(const EdgeInsets& p) { padding = p; return *this; }
CameraOptions& withAnchor(const optional<ScreenCoordinate>& o) { anchor = o; return *this; }
CameraOptions& withZoom(const optional<double>& o) { zoom = o; return *this; }
CameraOptions& withAngle(const optional<double>& o) { angle = o; return *this; }
CameraOptions& withBearing(const optional<double>& o) { bearing = o; return *this; }
CameraOptions& withPitch(const optional<double>& o) { pitch = o; return *this; }
/** Coordinate at the center of the map. */
@@ -38,7 +38,7 @@ struct CameraOptions {
optional<double> zoom;
/** Bearing, measured in degrees from true north. Wrapped to [0, 360). */
optional<double> angle;
optional<double> bearing;
/** Pitch toward the horizon measured in degrees , with 0 deg resulting in a
two-dimensional map. */
@@ -50,7 +50,7 @@ constexpr bool operator==(const CameraOptions& a, const CameraOptions& b) {
&& a.padding == b.padding
&& a.anchor == b.anchor
&& a.zoom == b.zoom
&& a.angle == b.angle
&& a.bearing == b.bearing
&& a.pitch == b.pitch;
}

17
platform/android/.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1

View File

@@ -14,7 +14,7 @@ jni::Local<jni::Object<CameraPosition>> CameraPosition::New(jni::JNIEnv &env, mb
// convert bearing, measured in radians counterclockwise from true north.
// Wrapped to [−π rad, π rad). Android binding from 0 to 360 degrees
double bearing_degrees = options.angle.value_or(0);
double bearing_degrees = options.bearing.value_or(0);
while (bearing_degrees > 360) {
bearing_degrees -= 360;
}

View File

@@ -305,10 +305,10 @@ void NativeMapView::moveBy(jni::JNIEnv&, jni::jdouble dx, jni::jdouble dy, jni::
map->moveBy({dx, dy}, animationOptions);
}
void NativeMapView::jumpTo(jni::JNIEnv&, jni::jdouble angle, jni::jdouble latitude, jni::jdouble longitude, jni::jdouble pitch, jni::jdouble zoom) {
void NativeMapView::jumpTo(jni::JNIEnv&, jni::jdouble bearing, jni::jdouble latitude, jni::jdouble longitude, jni::jdouble pitch, jni::jdouble zoom) {
mbgl::CameraOptions options;
if (angle != -1) {
options.angle = angle;
if (bearing != -1) {
options.bearing = bearing;
}
options.center = mbgl::LatLng(latitude, longitude);
options.padding = insets;
@@ -322,10 +322,10 @@ void NativeMapView::jumpTo(jni::JNIEnv&, jni::jdouble angle, jni::jdouble latitu
map->jumpTo(options);
}
void NativeMapView::easeTo(jni::JNIEnv&, jni::jdouble angle, jni::jdouble latitude, jni::jdouble longitude, jni::jlong duration, jni::jdouble pitch, jni::jdouble zoom, jni::jboolean easing) {
void NativeMapView::easeTo(jni::JNIEnv&, jni::jdouble bearing, jni::jdouble latitude, jni::jdouble longitude, jni::jlong duration, jni::jdouble pitch, jni::jdouble zoom, jni::jboolean easing) {
mbgl::CameraOptions cameraOptions;
if (angle != -1) {
cameraOptions.angle = angle;
if (bearing != -1) {
cameraOptions.bearing = bearing;
}
cameraOptions.center = mbgl::LatLng(latitude, longitude);
cameraOptions.padding = insets;
@@ -346,10 +346,10 @@ void NativeMapView::easeTo(jni::JNIEnv&, jni::jdouble angle, jni::jdouble latitu
map->easeTo(cameraOptions, animationOptions);
}
void NativeMapView::flyTo(jni::JNIEnv&, jni::jdouble angle, jni::jdouble latitude, jni::jdouble longitude, jni::jlong duration, jni::jdouble pitch, jni::jdouble zoom) {
void NativeMapView::flyTo(jni::JNIEnv&, jni::jdouble bearing, jni::jdouble latitude, jni::jdouble longitude, jni::jlong duration, jni::jdouble pitch, jni::jdouble zoom) {
mbgl::CameraOptions cameraOptions;
if (angle != -1) {
cameraOptions.angle = angle;
if (bearing != -1) {
cameraOptions.bearing = bearing;
}
cameraOptions.center = mbgl::LatLng(latitude, longitude);
cameraOptions.padding = insets;
@@ -439,20 +439,20 @@ void NativeMapView::rotateBy(jni::JNIEnv&, jni::jdouble sx, jni::jdouble sy, jni
}
void NativeMapView::setBearing(jni::JNIEnv&, jni::jdouble degrees, jni::jlong duration) {
map->easeTo(mbgl::CameraOptions().withAngle(degrees), mbgl::AnimationOptions{mbgl::Milliseconds(duration)});
map->easeTo(mbgl::CameraOptions().withBearing(degrees), mbgl::AnimationOptions{mbgl::Milliseconds(duration)});
}
void NativeMapView::setBearingXY(jni::JNIEnv&, jni::jdouble degrees, jni::jdouble cx, jni::jdouble cy, jni::jlong duration) {
mbgl::ScreenCoordinate anchor(cx, cy);
map->easeTo(mbgl::CameraOptions().withAngle(degrees).withAnchor(anchor), mbgl::AnimationOptions{mbgl::Milliseconds(duration)});
map->easeTo(mbgl::CameraOptions().withBearing(degrees).withAnchor(anchor), mbgl::AnimationOptions{mbgl::Milliseconds(duration)});
}
jni::jdouble NativeMapView::getBearing(jni::JNIEnv&) {
return *map->getCameraOptions().angle;
return *map->getCameraOptions().bearing;
}
void NativeMapView::resetNorth(jni::JNIEnv&) {
map->easeTo(mbgl::CameraOptions().withAngle(0.0), mbgl::AnimationOptions {{mbgl::Milliseconds(500)}});
map->easeTo(mbgl::CameraOptions().withBearing(0.0), mbgl::AnimationOptions {{mbgl::Milliseconds(500)}});
}
void NativeMapView::setVisibleCoordinateBounds(JNIEnv& env, const jni::Array<jni::Object<LatLng>>& coordinates, const jni::Object<RectF>& padding, jdouble direction, jni::jlong duration) {
@@ -469,7 +469,7 @@ void NativeMapView::setVisibleCoordinateBounds(JNIEnv& env, const jni::Array<jni
mbgl::EdgeInsets mbglInsets = { RectF::getTop(env, padding), RectF::getLeft(env, padding), RectF::getBottom(env, padding), RectF::getRight(env, padding) };
mbgl::CameraOptions cameraOptions = map->cameraForLatLngs(latLngs, mbglInsets);
if (direction >= 0) {
cameraOptions.angle = direction;
cameraOptions.bearing = direction;
}
mbgl::AnimationOptions animationOptions;

View File

@@ -607,7 +607,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
if (CLLocationCoordinate2DIsValid(options.camera.centerCoordinate)) {
cameraOptions.center = MGLLatLngFromLocationCoordinate2D(options.camera.centerCoordinate);
}
cameraOptions.angle = MAX(0, options.camera.heading);
cameraOptions.bearing = MAX(0, options.camera.heading);
cameraOptions.zoom = MAX(0, options.zoomLevel);
cameraOptions.pitch = MAX(0, options.camera.pitch);

View File

@@ -209,7 +209,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
#endif // MBGL_USE_GLES2
case GLFW_KEY_N:
if (!mods)
view->map->easeTo(mbgl::CameraOptions().withAngle(0.0), mbgl::AnimationOptions {{mbgl::Milliseconds(500)}});
view->map->easeTo(mbgl::CameraOptions().withBearing(0.0), mbgl::AnimationOptions {{mbgl::Milliseconds(500)}});
break;
case GLFW_KEY_Z:
view->nextOrientation();
@@ -273,10 +273,10 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
const mbgl::LatLng center { point.y, point.x };
auto latLng = *camera.center;
double bearing = ruler.bearing({ latLng.longitude(), latLng.latitude() }, point);
double easing = bearing - *camera.angle;
double easing = bearing - *camera.bearing;
easing += easing > 180.0 ? -360.0 : easing < -180 ? 360.0 : 0;
bearing = *camera.angle + (easing / 20);
routeMap->jumpTo(mbgl::CameraOptions().withCenter(center).withZoom(18.0).withAngle(bearing).withPitch(60.0));
bearing = *camera.bearing + (easing / 20);
routeMap->jumpTo(mbgl::CameraOptions().withCenter(center).withZoom(18.0).withBearing(bearing).withPitch(60.0));
};
view->animateRouteCallback(view->map);
} break;

View File

@@ -120,7 +120,7 @@ int main(int argc, char *argv[]) {
map.jumpTo(mbgl::CameraOptions()
.withCenter(mbgl::LatLng {settings.latitude, settings.longitude})
.withZoom(settings.zoom)
.withAngle(settings.bearing)
.withBearing(settings.bearing)
.withPitch(settings.pitch));
map.setDebug(mbgl::MapDebugOptions(settings.debug));
@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
settings.latitude = camera.center->latitude();
settings.longitude = camera.center->longitude();
settings.zoom = *camera.zoom;
settings.bearing = *camera.angle;
settings.bearing = *camera.bearing;
settings.pitch = *camera.pitch;
settings.debug = mbgl::EnumType(map.getDebug());
settings.save();

View File

@@ -1775,7 +1775,7 @@ public:
{
[self trackGestureEvent:MMEEventGestureRotateStart forRecognizer:rotate];
self.angle = MGLRadiansFromDegrees(*self.mbglMap.getCameraOptions().angle) * -1;
self.angle = MGLRadiansFromDegrees(*self.mbglMap.getCameraOptions().bearing) * -1;
if (self.userTrackingMode != MGLUserTrackingModeNone)
{
@@ -1803,7 +1803,7 @@ public:
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera])
{
self.mbglMap.jumpTo(mbgl::CameraOptions()
.withAngle(newDegrees)
.withBearing(newDegrees)
.withAnchor(mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y}));
}
@@ -1840,7 +1840,7 @@ public:
if ([self _shouldChangeFromCamera:oldCamera toCamera:toCamera])
{
self.mbglMap.easeTo(mbgl::CameraOptions()
.withAngle(newDegrees)
.withBearing(newDegrees)
.withAnchor(mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }),
MGLDurationFromTimeInterval(decelerationRate));
@@ -2149,7 +2149,7 @@ public:
MGLMapCamera *camera;
mbgl::ScreenCoordinate anchor = mbgl::ScreenCoordinate { anchorPoint.x, anchorPoint.y };
currentCameraOptions.angle = degrees;
currentCameraOptions.bearing = degrees;
currentCameraOptions.anchor = anchor;
camera = [self cameraForCameraOptions:currentCameraOptions];
@@ -2577,7 +2577,7 @@ public:
MGLLogInfo(@"Resetting the map to the current style’s default viewport.");
auto camera = self.mbglMap.getStyle().getDefaultCamera();
CGFloat pitch = *camera.pitch;
CLLocationDirection heading = mbgl::util::wrap(*camera.angle, 0., 360.);
CLLocationDirection heading = mbgl::util::wrap(*camera.bearing, 0., 360.);
CLLocationDistance altitude = MGLAltitudeForZoomLevel(*camera.zoom, pitch, 0, self.frame.size);
self.camera = [MGLMapCamera cameraLookingAtCenterCoordinate:MGLLocationCoordinate2DFromLatLng(*camera.center)
altitude:altitude
@@ -3235,7 +3235,7 @@ public:
cameraOptions.zoom = zoomLevel;
if (direction >= 0)
{
cameraOptions.angle = direction;
cameraOptions.bearing = direction;
}
mbgl::AnimationOptions animationOptions;
@@ -3491,7 +3491,7 @@ public:
- (CLLocationDirection)direction
{
return *self.mbglMap.getCameraOptions().angle;
return *self.mbglMap.getCameraOptions().bearing;
}
- (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated
@@ -3524,7 +3524,7 @@ public:
if (self.userTrackingMode == MGLUserTrackingModeNone)
{
self.mbglMap.easeTo(mbgl::CameraOptions()
.withAngle(direction)
.withBearing(direction)
.withPadding(MGLEdgeInsetsFromNSEdgeInsets(self.contentInset)),
MGLDurationFromTimeInterval(duration));
}
@@ -3532,7 +3532,7 @@ public:
{
CGPoint anchor = self.userLocationAnnotationViewCenter;
self.mbglMap.easeTo(mbgl::CameraOptions()
.withAngle(direction)
.withBearing(direction)
.withAnchor(mbgl::ScreenCoordinate { anchor.x, anchor.y }),
MGLDurationFromTimeInterval(duration));
}
@@ -3797,7 +3797,7 @@ public:
mbgl::CameraOptions mapCamera = self.mbglMap.getCameraOptions();
CLLocationCoordinate2D centerCoordinate = MGLLocationCoordinate2DFromLatLng(cameraOptions.center ? *cameraOptions.center : self.mbglMap.getLatLng());
double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel;
CLLocationDirection direction = cameraOptions.angle ? mbgl::util::wrap(*cameraOptions.angle, 0., 360.) : self.direction;
CLLocationDirection direction = cameraOptions.bearing ? mbgl::util::wrap(*cameraOptions.bearing, 0., 360.) : self.direction;
CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : *mapCamera.pitch;
CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitch, centerCoordinate.latitude, self.frame.size);
return [MGLMapCamera cameraLookingAtCenterCoordinate:centerCoordinate altitude:altitude pitch:pitch heading:direction];
@@ -3818,7 +3818,7 @@ public:
self.frame.size);
if (camera.heading >= 0)
{
options.angle = camera.heading;
options.bearing = camera.heading;
}
if (camera.pitch >= 0)
{

View File

@@ -1124,7 +1124,7 @@ public:
}
- (CLLocationDirection)direction {
return *_mbglMap->getCameraOptions().angle;
return *_mbglMap->getCameraOptions().bearing;
}
- (void)setDirection:(CLLocationDirection)direction {
@@ -1136,14 +1136,14 @@ public:
MGLLogDebug(@"Setting direction: %f animated: %@", direction, MGLStringFromBOOL(animated));
[self willChangeValueForKey:@"direction"];
_mbglMap->easeTo(mbgl::CameraOptions()
.withAngle(direction)
.withBearing(direction)
.withPadding(MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets)),
MGLDurationFromTimeInterval(animated ? MGLAnimationDuration : 0));
[self didChangeValueForKey:@"direction"];
}
- (void)offsetDirectionBy:(CLLocationDegrees)delta animated:(BOOL)animated {
[self setDirection:*_mbglMap->getCameraOptions().angle + delta animated:animated];
[self setDirection:*_mbglMap->getCameraOptions().bearing + delta animated:animated];
}
+ (NSSet<NSString *> *)keyPathsForValuesAffectingCamera {
@@ -1262,7 +1262,7 @@ public:
camera.centerCoordinate.latitude,
self.frame.size);
if (camera.heading >= 0) {
options.angle = camera.heading;
options.bearing = camera.heading;
}
if (camera.pitch >= 0) {
options.pitch = camera.pitch;
@@ -1361,7 +1361,7 @@ public:
mbgl::CameraOptions mapCamera = _mbglMap->getCameraOptions();
CLLocationCoordinate2D centerCoordinate = MGLLocationCoordinate2DFromLatLng(cameraOptions.center ? *cameraOptions.center : _mbglMap->getLatLng());
double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel;
CLLocationDirection direction = cameraOptions.angle ? mbgl::util::wrap(*cameraOptions.angle, 0., 360.) : self.direction;
CLLocationDirection direction = cameraOptions.bearing ? mbgl::util::wrap(*cameraOptions.bearing, 0., 360.) : self.direction;
CGFloat pitch = cameraOptions.pitch ? *cameraOptions.pitch : *mapCamera.pitch;
CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitch,
centerCoordinate.latitude,
@@ -1487,7 +1487,7 @@ public:
if (self.rotateEnabled) {
CLLocationDirection newDirection = _directionAtBeginningOfGesture - delta.x / 10;
[self willChangeValueForKey:@"direction"];
_mbglMap->jumpTo(mbgl::CameraOptions().withAngle(newDirection).withAnchor(center));
_mbglMap->jumpTo(mbgl::CameraOptions().withBearing(newDirection).withAnchor(center));
didChangeCamera = YES;
[self didChangeValueForKey:@"direction"];
}
@@ -1626,7 +1626,7 @@ public:
NSPoint rotationPoint = [gestureRecognizer locationInView:self];
mbgl::ScreenCoordinate anchor(rotationPoint.x, self.bounds.size.height - rotationPoint.y);
_mbglMap->jumpTo(mbgl::CameraOptions()
.withAngle(_directionAtBeginningOfGesture + gestureRecognizer.rotationInDegrees)
.withBearing(_directionAtBeginningOfGesture + gestureRecognizer.rotationInDegrees)
.withAnchor(anchor));
if ([self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)]

View File

@@ -443,7 +443,7 @@ void NodeMap::startRender(NodeMap::RenderOptions options) {
mbgl::CameraOptions camera;
camera.center = mbgl::LatLng { options.latitude, options.longitude };
camera.zoom = options.zoom;
camera.angle = options.bearing;
camera.bearing = options.bearing;
camera.pitch = options.pitch;
if (map->getAxonometric() != options.axonometric) {
@@ -976,7 +976,7 @@ void NodeMap::SetBearing(const Nan::FunctionCallbackInfo<v8::Value>& info) {
}
try {
nodeMap->map->jumpTo(mbgl::CameraOptions().withAngle(info[0]->NumberValue()));
nodeMap->map->jumpTo(mbgl::CameraOptions().withBearing(info[0]->NumberValue()));
} catch (const std::exception &ex) {
return Nan::ThrowError(ex.what());
}

View File

@@ -94,7 +94,7 @@ struct Q_MAPBOXGL_EXPORT QMapboxGLCameraOptions {
QVariant center; // Coordinate
QVariant anchor; // QPointF
QVariant zoom; // double
QVariant angle; // double
QVariant bearing; // double
QVariant pitch; // double
};

View File

@@ -829,8 +829,8 @@ void QMapboxGL::jumpTo(const QMapboxGLCameraOptions& camera)
if (camera.zoom.isValid()) {
mbglCamera.zoom = camera.zoom.value<double>();
}
if (camera.angle.isValid()) {
mbglCamera.angle = camera.angle.value<double>();
if (camera.bearing.isValid()) {
mbglCamera.bearing = camera.bearing.value<double>();
}
if (camera.pitch.isValid()) {
mbglCamera.pitch = camera.pitch.value<double>();
@@ -855,20 +855,20 @@ void QMapboxGL::jumpTo(const QMapboxGLCameraOptions& camera)
*/
double QMapboxGL::bearing() const
{
return *d_ptr->mapObj->getCameraOptions().angle;
return *d_ptr->mapObj->getCameraOptions().bearing;
}
void QMapboxGL::setBearing(double degrees)
{
d_ptr->mapObj->jumpTo(mbgl::CameraOptions()
.withAngle(degrees)
.withBearing(degrees)
.withPadding(d_ptr->margins));
}
void QMapboxGL::setBearing(double degrees, const QPointF &center)
{
d_ptr->mapObj->jumpTo(mbgl::CameraOptions()
.withAngle(degrees)
.withBearing(degrees)
.withAnchor(mbgl::ScreenCoordinate { center.x(), center.y() }));
}

View File

@@ -62,7 +62,7 @@ namespace mbgl {
if (pitchWithMap) {
matrix::scale(m, m, 1 / pixelsToTileUnits, 1 / pixelsToTileUnits, 1);
if (!rotateWithMap) {
matrix::rotate_z(m, m, state.getAngle());
matrix::rotate_z(m, m, state.getBearing());
}
} else {
matrix::scale(m, m, state.getSize().width / 2.0, -(state.getSize().height / 2.0), 1.0);
@@ -82,7 +82,7 @@ namespace mbgl {
matrix::multiply(m, m, posMatrix);
matrix::scale(m, m, pixelsToTileUnits, pixelsToTileUnits, 1);
if (!rotateWithMap) {
matrix::rotate_z(m, m, -state.getAngle());
matrix::rotate_z(m, m, -state.getBearing());
}
} else {
matrix::scale(m, m, 1, -1, 1);

View File

@@ -181,7 +181,7 @@ LatLng Map::getLatLng(const EdgeInsets& padding) const {
void Map::resetPosition(const EdgeInsets& padding) {
impl->cameraMutated = true;
impl->transform.jumpTo(CameraOptions().withCenter(LatLng()).withPadding(padding).withZoom(0.0).withAngle(0.0).withPitch(0.0));
impl->transform.jumpTo(CameraOptions().withCenter(LatLng()).withPadding(padding).withZoom(0.0).withBearing(0.0).withPitch(0.0));
impl->onUpdate();
}
@@ -260,11 +260,11 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed
Transform transform(impl->transform.getState());
if (bearing || pitch) {
transform.jumpTo(CameraOptions().withAngle(bearing).withPitch(pitch));
transform.jumpTo(CameraOptions().withBearing(bearing).withPitch(pitch));
}
return mbgl::cameraForLatLngs(latLngs, transform, padding)
.withAngle(-transform.getAngle() * util::RAD2DEG)
.withBearing(-transform.getBearing() * util::RAD2DEG)
.withPitch(transform.getPitch() * util::RAD2DEG);
}

View File

@@ -87,10 +87,10 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
const LatLng& unwrappedLatLng = camera.center.value_or(startLatLng);
const LatLng& latLng = state.bounds ? unwrappedLatLng : unwrappedLatLng.wrapped();
double zoom = camera.zoom.value_or(getZoom());
double angle = camera.angle ? -*camera.angle * util::DEG2RAD : getAngle();
double bearing = camera.bearing ? -*camera.bearing * util::DEG2RAD : getBearing();
double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch();
if (std::isnan(zoom) || std::isnan(angle) || std::isnan(pitch)) {
if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch)) {
return;
}
@@ -119,17 +119,17 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
pitch = util::clamp(pitch, state.min_pitch, state.max_pitch);
// Minimize rotation by taking the shorter path around the circle.
angle = _normalizeAngle(angle, state.angle);
state.angle = _normalizeAngle(state.angle, angle);
bearing = _normalizeAngle(bearing, state.bearing);
state.bearing = _normalizeAngle(state.bearing, bearing);
Duration duration = animation.duration ? *animation.duration : Duration::zero();
const double startScale = state.scale;
const double startAngle = state.angle;
const double startBearing = state.bearing;
const double startPitch = state.pitch;
state.panning = unwrappedLatLng != startLatLng;
state.scaling = scale != startScale;
state.rotating = angle != startAngle;
state.rotating = bearing != startBearing;
startTransition(camera, animation, [=](double t) {
Point<double> framePoint = util::interpolate(startPoint, endPoint, t);
@@ -137,8 +137,8 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
double frameScale = util::interpolate(startScale, scale, t);
state.setLatLngZoom(frameLatLng, state.scaleZoom(frameScale));
if (angle != startAngle) {
state.angle = util::wrap(util::interpolate(startAngle, angle, t), -M_PI, M_PI);
if (bearing != startBearing) {
state.bearing = util::wrap(util::interpolate(startBearing, bearing, t), -M_PI, M_PI);
}
if (pitch != startPitch) {
state.pitch = util::interpolate(startPitch, pitch, t);
@@ -162,10 +162,10 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
const EdgeInsets& padding = camera.padding;
const LatLng& latLng = camera.center.value_or(getLatLng(padding, LatLng::Unwrapped)).wrapped();
double zoom = camera.zoom.value_or(getZoom());
double angle = camera.angle ? -*camera.angle * util::DEG2RAD : getAngle();
double bearing = camera.bearing ? -*camera.bearing * util::DEG2RAD : getBearing();
double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch();
if (std::isnan(zoom) || std::isnan(angle) || std::isnan(pitch) || state.size.isEmpty()) {
if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch) || state.size.isEmpty()) {
return;
}
@@ -184,11 +184,11 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
pitch = util::clamp(pitch, state.min_pitch, state.max_pitch);
// Minimize rotation by taking the shorter path around the circle.
angle = _normalizeAngle(angle, state.angle);
state.angle = _normalizeAngle(state.angle, angle);
bearing = _normalizeAngle(bearing, state.bearing);
state.bearing = _normalizeAngle(state.bearing, bearing);
const double startZoom = state.scaleZoom(state.scale);
const double startAngle = state.angle;
const double startBearing = state.bearing;
const double startPitch = state.pitch;
/// w₀: Initial visible span, measured in pixels at the initial scale.
@@ -277,7 +277,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
const double startScale = state.scale;
state.panning = true;
state.scaling = true;
state.rotating = angle != startAngle;
state.rotating = bearing != startBearing;
startTransition(camera, animation, [=](double k) {
/// s: The distance traveled along the flight path, measured in
@@ -298,8 +298,8 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
LatLng frameLatLng = Projection::unproject(framePoint, startScale);
state.setLatLngZoom(frameLatLng, frameZoom);
if (angle != startAngle) {
state.angle = util::wrap(util::interpolate(startAngle, angle, k), -M_PI, M_PI);
if (bearing != startBearing) {
state.bearing = util::wrap(util::interpolate(startBearing, bearing, k), -M_PI, M_PI);
}
if (pitch != startPitch) {
state.pitch = util::interpolate(startPitch, pitch, k);
@@ -371,7 +371,7 @@ void Transform::setMaxPitch(double maxPitch) {
state.setMaxPitch(maxPitch);
}
#pragma mark - Angle
#pragma mark - Bearing
void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& animation) {
ScreenCoordinate center = getScreenCoordinate();
@@ -382,17 +382,17 @@ void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate&
// in the direction of the click.
if (distance < 200) {
const double heightOffset = -200;
const double rotateAngle = std::atan2(offset.y, offset.x);
center.x = first.x + std::cos(rotateAngle) * heightOffset;
center.y = first.y + std::sin(rotateAngle) * heightOffset;
const double rotateBearing = std::atan2(offset.y, offset.x);
center.x = first.x + std::cos(rotateBearing) * heightOffset;
center.y = first.y + std::sin(rotateBearing) * heightOffset;
}
const double angle = -(state.angle + util::angle_between(first - center, second - center)) * util::RAD2DEG;
easeTo(CameraOptions().withAngle(angle), animation);
const double bearing = -(state.bearing + util::angle_between(first - center, second - center)) * util::RAD2DEG;
easeTo(CameraOptions().withBearing(bearing), animation);
}
double Transform::getAngle() const {
return state.angle;
double Transform::getBearing() const {
return state.bearing;
}
#pragma mark - Pitch

View File

@@ -62,13 +62,10 @@ public:
/** Returns the zoom level. */
double getZoom() const;
// Angle
// Bearing
void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {});
/** Returns the angle of rotation.
@return The angle of rotation, measured in radians counterclockwise from
true north. */
double getAngle() const;
double getBearing() const;
// Pitch

View File

@@ -61,7 +61,7 @@ void TransformState::getProjMatrix(mat4& projMatrix, uint16_t nearZ, bool aligne
default: matrix::rotate_x(projMatrix, projMatrix, getPitch()); break;
}
matrix::rotate_z(projMatrix, projMatrix, getAngle() + getNorthOrientationAngle());
matrix::rotate_z(projMatrix, projMatrix, getBearing() + getNorthOrientationAngle());
const double dx = pixel_x() - size.width / 2.0f, dy = pixel_y() - size.height / 2.0f;
matrix::translate(projMatrix, projMatrix, dx, dy, 0);
@@ -86,10 +86,10 @@ void TransformState::getProjMatrix(mat4& projMatrix, uint16_t nearZ, bool aligne
// it is always <= 0.5 pixels.
if (aligned) {
const float xShift = float(size.width % 2) / 2, yShift = float(size.height % 2) / 2;
const double angleCos = std::cos(angle), angleSin = std::sin(angle);
const double bearingCos = std::cos(bearing), bearingSin = std::sin(bearing);
double devNull;
const float dxa = -std::modf(dx, &devNull) + angleCos * xShift + angleSin * yShift;
const float dya = -std::modf(dy, &devNull) + angleCos * yShift + angleSin * xShift;
const float dxa = -std::modf(dx, &devNull) + bearingCos * xShift + bearingSin * yShift;
const float dya = -std::modf(dy, &devNull) + bearingCos * yShift + bearingSin * xShift;
matrix::translate(projMatrix, projMatrix, dxa > 0.5 ? dxa - 1 : dxa, dya > 0.5 ? dya - 1 : dya, 0);
}
}
@@ -145,7 +145,7 @@ CameraOptions TransformState::getCameraOptions(const EdgeInsets& padding) const
.withCenter(center)
.withPadding(padding)
.withZoom(getZoom())
.withAngle(-angle * util::RAD2DEG)
.withBearing(-bearing * util::RAD2DEG)
.withPitch(pitch * util::RAD2DEG);
}
@@ -243,8 +243,8 @@ double TransformState::getMaxPitch() const {
#pragma mark - Rotation
float TransformState::getAngle() const {
return angle;
float TransformState::getBearing() const {
return bearing;
}
float TransformState::getFieldOfView() const {

View File

@@ -67,7 +67,7 @@ public:
double getMaxPitch() const;
// Rotation
float getAngle() const;
float getBearing() const;
float getFieldOfView() const;
float getCameraToCenterDistance() const;
float getPitch() const;
@@ -131,7 +131,7 @@ private:
// map position
double x = 0, y = 0;
double angle = 0;
double bearing = 0;
double scale = 1;
// This fov value is somewhat arbitrary. The altitude of the camera used
// to be defined as 1.5 screen heights above the ground, which was an

View File

@@ -21,7 +21,7 @@ std::array<float, 3> lightPosition(const EvaluatedLight& light, const TransformS
mat3 lightMat;
matrix::identity(lightMat);
if (light.get<LightAnchor>() == LightAnchorType::Viewport) {
matrix::rotate(lightMat, lightMat, -state.getAngle());
matrix::rotate(lightMat, lightMat, -state.getBearing());
}
matrix::transformMat3f(lightPos, lightPos, lightMat);
return lightPos;

View File

@@ -142,7 +142,7 @@ bool RenderCircleLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::CircleTranslate>(),
evaluated.get<style::CircleTranslateAnchor>(),
transformState.getAngle(),
transformState.getBearing(),
pixelsToTileUnits).value_or(queryGeometry);
// Evaluate functions

View File

@@ -74,7 +74,7 @@ void RenderCustomLayer::render(PaintParameters& paintParameters, RenderSource*)
parameters.latitude = state.getLatLng().latitude();
parameters.longitude = state.getLatLng().longitude();
parameters.zoom = state.getZoom();
parameters.bearing = -state.getAngle() * util::RAD2DEG;
parameters.bearing = -state.getBearing() * util::RAD2DEG;
parameters.pitch = state.getPitch();
parameters.fieldOfView = state.getFieldOfView();
mat4 projMatrix;

View File

@@ -218,7 +218,7 @@ bool RenderFillExtrusionLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::FillExtrusionTranslate>(),
evaluated.get<style::FillExtrusionTranslateAnchor>(),
transformState.getAngle(),
transformState.getBearing(),
pixelsToTileUnits);
return util::polygonIntersectsMultiPolygon(translatedQueryGeometry.value_or(queryGeometry), feature.getGeometries());

View File

@@ -233,7 +233,7 @@ bool RenderFillLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::FillTranslate>(),
evaluated.get<style::FillTranslateAnchor>(),
transformState.getAngle(),
transformState.getBearing(),
pixelsToTileUnits);
return util::polygonIntersectsMultiPolygon(translatedQueryGeometry.value_or(queryGeometry), feature.getGeometries());

View File

@@ -32,7 +32,7 @@ const std::array<float, 2> RenderHillshadeLayer::getLatRange(const UnwrappedTile
const std::array<float, 2> RenderHillshadeLayer::getLight(const PaintParameters& parameters){
float azimuthal = evaluated.get<HillshadeIlluminationDirection>() * util::DEG2RAD;
if (evaluated.get<HillshadeIlluminationAnchor>() == HillshadeIlluminationAnchorType::Viewport) azimuthal = azimuthal - parameters.state.getAngle();
if (evaluated.get<HillshadeIlluminationAnchor>() == HillshadeIlluminationAnchorType::Viewport) azimuthal = azimuthal - parameters.state.getBearing();
return {{evaluated.get<HillshadeExaggeration>(), azimuthal}};
}

View File

@@ -207,7 +207,7 @@ bool RenderLineLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::LineTranslate>(),
evaluated.get<style::LineTranslateAnchor>(),
transformState.getAngle(),
transformState.getBearing(),
pixelsToTileUnits);
// Evaluate function

View File

@@ -379,8 +379,8 @@ void RenderSymbolLayer::sortRenderTiles(const TransformState& state) {
Point<float> pa(a.get().id.canonical.x, a.get().id.canonical.y);
Point<float> pb(b.get().id.canonical.x, b.get().id.canonical.y);
auto par = util::rotate(pa, state.getAngle());
auto pbr = util::rotate(pb, state.getAngle());
auto par = util::rotate(pa, state.getBearing());
auto pbr = util::rotate(pb, state.getBearing());
return std::tie(b.get().id.canonical.z, par.y, par.x) < std::tie(a.get().id.canonical.z, pbr.y, pbr.x);
});

View File

@@ -23,8 +23,8 @@ mat4 RenderTile::translateVtxMatrix(const mat4& tileMatrix,
mat4 vtxMatrix;
const float angle = inViewportPixelUnits ?
(anchor == TranslateAnchorType::Map ? state.getAngle() : 0) :
(anchor == TranslateAnchorType::Viewport ? -state.getAngle() : 0);
(anchor == TranslateAnchorType::Map ? state.getBearing() : 0) :
(anchor == TranslateAnchorType::Viewport ? -state.getBearing() : 0);
Point<float> translate = util::rotate(Point<float>{ translation[0], translation[1] }, angle);

View File

@@ -105,7 +105,7 @@ void Style::Impl::parse(const std::string& json_) {
name = parser.name;
defaultCamera.center = parser.latLng;
defaultCamera.zoom = parser.zoom;
defaultCamera.angle = parser.bearing;
defaultCamera.bearing = parser.bearing;
defaultCamera.pitch = parser.pitch;
setLight(std::make_unique<Light>(parser.light));

View File

@@ -399,7 +399,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>&
}
bucket.updateOpacity();
bucket.sortFeatures(state.getAngle());
bucket.sortFeatures(state.getBearing());
auto retainedData = retainedQueryData.find(bucket.bucketInstanceId);
if (retainedData != retainedQueryData.end()) {
retainedData->second.featureSortOrder = bucket.featureSortOrder;

View File

@@ -418,7 +418,7 @@ TEST(Annotations, VisibleFeatures) {
}
// Change bearing *after* adding annotations causes them to be reordered.
test.map.jumpTo(CameraOptions().withAngle(45.0));
test.map.jumpTo(CameraOptions().withBearing(45.0));
test.frontend.render(test.map);
auto features = test.frontend.getRenderer()->queryRenderedFeatures(box, {});
@@ -428,7 +428,7 @@ TEST(Annotations, VisibleFeatures) {
features.erase(std::unique(features.begin(), features.end(), sameID), features.end());
EXPECT_EQ(features.size(), ids.size());
test.map.jumpTo(CameraOptions().withZoom(4.0).withAngle(0.0));
test.map.jumpTo(CameraOptions().withZoom(4.0).withBearing(0.0));
test.frontend.render(test.map);
features = test.frontend.getRenderer()->queryRenderedFeatures(box);
std::sort(features.begin(), features.end(), sortID);

View File

@@ -64,7 +64,7 @@ TEST(Map, RendererState) {
double bearingInDegrees = 30.0;
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.jumpTo(CameraOptions().withCenter(coordinate).withZoom(zoom).withPitch(pitchInDegrees).withAngle(bearingInDegrees));
test.map.jumpTo(CameraOptions().withCenter(coordinate).withZoom(zoom).withPitch(pitchInDegrees).withBearing(bearingInDegrees));
test.runLoop.runOnce();
test.frontend.render(test.map);
@@ -75,7 +75,7 @@ TEST(Map, RendererState) {
EXPECT_NEAR(options.center->longitude(), coordinate.longitude(), 1e-7);
ASSERT_DOUBLE_EQ(*options.zoom, zoom);
ASSERT_DOUBLE_EQ(*options.pitch, pitchInDegrees);
EXPECT_NEAR(*options.angle, bearingInDegrees, 1e-7);
EXPECT_NEAR(*options.bearing, bearingInDegrees, 1e-7);
{
const LatLng& latLng = test.frontend.latLngForPixel(ScreenCoordinate { 0, 0 });
@@ -148,7 +148,7 @@ TEST(Map, LatLngBoundsToCamera) {
EXPECT_NEAR(*virtualCamera.zoom, 1.55467, 1e-5);
}
TEST(Map, LatLngBoundsToCameraWithAngle) {
TEST(Map, LatLngBoundsToCameraWithBearing) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0));
@@ -158,10 +158,10 @@ TEST(Map, LatLngBoundsToCameraWithAngle) {
CameraOptions virtualCamera = test.map.cameraForLatLngBounds(bounds, {}, 35.0);
ASSERT_TRUE(bounds.contains(*virtualCamera.center));
EXPECT_NEAR(*virtualCamera.zoom, 1.21385, 1e-5);
EXPECT_NEAR(virtualCamera.angle.value_or(0), 35.0, 1e-5);
EXPECT_NEAR(virtualCamera.bearing.value_or(0), 35.0, 1e-5);
}
TEST(Map, LatLngBoundsToCameraWithAngleAndPitch) {
TEST(Map, LatLngBoundsToCameraWithBearingAndPitch) {
MapTest<> test;
test.map.jumpTo(CameraOptions().withCenter(LatLng { 40.712730, -74.005953 }).withZoom(16.0));
@@ -172,7 +172,7 @@ TEST(Map, LatLngBoundsToCameraWithAngleAndPitch) {
ASSERT_TRUE(bounds.contains(*virtualCamera.center));
EXPECT_NEAR(*virtualCamera.zoom, 13.66272, 1e-5);
ASSERT_DOUBLE_EQ(*virtualCamera.pitch, 20.0);
EXPECT_NEAR(virtualCamera.angle.value_or(0), 35.0, 1e-5);
EXPECT_NEAR(virtualCamera.bearing.value_or(0), 35.0, 1e-5);
}
TEST(Map, LatLngsToCamera) {
@@ -181,19 +181,19 @@ TEST(Map, LatLngsToCamera) {
std::vector<LatLng> latLngs{{ 40.712730, 74.005953 }, {15.68169,73.499857}, {30.82678, 83.4082}};
CameraOptions virtualCamera = test.map.cameraForLatLngs(latLngs, {}, 23.0);
EXPECT_NEAR(virtualCamera.angle.value_or(0), 23.0, 1e-5);
EXPECT_NEAR(virtualCamera.bearing.value_or(0), 23.0, 1e-5);
EXPECT_NEAR(virtualCamera.zoom.value_or(0), 2.75434, 1e-5);
EXPECT_NEAR(virtualCamera.center->latitude(), 28.49288, 1e-5);
EXPECT_NEAR(virtualCamera.center->longitude(), 74.97437, 1e-5);
}
TEST(Map, LatLngsToCameraWithAngleAndPitch) {
TEST(Map, LatLngsToCameraWithBearingAndPitch) {
MapTest<> test;
std::vector<LatLng> latLngs{{ 40.712730, 74.005953 }, {15.68169,73.499857}, {30.82678, 83.4082}};
CameraOptions virtualCamera = test.map.cameraForLatLngs(latLngs, {}, 23, 20);
EXPECT_NEAR(virtualCamera.angle.value_or(0), 23.0, 1e-5);
EXPECT_NEAR(virtualCamera.bearing.value_or(0), 23.0, 1e-5);
EXPECT_NEAR(virtualCamera.zoom.value_or(0), 3.04378, 1e-5);
EXPECT_NEAR(virtualCamera.center->latitude(), 28.53718, 1e-5);
EXPECT_NEAR(virtualCamera.center->longitude(), 74.31746, 1e-5);
@@ -256,7 +256,7 @@ TEST(Map, SetStyleDefaultCamera) {
CameraOptions camera = test.map.getCameraOptions();
EXPECT_DOUBLE_EQ(*camera.zoom, 0.0);
EXPECT_DOUBLE_EQ(*camera.pitch, 0.0);
EXPECT_DOUBLE_EQ(*camera.angle, 0.0);
EXPECT_DOUBLE_EQ(*camera.bearing, 0.0);
EXPECT_EQ(*camera.center, LatLng {});
test.map.getStyle().loadJSON(util::read_file("test/fixtures/api/empty-zoomed.json"));

View File

@@ -61,19 +61,19 @@ TEST(Transform, InvalidBearing) {
ASSERT_DOUBLE_EQ(0, transform.getLatLng().longitude());
ASSERT_DOUBLE_EQ(0, transform.getZoom());
transform.jumpTo(CameraOptions().withZoom(1.0).withAngle(2.0));
transform.jumpTo(CameraOptions().withZoom(1.0).withBearing(2.0));
ASSERT_DOUBLE_EQ(0, transform.getLatLng().latitude());
ASSERT_DOUBLE_EQ(0, transform.getLatLng().longitude());
ASSERT_DOUBLE_EQ(1, transform.getZoom());
ASSERT_NEAR(-2.0 * util::DEG2RAD, transform.getAngle(), 1e-15);
ASSERT_NEAR(-2.0 * util::DEG2RAD, transform.getBearing(), 1e-15);
const double invalid = NAN;
transform.jumpTo(CameraOptions().withAngle(invalid));
transform.jumpTo(CameraOptions().withBearing(invalid));
ASSERT_DOUBLE_EQ(0, transform.getLatLng().latitude());
ASSERT_DOUBLE_EQ(0, transform.getLatLng().longitude());
ASSERT_DOUBLE_EQ(1, transform.getZoom());
ASSERT_NEAR(-2.0 * util::DEG2RAD, transform.getAngle(), 1e-15);
ASSERT_NEAR(-2.0 * util::DEG2RAD, transform.getBearing(), 1e-15);
}
TEST(Transform, IntegerZoom) {
@@ -196,7 +196,7 @@ TEST(Transform, Anchor) {
ASSERT_DOUBLE_EQ(latLng.latitude(), transform.getLatLng().latitude());
ASSERT_DOUBLE_EQ(latLng.longitude(), transform.getLatLng().longitude());
ASSERT_DOUBLE_EQ(10, transform.getZoom());
ASSERT_DOUBLE_EQ(0, transform.getAngle());
ASSERT_DOUBLE_EQ(0, transform.getBearing());
const LatLng anchorLatLng = transform.getState().screenCoordinateToLatLng(anchorPoint);
ASSERT_NE(latLng.latitude(), anchorLatLng.latitude());
@@ -247,18 +247,18 @@ TEST(Transform, Anchor) {
ASSERT_NE(latLng.latitude(), transform.getLatLng().latitude());
ASSERT_NE(latLng.longitude(), transform.getLatLng().longitude());
transform.jumpTo(CameraOptions().withCenter(latLng).withZoom(10.0).withAngle(-45.0));
ASSERT_NEAR(M_PI_4, transform.getAngle(), 0.000001);
transform.jumpTo(CameraOptions().withCenter(latLng).withZoom(10.0).withBearing(-45.0));
ASSERT_NEAR(M_PI_4, transform.getBearing(), 0.000001);
ASSERT_DOUBLE_EQ(latLng.latitude(), transform.getLatLng().latitude());
ASSERT_DOUBLE_EQ(latLng.longitude(), transform.getLatLng().longitude());
transform.jumpTo(CameraOptions().withAngle(0.0));
ASSERT_DOUBLE_EQ(0, transform.getAngle());
transform.jumpTo(CameraOptions().withBearing(0.0));
ASSERT_DOUBLE_EQ(0, transform.getBearing());
ASSERT_DOUBLE_EQ(latLng.latitude(), transform.getLatLng().latitude());
ASSERT_DOUBLE_EQ(latLng.longitude(), transform.getLatLng().longitude());
transform.jumpTo(CameraOptions().withAngle(45.0).withAnchor(anchorPoint));
ASSERT_NEAR(-45.0 * util::DEG2RAD, transform.getAngle(), 0.000001);
transform.jumpTo(CameraOptions().withBearing(45.0).withAnchor(anchorPoint));
ASSERT_NEAR(-45.0 * util::DEG2RAD, transform.getBearing(), 0.000001);
ASSERT_NEAR(anchorLatLng.latitude(), transform.getLatLng().latitude(), 1);
ASSERT_NEAR(anchorLatLng.longitude(), transform.getLatLng().longitude(), 1);

View File

@@ -33,7 +33,7 @@ TEST(Style, Properties) {
style.loadJSON(R"STYLE({"bearing": 24})STYLE");
ASSERT_EQ("", style.getName());
ASSERT_EQ(LatLng {}, *style.getDefaultCamera().center);
ASSERT_EQ(24, *style.getDefaultCamera().angle);
ASSERT_EQ(24, *style.getDefaultCamera().bearing);
style.loadJSON(R"STYLE({"zoom": 13.3})STYLE");
ASSERT_EQ("", style.getName());
@@ -55,7 +55,7 @@ TEST(Style, Properties) {
ASSERT_EQ("", style.getName());
ASSERT_EQ(LatLng {}, *style.getDefaultCamera().center);
ASSERT_EQ(0, *style.getDefaultCamera().zoom);
ASSERT_EQ(0, *style.getDefaultCamera().angle);
ASSERT_EQ(0, *style.getDefaultCamera().bearing);
ASSERT_EQ(0, *style.getDefaultCamera().pitch);
}

View File

@@ -35,7 +35,7 @@ TEST(TileCover, Pitch) {
transform.resize({ 512, 512 });
// slightly offset center so that tile order is better defined
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.1, -0.1, }).withZoom(2.0).withAngle(5.0).withPitch(40.0));
transform.jumpTo(CameraOptions().withCenter(LatLng { 0.1, -0.1, }).withZoom(2.0).withBearing(5.0).withPitch(40.0));
EXPECT_EQ((std::vector<UnwrappedTileID>{
{ 2, 1, 1 }, { 2, 2, 1 }, { 2, 1, 2 }, { 2, 2, 2 }