From 904360ff693c6000b0149c8dd5fdb8f029139979 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek <hannes.janetzek@gmail.com> Date: Sun, 16 Feb 2014 04:22:36 +0100 Subject: [PATCH] rename MapPosition.angle -> bearing --- vtm-android-app | 2 +- .../src/org/oscim/gdx/client/GwtGdxMap.java | 8 +++--- vtm/src/org/oscim/core/MapPosition.java | 20 +++++++------- .../oscim/layers/marker/MarkerRenderer.java | 4 +-- .../tile/vector/labeling/LabelPlacement.java | 2 +- vtm/src/org/oscim/map/Animator.java | 6 ++--- vtm/src/org/oscim/map/ViewController.java | 26 +++++++++---------- vtm/src/org/oscim/map/Viewport.java | 6 ++--- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/vtm-android-app b/vtm-android-app index 0558c06e..873b9643 160000 --- a/vtm-android-app +++ b/vtm-android-app @@ -1 +1 @@ -Subproject commit 0558c06ed068929a53897dc4ab6b98d4a79e0192 +Subproject commit 873b964335364db5b524d505451aa1a68ca62b52 diff --git a/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java b/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java index b47933b6..1d42f453 100644 --- a/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java +++ b/vtm-gdx-html/src/org/oscim/gdx/client/GwtGdxMap.java @@ -95,7 +95,7 @@ class GwtGdxMap extends GdxMap { p.setPosition(lat, lon); log.debug("map position: " + p.x + "/" + p.y + " " + lat + "/" + lon); - p.angle = rotation; + p.bearing = rotation; p.tilt = tilt; mMap.setMapPosition(p); @@ -124,12 +124,12 @@ class GwtGdxMap extends GdxMap { mMap.viewport().getMapPosition(pos); int lat = (int) (MercatorProjection.toLatitude(pos.y) * 1000); int lon = (int) (MercatorProjection.toLongitude(pos.x) * 1000); - int rot = (int) (pos.angle); - rot = (int) (pos.angle) % 360; + int rot = (int) (pos.bearing); + rot = (int) (pos.bearing) % 360; //rot = rot < 0 ? -rot : rot; if (curZoom != pos.zoomLevel || curLat != lat || curLon != lon - || curTilt != rot || curRot != (int) (pos.angle)) { + || curTilt != rot || curRot != (int) (pos.bearing)) { curLat = lat; curLon = lon; diff --git a/vtm/src/org/oscim/core/MapPosition.java b/vtm/src/org/oscim/core/MapPosition.java index 52e8b160..fc6b40f0 100644 --- a/vtm/src/org/oscim/core/MapPosition.java +++ b/vtm/src/org/oscim/core/MapPosition.java @@ -29,7 +29,7 @@ public class MapPosition { public double scale; /** rotation angle */ - public float angle; + public float bearing; /** perspective tile */ public float tilt; @@ -41,7 +41,7 @@ public class MapPosition { this.x = 0.5; this.y = 0.5; this.zoomLevel = 1; - this.angle = 0; + this.bearing = 0; } public MapPosition(double latitude, double longitude, double scale) { @@ -74,22 +74,22 @@ public class MapPosition { this.x = other.x; this.y = other.y; - this.angle = other.angle; + this.bearing = other.bearing; this.scale = other.scale; this.tilt = other.tilt; this.zoomLevel = other.zoomLevel; } - public void set(double x, double y, double scale, float rotation, float tilt) { + public void set(double x, double y, double scale, float bearing, float tilt) { this.x = x; this.y = y; this.scale = scale; - while (rotation > 180) - rotation -= 360; - while (rotation < -180) - rotation += 360; - this.angle = rotation; + while (bearing > 180) + bearing -= 360; + while (bearing < -180) + bearing += 360; + this.bearing = bearing; this.tilt = tilt; this.zoomLevel = FastMath.log2((int) scale); @@ -127,7 +127,7 @@ public class MapPosition { scale = Math.min(zx, zy); x = minx + dx / 2; y = miny + dy / 2; - angle = 0; + bearing = 0; tilt = 0; } diff --git a/vtm/src/org/oscim/layers/marker/MarkerRenderer.java b/vtm/src/org/oscim/layers/marker/MarkerRenderer.java index e7eb5256..2885c86f 100644 --- a/vtm/src/org/oscim/layers/marker/MarkerRenderer.java +++ b/vtm/src/org/oscim/layers/marker/MarkerRenderer.java @@ -97,7 +97,7 @@ public class MarkerRenderer extends ElementRenderer { return; } - double angle = Math.toRadians(v.pos.angle); + double angle = Math.toRadians(v.pos.bearing); float cos = (float) Math.cos(angle); float sin = (float) Math.sin(angle); @@ -143,7 +143,7 @@ public class MarkerRenderer extends ElementRenderer { } /* keep position for current state */ mMapPosition.copy(v.pos); - mMapPosition.angle = -mMapPosition.angle; + mMapPosition.bearing = -mMapPosition.bearing; sort(mItems, 0, mItems.length); //log.debug(Arrays.toString(mItems)); diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java index 2bfe2669..5d074594 100644 --- a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java +++ b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java @@ -303,7 +303,7 @@ public class LabelPlacement { /* scale of tiles zoom-level relative to current position */ double scale = pos.scale / (1 << zoom); - double angle = Math.toRadians(pos.angle); + double angle = Math.toRadians(pos.bearing); float cos = (float) Math.cos(angle); float sin = (float) Math.sin(angle); diff --git a/vtm/src/org/oscim/map/Animator.java b/vtm/src/org/oscim/map/Animator.java index 41ee5199..c2926d20 100644 --- a/vtm/src/org/oscim/map/Animator.java +++ b/vtm/src/org/oscim/map/Animator.java @@ -82,7 +82,7 @@ public class Animator { mDeltaPos.set(longitudeToX(p.getLongitude()) - mStartPos.x, latitudeToY(p.getLatitude()) - mStartPos.y, newScale - mStartPos.scale, - -mStartPos.angle, + -mStartPos.bearing, -mStartPos.tilt); animStart(duration, ANIM_MOVE | ANIM_SCALE | ANIM_ROTATE | ANIM_TILT); @@ -123,7 +123,7 @@ public class Animator { mDeltaPos.set(pos.x - mStartPos.x, pos.y - mStartPos.y, pos.scale - mStartPos.scale, - mStartPos.angle - pos.angle, + mStartPos.bearing - pos.bearing, clamp(pos.tilt, 0, Viewport.MAX_TILT) - mStartPos.tilt); animStart(duration, ANIM_MOVE | ANIM_SCALE | ANIM_ROTATE | ANIM_TILT); @@ -229,7 +229,7 @@ public class Animator { } } if ((mState & ANIM_ROTATE) != 0) { - v.setRotation(mStartPos.angle + mDeltaPos.angle * adv); + v.setRotation(mStartPos.bearing + mDeltaPos.bearing * adv); } if ((mState & ANIM_TILT) != 0) { diff --git a/vtm/src/org/oscim/map/ViewController.java b/vtm/src/org/oscim/map/ViewController.java index 4d67c381..c7b9fabc 100644 --- a/vtm/src/org/oscim/map/ViewController.java +++ b/vtm/src/org/oscim/map/ViewController.java @@ -41,7 +41,7 @@ public class ViewController extends Viewport { mTmpMatrix.setScale(1 / mWidth, 1 / mWidth, 1 / mWidth); mProjMatrix.multiplyRhs(mTmpMatrix); - updateMatrix(); + updateMatrices(); } /** @@ -72,11 +72,11 @@ public class ViewController extends Viewport { } private Point applyRotation(double mx, double my) { - if (mPos.angle == 0) { + if (mPos.bearing == 0) { mMovePoint.x = mx; mMovePoint.y = my; } else { - double rad = Math.toRadians(mPos.angle); + double rad = Math.toRadians(mPos.bearing); double rcos = Math.cos(rad); double rsin = Math.sin(rad); mMovePoint.x = mx * rcos + my * rsin; @@ -136,17 +136,17 @@ public class ViewController extends Viewport { moveMap(x, y); - setRotation(mPos.angle + Math.toDegrees(radians)); + setRotation(mPos.bearing + Math.toDegrees(radians)); } public synchronized void setRotation(double degree) { - while (degree > 360) + while (degree > 180) degree -= 360; - while (degree < 0) + while (degree < -180) degree += 360; - mPos.angle = (float) degree; - updateMatrix(); + mPos.bearing = (float) degree; + updateMatrices(); } public synchronized boolean tiltMap(float move) { @@ -158,7 +158,7 @@ public class ViewController extends Viewport { if (tilt == mPos.tilt) return false; mPos.tilt = tilt; - updateMatrix(); + updateMatrices(); return true; } @@ -167,16 +167,16 @@ public class ViewController extends Viewport { mPos.x = mapPosition.x; mPos.y = mapPosition.y; mPos.tilt = mapPosition.tilt; - mPos.angle = mapPosition.angle; - updateMatrix(); + mPos.bearing = mapPosition.bearing; + updateMatrices(); } - private void updateMatrix() { + private void updateMatrices() { /* - view matrix: * 0. apply rotate * 1. apply tilt */ - mRotationMatrix.setRotation(mPos.angle, 0, 0, 1); + mRotationMatrix.setRotation(mPos.bearing, 0, 0, 1); mTmpMatrix.setRotation(mPos.tilt, 1, 0, 0); /* apply first rotation, then tilt */ diff --git a/vtm/src/org/oscim/map/Viewport.java b/vtm/src/org/oscim/map/Viewport.java index 83c747a2..0f2eadbe 100644 --- a/vtm/src/org/oscim/map/Viewport.java +++ b/vtm/src/org/oscim/map/Viewport.java @@ -75,7 +75,7 @@ public class Viewport { mPos.scale = MIN_SCALE; mPos.x = 0.5; mPos.y = 0.5; - mPos.angle = 0; + mPos.bearing = 0; mPos.tilt = 0; } @@ -92,10 +92,10 @@ public class Viewport { boolean changed = (pos.scale != mPos.scale || pos.x != mPos.x || pos.y != mPos.y - || pos.angle != mPos.angle + || pos.bearing != mPos.bearing || pos.tilt != mPos.tilt); - pos.angle = mPos.angle; + pos.bearing = mPos.bearing; pos.tilt = mPos.tilt; pos.x = mPos.x;