summaryrefslogtreecommitdiff
path: root/platform/android/src
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2017-04-21 19:15:26 +0200
committerGitHub <noreply@github.com>2017-04-21 19:15:26 +0200
commited51462428466628b24f3d909bcfcd7cab130607 (patch)
tree507f9bc005c7f3413b302e3d56c81652eea02d2e /platform/android/src
parent3c23faf65ade59b62d41b68891bfac238acfc9ea (diff)
downloadqtlocation-mapboxgl-ed51462428466628b24f3d909bcfcd7cab130607.tar.gz
[android] - convert camera position values coming from core (#8794)
Diffstat (limited to 'platform/android/src')
-rw-r--r--platform/android/src/map/camera_position.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/platform/android/src/map/camera_position.cpp b/platform/android/src/map/camera_position.cpp
index 6286047257..0b46998878 100644
--- a/platform/android/src/map/camera_position.cpp
+++ b/platform/android/src/map/camera_position.cpp
@@ -6,9 +6,24 @@ namespace android {
jni::Object<CameraPosition> CameraPosition::New(jni::JNIEnv &env, mbgl::CameraOptions options) {
static auto constructor = CameraPosition::javaClass.GetConstructor<jni::Object<LatLng>, double, double, double>(env);
+
+ // wrap LatLng values coming from core
auto center = options.center.value();
center.wrap();
- return CameraPosition::javaClass.New(env, constructor, LatLng::New(env, center), options.zoom.value_or(0), options.pitch.value_or(0), options.angle.value_or(0));
+
+ // convert bearing, core ranges from [−π rad, π rad], android from 0 to 360 degrees
+ double bearing_degrees = options.angle.value_or(-M_PI) * 180.0 / M_PI;
+ while (bearing_degrees > 360) {
+ bearing_degrees -= 360;
+ }
+ while (bearing_degrees < 0) {
+ bearing_degrees += 360;
+ }
+
+ // convert tilt, core ranges from [0 rad, 1,0472 rad], android ranges from 0 to 60
+ double tilt_degrees = options.pitch.value_or(0) * 180 / M_PI;
+
+ return CameraPosition::javaClass.New(env, constructor, LatLng::New(env, center), options.zoom.value_or(0), tilt_degrees, bearing_degrees);
}
void CameraPosition::registerNative(jni::JNIEnv &env) {