Rename angle to bearing

This commit is contained in:
Leith Bade
2014-11-06 21:08:18 +11:00
parent 4caf8b5b50
commit 38ec9f03c1
3 changed files with 32 additions and 45 deletions

View File

@@ -497,34 +497,25 @@ void JNICALL nativeRotateBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr,
native_map_view->getMap()->rotateBy(sx, sy, ex, ey, duration);
}
void JNICALL nativeSetAngle(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble angle, jdouble duration) {
VERBOSE("nativeSetAngle");
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble duration) {
VERBOSE("nativeSetBearing");
ASSERT(native_map_view_ptr != 0);
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
// TODO update java class
//native_map_view->getMap()->setAngle(angle, duration);
double degrees = -angle / M_PI * 180;
native_map_view->getMap()->setBearing(degrees, duration);
}
void JNICALL nativeSetAngle(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble angle, jdouble cx, jdouble cy) {
VERBOSE("nativeSetAngle");
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble cx, jdouble cy) {
VERBOSE("nativeSetBearing");
ASSERT(native_map_view_ptr != 0);
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
// TODO update java class
//native_map_view->getMap()->setAngle(angle, cx, cy);
double degrees = -angle / M_PI * 180;
native_map_view->getMap()->setBearing(degrees, cx, cy);
}
jdouble JNICALL nativeGetAngle(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
VERBOSE("nativeGetAngle");
jdouble JNICALL nativeGetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
VERBOSE("nativeGetBearing");
ASSERT(native_map_view_ptr != 0);
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
// TODO update java class
//return native_map_view->getMap()->getAngle();
double degrees = native_map_view->getMap()->getBearing();
return -degrees * M_PI / 180;
return native_map_view->getMap()->getBearing();
}
void JNICALL nativeResetNorth(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
@@ -732,9 +723,9 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
{ "nativeGetMinZoom", "(J)D", reinterpret_cast<void*>(&nativeGetMinZoom) },
{ "nativeGetMaxZoom", "(J)D", reinterpret_cast<void*>(&nativeGetMaxZoom) },
{ "nativeRotateBy", "(JDDDDD)V", reinterpret_cast<void*>(&nativeRotateBy) },
{ "nativeSetAngle", "(JDD)V", reinterpret_cast<void*>(static_cast<void JNICALL(*)(JNIEnv*,jobject,jlong,jdouble,jdouble)>(&nativeSetAngle)) },
{ "nativeSetAngle", "(JDDD)V", reinterpret_cast<void*>(static_cast<void JNICALL(*)(JNIEnv*,jobject,jlong,jdouble,jdouble,jdouble)>(&nativeSetAngle)) },
{ "nativeGetAngle", "(J)D", reinterpret_cast<void*>(&nativeGetAngle) },
{ "nativeSetBearing", "(JDD)V", reinterpret_cast<void*>(static_cast<void JNICALL(*)(JNIEnv*,jobject,jlong,jdouble,jdouble)>(&nativeSetBearing)) },
{ "nativeSetBearing", "(JDDD)V", reinterpret_cast<void*>(static_cast<void JNICALL(*)(JNIEnv*,jobject,jlong,jdouble,jdouble,jdouble)>(&nativeSetBearing)) },
{ "nativeGetBearing", "(J)D", reinterpret_cast<void*>(&nativeGetBearing) },
{ "nativeResetNorth", "(J)V", reinterpret_cast<void*>(&nativeResetNorth) },
{ "nativeStartRotating", "(J)V", reinterpret_cast<void*>(&nativeStartRotating) },
{ "nativeStopRotating", "(J)V", reinterpret_cast<void*>(&nativeStopRotating) },

View File

@@ -213,9 +213,7 @@ public class MapView extends SurfaceView {
}
public double getDirection() {
double direction = mNativeMapView.getAngle();
direction *= 180 / Math.PI;
double direction = -mNativeMapView.getBearing();
while (direction > 360)
direction -= 360;
@@ -232,9 +230,7 @@ public class MapView extends SurfaceView {
public void setDirection(double direction, boolean animated) {
double duration = animated ? 0.3 : 0.0;
direction *= Math.PI / 180;
mNativeMapView.setAngle(direction, duration);
mNativeMapView.setBearing(-direction, duration);
}
public void resetPosition() {
@@ -362,7 +358,7 @@ public class MapView extends SurfaceView {
if (savedInstanceState != null) {
lonlat = (LonLat) savedInstanceState
.getParcelable(STATE_CENTER_COORDINATE);
angle = savedInstanceState.getDouble(STATE_CENTER_DIRECTION);
bearing = savedInstanceState.getDouble(STATE_CENTER_DIRECTION);
zoom = savedInstanceState.getDouble(STATE_ZOOM_LEVEL);
setCenterCoordinate((LonLat) savedInstanceState
.getParcelable(STATE_CENTER_COORDINATE));
@@ -418,7 +414,7 @@ public class MapView extends SurfaceView {
public void onPause() {
Log.v(TAG, "onPause");
lonlat = mNativeMapView.getLonLat();
angle = mNativeMapView.getAngle();
bearing = mNativeMapView.getBearing();
zoom = mNativeMapView.getZoom();
mNativeMapView.stop();
}
@@ -429,14 +425,14 @@ public class MapView extends SurfaceView {
// TODO need to fix this in Map C++ code
// Seems map state gets reset when we start()
private LonLat lonlat;
private double angle, zoom;
private double bearing, zoom;
public void onResume() {
Log.v(TAG, "onResume");
mNativeMapView.start();
if (lonlat != null) {
mNativeMapView.setLonLat(lonlat);
mNativeMapView.setAngle(angle);
mNativeMapView.setBearing(bearing);
mNativeMapView.setZoom(zoom);
}
}
@@ -461,7 +457,7 @@ public class MapView extends SurfaceView {
mNativeMapView.createSurface(holder.getSurface());
if (lonlat != null) {
mNativeMapView.setLonLat(lonlat);
mNativeMapView.setAngle(angle);
mNativeMapView.setBearing(bearing);
mNativeMapView.setZoom(zoom);
}
}
@@ -834,10 +830,10 @@ public class MapView extends SurfaceView {
mNativeMapView.cancelTransitions();
// Rotate the map
double angle = mNativeMapView.getAngle();
angle -= detector.getRotationDegreesDelta() * Math.PI / 180.0;
Log.d("rotate", "rotate to " + angle);
mNativeMapView.setAngle(angle, detector.getFocusX(),
double bearing = mNativeMapView.getBearing();
bearing += detector.getRotationDegreesDelta() * Math.PI / 180.0;
Log.d("rotate", "rotate to " + bearing);
mNativeMapView.setBearing(bearing, detector.getFocusX(),
detector.getFocusY());
return true;

View File

@@ -295,20 +295,20 @@ class NativeMapView {
nativeRotateBy(mNativeMapViewPtr, sx, sy, ex, ey, duration);
}
public void setAngle(double angle) {
setAngle(angle, 0.0);
public void setBearing(double degrees) {
setBearing(degrees, 0.0);
}
public void setAngle(double angle, double duration) {
nativeSetAngle(mNativeMapViewPtr, angle, duration);
public void setBearing(double degrees, double duration) {
nativeSetBearing(mNativeMapViewPtr, degrees, duration);
}
public void setAngle(double angle, double cx, double cy) {
nativeSetAngle(mNativeMapViewPtr, angle, cx, cy);
public void setBearing(double degrees, double cx, double cy) {
nativeSetBearing(mNativeMapViewPtr, degrees, cx, cy);
}
public double getAngle() {
return nativeGetAngle(mNativeMapViewPtr);
public double getBearing() {
return nativeGetBearing(mNativeMapViewPtr);
}
public void resetNorth() {
@@ -452,13 +452,13 @@ class NativeMapView {
private native void nativeRotateBy(long nativeMapViewPtr, double sx,
double sy, double ex, double ey, double duration);
private native void nativeSetAngle(long nativeMapViewPtr, double angle,
private native void nativeSetBearing(long nativeMapViewPtr, double degrees,
double duration);
private native void nativeSetAngle(long nativeMapViewPtr, double angle,
private native void nativeSetBearing(long nativeMapViewPtr, double degrees,
double cx, double cy);
private native double nativeGetAngle(long nativeMapViewPtr);
private native double nativeGetBearing(long nativeMapViewPtr);
private native void nativeResetNorth(long nativeMapViewPtr);