use MapPosition.copy(other)

This commit is contained in:
Hannes Janetzek 2013-03-26 06:40:49 +01:00
parent 72741ced7f
commit a818e2f062
6 changed files with 23 additions and 14 deletions

View File

@ -15,7 +15,6 @@
*/ */
package org.oscim.core; package org.oscim.core;
/** A MapPosition Container. */ /** A MapPosition Container. */
public class MapPosition { public class MapPosition {
@ -70,6 +69,16 @@ public class MapPosition {
this.y = MercatorProjection.latitudeToPixelY(latitude, zoomLevel); this.y = MercatorProjection.latitudeToPixelY(latitude, zoomLevel);
} }
public void copy(MapPosition other) {
this.zoomLevel = other.zoomLevel;
this.scale = other.scale;
this.lat = other.lat;
this.lon = other.lon;
this.angle = other.angle;
this.x = other.x;
this.y = other.y;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();

View File

@ -109,7 +109,7 @@ public class PathOverlay extends Overlay {
int size = mSize; int size = mSize;
// keep position to render relative to current state // keep position to render relative to current state
updateMapPosition(); mMapPosition.copy(curPos);
// items are placed relative to scale == 1 // items are placed relative to scale == 1
mMapPosition.scale = 1; mMapPosition.scale = 1;

View File

@ -65,7 +65,7 @@ public class CustomOverlay extends RenderOverlay {
newData = true; newData = true;
// fix current MapPosition // fix current MapPosition
updateMapPosition(); mMapPosition.copy(curPos);
} }
} }

View File

@ -108,7 +108,7 @@ public class GridOverlay extends BasicOverlay {
public synchronized void update(MapPosition curPos, boolean positionChanged, public synchronized void update(MapPosition curPos, boolean positionChanged,
boolean tilesChanged, Matrices matrices) { boolean tilesChanged, Matrices matrices) {
updateMapPosition(); mMapPosition.copy(curPos);
// fix map position to tile coordinates // fix map position to tile coordinates
float size = Tile.TILE_SIZE; float size = Tile.TILE_SIZE;

View File

@ -117,12 +117,12 @@ public abstract class RenderOverlay {
setMatrix(curPos, m, true); setMatrix(curPos, m, true);
} }
/** // /**
* Utility: update mMapPosition // * Utility: update mMapPosition
* // *
* @return true if position has changed // * @return true if position has changed
*/ // */
protected boolean updateMapPosition() { // protected boolean updateMapPosition() {
return mMapView.getMapViewPosition().getMapPosition(mMapPosition); // return mMapView.getMapViewPosition().getMapPosition(mMapPosition);
} // }
} }

View File

@ -125,11 +125,11 @@ public class TestOverlay extends BasicOverlay {
public synchronized void update(MapPosition curPos, boolean positionChanged, public synchronized void update(MapPosition curPos, boolean positionChanged,
boolean tilesChanged, Matrices matrices) { boolean tilesChanged, Matrices matrices) {
// keep position constant (or update layer relative to new position) // keep position constant (or update layer relative to new position)
//mMapView.getMapViewPosition().getMapPosition(mMapPosition, null); //mMapPosition.copy(curPos);
if (first) { if (first) {
// fix at initial position // fix at initial position
updateMapPosition(); mMapPosition.copy(curPos);
first = false; first = false;
//((SymbolLayer) (layers.textureLayers)).prepare(); //((SymbolLayer) (layers.textureLayers)).prepare();