Improve code / xml formatting, closes #54
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -16,9 +16,6 @@
|
||||
*/
|
||||
package org.oscim.gdx.client;
|
||||
|
||||
import org.oscim.backend.GL;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
@@ -26,75 +23,80 @@ import com.google.gwt.dom.client.ImageElement;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
|
||||
import org.oscim.backend.GL;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
|
||||
public class GwtBitmap implements Bitmap {
|
||||
Pixmap pixmap;
|
||||
Image image;
|
||||
boolean disposable;
|
||||
Pixmap pixmap;
|
||||
Image image;
|
||||
boolean disposable;
|
||||
|
||||
public GwtBitmap(Image data) {
|
||||
ImageElement imageElement = ImageElement.as(data.getElement());
|
||||
pixmap = new Pixmap(imageElement);
|
||||
image = data;
|
||||
}
|
||||
public GwtBitmap(Image data) {
|
||||
ImageElement imageElement = ImageElement.as(data.getElement());
|
||||
pixmap = new Pixmap(imageElement);
|
||||
image = data;
|
||||
}
|
||||
|
||||
/** always argb8888 */
|
||||
public GwtBitmap(int width, int height, int format) {
|
||||
pixmap = new Pixmap(width, height, null);
|
||||
}
|
||||
/**
|
||||
* always argb8888
|
||||
*/
|
||||
public GwtBitmap(int width, int height, int format) {
|
||||
pixmap = new Pixmap(width, height, null);
|
||||
}
|
||||
|
||||
public GwtBitmap(String fileName) {
|
||||
FileHandle handle = Gdx.files.internal(fileName);
|
||||
pixmap = new Pixmap(handle);
|
||||
disposable = true;
|
||||
}
|
||||
public GwtBitmap(String fileName) {
|
||||
FileHandle handle = Gdx.files.internal(fileName);
|
||||
pixmap = new Pixmap(handle);
|
||||
disposable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return pixmap.getWidth();
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return pixmap.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return pixmap.getHeight();
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return pixmap.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
// FIXME this should be called at some point in time
|
||||
pixmap.dispose();
|
||||
@Override
|
||||
public void recycle() {
|
||||
// FIXME this should be called at some point in time
|
||||
pixmap.dispose();
|
||||
|
||||
if (image != null)
|
||||
RootPanel.get().remove(image);
|
||||
}
|
||||
if (image != null)
|
||||
RootPanel.get().remove(image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getPixels() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int[] getPixels() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseColor(int color) {
|
||||
}
|
||||
@Override
|
||||
public void eraseColor(int color) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
|
||||
Gdx.gl.glTexImage2D(GL.TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(),
|
||||
pixmap.getHeight(), 0,
|
||||
pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
|
||||
Gdx.gl.glTexImage2D(GL.TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(),
|
||||
pixmap.getHeight(), 0,
|
||||
pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
|
||||
|
||||
if (disposable || image != null) {
|
||||
//log.debug("dispose pixmap " + getWidth() + "/" + getHeight());
|
||||
pixmap.dispose();
|
||||
if (disposable || image != null) {
|
||||
//log.debug("dispose pixmap " + getWidth() + "/" + getHeight());
|
||||
pixmap.dispose();
|
||||
|
||||
if (image != null)
|
||||
RootPanel.get().remove(image);
|
||||
}
|
||||
}
|
||||
if (image != null)
|
||||
RootPanel.get().remove(image);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,54 +16,54 @@
|
||||
*/
|
||||
package org.oscim.gdx.client;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
import com.google.gwt.canvas.dom.client.Context2d;
|
||||
import com.google.gwt.canvas.dom.client.Context2d.LineJoin;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class GwtCanvas implements org.oscim.backend.canvas.Canvas {
|
||||
GwtBitmap bitmap;
|
||||
GwtBitmap bitmap;
|
||||
|
||||
public GwtCanvas() {
|
||||
// canvas comes with gdx pixmap
|
||||
}
|
||||
public GwtCanvas() {
|
||||
// canvas comes with gdx pixmap
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.bitmap = (GwtBitmap) bitmap;
|
||||
Context2d ctx = this.bitmap.pixmap.getContext();
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.bitmap = (GwtBitmap) bitmap;
|
||||
Context2d ctx = this.bitmap.pixmap.getContext();
|
||||
|
||||
ctx.clearRect(0, 0, this.bitmap.getWidth(), this.bitmap.getHeight());
|
||||
ctx.setLineJoin(LineJoin.BEVEL);
|
||||
}
|
||||
ctx.clearRect(0, 0, this.bitmap.getWidth(), this.bitmap.getHeight());
|
||||
ctx.setLineJoin(LineJoin.BEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(String string, float x, float y, Paint fill, Paint stroke) {
|
||||
if (bitmap == null) {
|
||||
//log.debug("no bitmap set");
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void drawText(String string, float x, float y, Paint fill, Paint stroke) {
|
||||
if (bitmap == null) {
|
||||
//log.debug("no bitmap set");
|
||||
return;
|
||||
}
|
||||
|
||||
GwtPaint p = (GwtPaint) fill;
|
||||
GwtPaint p = (GwtPaint) fill;
|
||||
|
||||
if (p.stroke && GwtGdxGraphics.NO_STROKE_TEXT)
|
||||
return;
|
||||
if (p.stroke && GwtGdxGraphics.NO_STROKE_TEXT)
|
||||
return;
|
||||
|
||||
Context2d ctx = bitmap.pixmap.getContext();
|
||||
ctx.setFont(p.font);
|
||||
Context2d ctx = bitmap.pixmap.getContext();
|
||||
ctx.setFont(p.font);
|
||||
|
||||
if (p.stroke) {
|
||||
ctx.setLineWidth(p.strokeWidth);
|
||||
ctx.setStrokeStyle(p.color);
|
||||
ctx.strokeText(string, (int) (x + 1), (int) (y + 1));
|
||||
} else {
|
||||
ctx.setFillStyle(p.color);
|
||||
ctx.fillText(string, (int) (x + 1), (int) (y + 1));
|
||||
}
|
||||
}
|
||||
if (p.stroke) {
|
||||
ctx.setLineWidth(p.strokeWidth);
|
||||
ctx.setStrokeStyle(p.color);
|
||||
ctx.strokeText(string, (int) (x + 1), (int) (y + 1));
|
||||
} else {
|
||||
ctx.setFillStyle(p.color);
|
||||
ctx.fillText(string, (int) (x + 1), (int) (y + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
}
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,62 +16,62 @@
|
||||
*/
|
||||
package org.oscim.gdx.client;
|
||||
|
||||
import java.io.InputStream;
|
||||
import com.google.gwt.canvas.client.Canvas;
|
||||
import com.google.gwt.canvas.dom.client.Context2d;
|
||||
import com.google.gwt.canvas.dom.client.TextMetrics;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
import com.google.gwt.canvas.client.Canvas;
|
||||
import com.google.gwt.canvas.dom.client.Context2d;
|
||||
import com.google.gwt.canvas.dom.client.TextMetrics;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class GwtGdxGraphics extends CanvasAdapter {
|
||||
|
||||
public static boolean NO_STROKE_TEXT = false;
|
||||
public static boolean NO_STROKE_TEXT = false;
|
||||
|
||||
static final Context2d ctx;
|
||||
static final Context2d ctx;
|
||||
|
||||
static {
|
||||
Canvas canvas = Canvas.createIfSupported();
|
||||
canvas.setCoordinateSpaceWidth(1);
|
||||
canvas.setCoordinateSpaceHeight(1);
|
||||
ctx = canvas.getContext2d();
|
||||
}
|
||||
static {
|
||||
Canvas canvas = Canvas.createIfSupported();
|
||||
canvas.setCoordinateSpaceWidth(1);
|
||||
canvas.setCoordinateSpaceHeight(1);
|
||||
ctx = canvas.getContext2d();
|
||||
}
|
||||
|
||||
public static synchronized float getTextWidth(String text, String font) {
|
||||
ctx.setFont(font);
|
||||
TextMetrics tm = ctx.measureText(text);
|
||||
return (float) tm.getWidth();
|
||||
}
|
||||
public static synchronized float getTextWidth(String text, String font) {
|
||||
ctx.setFont(font);
|
||||
TextMetrics tm = ctx.measureText(text);
|
||||
return (float) tm.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap decodeBitmapImpl(InputStream in) {
|
||||
//ImageData data = new ImageData();
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Bitmap decodeBitmapImpl(InputStream in) {
|
||||
//ImageData data = new ImageData();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadBitmapAssetImpl(String fileName) {
|
||||
return new GwtBitmap(fileName);
|
||||
}
|
||||
@Override
|
||||
public Bitmap loadBitmapAssetImpl(String fileName) {
|
||||
return new GwtBitmap(fileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint newPaintImpl() {
|
||||
return new GwtPaint();
|
||||
}
|
||||
@Override
|
||||
public Paint newPaintImpl() {
|
||||
return new GwtPaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap newBitmapImpl(int width, int height, int format) {
|
||||
return new GwtBitmap(width, height, format);
|
||||
}
|
||||
@Override
|
||||
public Bitmap newBitmapImpl(int width, int height, int format) {
|
||||
return new GwtBitmap(width, height, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.oscim.backend.canvas.Canvas newCanvasImpl() {
|
||||
return new GwtCanvas();
|
||||
}
|
||||
@Override
|
||||
public org.oscim.backend.canvas.Canvas newCanvasImpl() {
|
||||
return new GwtCanvas();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new GwtGdxGraphics());
|
||||
}
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new GwtGdxGraphics());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,106 +16,106 @@
|
||||
*/
|
||||
package org.oscim.gdx.client;
|
||||
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class GwtPaint implements Paint {
|
||||
|
||||
String color;
|
||||
boolean stroke;
|
||||
String color;
|
||||
boolean stroke;
|
||||
|
||||
float strokeWidth;
|
||||
Align mAlign;
|
||||
float strokeWidth;
|
||||
Align mAlign;
|
||||
|
||||
float fontSize = 12;
|
||||
float fontSize = 12;
|
||||
|
||||
private FontStyle fontStyle = FontStyle.NORMAL;
|
||||
//private FontFamily fontFamily = FontFamily.DEFAULT;
|
||||
private FontStyle fontStyle = FontStyle.NORMAL;
|
||||
//private FontFamily fontFamily = FontFamily.DEFAULT;
|
||||
|
||||
//String font = "12px sans-serif";
|
||||
String font = "13px Helvetica";
|
||||
//String font = "12px sans-serif";
|
||||
String font = "13px Helvetica";
|
||||
|
||||
//private int cap;
|
||||
//private int cap;
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
float a = ((color >>> 24) & 0xff) / 255f;
|
||||
int r = (color >>> 16) & 0xff;
|
||||
int g = (color >>> 8) & 0xff;
|
||||
int b = (color & 0xff);
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
float a = ((color >>> 24) & 0xff) / 255f;
|
||||
int r = (color >>> 16) & 0xff;
|
||||
int g = (color >>> 8) & 0xff;
|
||||
int b = (color & 0xff);
|
||||
|
||||
this.color = Pixmap.make(r, g, b, a);
|
||||
}
|
||||
this.color = Pixmap.make(r, g, b, a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeCap(Cap cap) {
|
||||
stroke = true;
|
||||
}
|
||||
@Override
|
||||
public void setStrokeCap(Cap cap) {
|
||||
stroke = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeWidth(float width) {
|
||||
stroke = true;
|
||||
strokeWidth = width;
|
||||
}
|
||||
@Override
|
||||
public void setStrokeWidth(float width) {
|
||||
stroke = true;
|
||||
strokeWidth = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(Style style) {
|
||||
}
|
||||
@Override
|
||||
public void setStyle(Style style) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextAlign(Align align) {
|
||||
mAlign = align;
|
||||
}
|
||||
@Override
|
||||
public void setTextAlign(Align align) {
|
||||
mAlign = align;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float size) {
|
||||
fontSize = size;
|
||||
buildFont();
|
||||
}
|
||||
@Override
|
||||
public void setTextSize(float size) {
|
||||
fontSize = size;
|
||||
buildFont();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
this.fontStyle = fontStyle;
|
||||
//this.fontFamily = fontFamily;
|
||||
buildFont();
|
||||
}
|
||||
@Override
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
this.fontStyle = fontStyle;
|
||||
//this.fontFamily = fontFamily;
|
||||
buildFont();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float measureText(String text) {
|
||||
return GwtGdxGraphics.getTextWidth(text, font);
|
||||
}
|
||||
@Override
|
||||
public float measureText(String text) {
|
||||
return GwtGdxGraphics.getTextWidth(text, font);
|
||||
}
|
||||
|
||||
// FIXME all estimates. no idea how to properly measure canvas text..
|
||||
@Override
|
||||
public float getFontHeight() {
|
||||
return 2 + fontSize + strokeWidth * 2;
|
||||
}
|
||||
// FIXME all estimates. no idea how to properly measure canvas text..
|
||||
@Override
|
||||
public float getFontHeight() {
|
||||
return 2 + fontSize + strokeWidth * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontDescent() {
|
||||
return 4 + strokeWidth;
|
||||
}
|
||||
@Override
|
||||
public float getFontDescent() {
|
||||
return 4 + strokeWidth;
|
||||
}
|
||||
|
||||
void buildFont() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
void buildFont() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (this.fontStyle == FontStyle.BOLD)
|
||||
sb.append("bold ");
|
||||
else if (this.fontStyle == FontStyle.ITALIC)
|
||||
sb.append("italic ");
|
||||
if (this.fontStyle == FontStyle.BOLD)
|
||||
sb.append("bold ");
|
||||
else if (this.fontStyle == FontStyle.ITALIC)
|
||||
sb.append("italic ");
|
||||
|
||||
sb.append(Math.round(this.fontSize));
|
||||
sb.append("px ");
|
||||
sb.append(Math.round(this.fontSize));
|
||||
sb.append("px ");
|
||||
|
||||
sb.append("Helvetica");
|
||||
sb.append("Helvetica");
|
||||
|
||||
this.font = sb.toString();
|
||||
this.font = sb.toString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,30 +19,30 @@ package org.oscim.gdx.client;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
public class MapConfig extends JavaScriptObject {
|
||||
protected MapConfig() {
|
||||
}
|
||||
protected MapConfig() {
|
||||
}
|
||||
|
||||
public static native MapConfig get()/*-{
|
||||
return $wnd.mapconfig;
|
||||
public static native MapConfig get()/*-{
|
||||
return $wnd.mapconfig;
|
||||
}-*/;
|
||||
|
||||
public final native double getLatitude() /*-{
|
||||
return this.latitude || 0;
|
||||
public final native double getLatitude() /*-{
|
||||
return this.latitude || 0;
|
||||
}-*/;
|
||||
|
||||
public final native double getLongitude() /*-{
|
||||
public final native double getLongitude() /*-{
|
||||
return this.longitude || 0;
|
||||
}-*/;
|
||||
|
||||
public final native int getZoom() /*-{
|
||||
public final native int getZoom() /*-{
|
||||
return this.zoom || 2;
|
||||
}-*/;
|
||||
|
||||
public final native String getTileSource() /*-{
|
||||
public final native String getTileSource() /*-{
|
||||
return this.tilesource;
|
||||
}-*/;
|
||||
|
||||
public final native int getTileSize() /*-{
|
||||
public final native int getTileSize() /*-{
|
||||
return this.tileSize || 256;
|
||||
}-*/;
|
||||
|
||||
|
||||
@@ -1,120 +1,120 @@
|
||||
package org.oscim.gdx.client;
|
||||
|
||||
import java.util.HashMap;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
import org.oscim.map.Map;
|
||||
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MapUrl extends Timer {
|
||||
private int curLon, curLat, curZoom, curTilt, curRot;
|
||||
private MapPosition pos = new MapPosition();
|
||||
private final Map mMap;
|
||||
private String mParams = "";
|
||||
private int curLon, curLat, curZoom, curTilt, curRot;
|
||||
private MapPosition pos = new MapPosition();
|
||||
private final Map mMap;
|
||||
private String mParams = "";
|
||||
|
||||
public MapUrl(Map map) {
|
||||
mMap = map;
|
||||
}
|
||||
public MapUrl(Map map) {
|
||||
mMap = map;
|
||||
}
|
||||
|
||||
public String getParam(String name) {
|
||||
return params.get(name);
|
||||
}
|
||||
public String getParam(String name) {
|
||||
return params.get(name);
|
||||
}
|
||||
|
||||
public final HashMap<String, String> params = new HashMap<String, String>();
|
||||
public final HashMap<String, String> params = new HashMap<String, String>();
|
||||
|
||||
public void parseUrl(MapPosition pos) {
|
||||
public void parseUrl(MapPosition pos) {
|
||||
|
||||
//String addOpts = "";
|
||||
if (Window.Location.getHash() == null)
|
||||
return;
|
||||
//String addOpts = "";
|
||||
if (Window.Location.getHash() == null)
|
||||
return;
|
||||
|
||||
String hash = Window.Location.getHash();
|
||||
hash = hash.substring(1);
|
||||
String[] urlParams = null;
|
||||
urlParams = hash.split("&");
|
||||
if (urlParams.length == 1)
|
||||
urlParams = hash.split(",");
|
||||
double lat = pos.getLatitude(), lon = pos.getLongitude();
|
||||
float rotation = pos.bearing;
|
||||
float tilt = pos.tilt;
|
||||
String hash = Window.Location.getHash();
|
||||
hash = hash.substring(1);
|
||||
String[] urlParams = null;
|
||||
urlParams = hash.split("&");
|
||||
if (urlParams.length == 1)
|
||||
urlParams = hash.split(",");
|
||||
double lat = pos.getLatitude(), lon = pos.getLongitude();
|
||||
float rotation = pos.bearing;
|
||||
float tilt = pos.tilt;
|
||||
|
||||
//String themeName = "";
|
||||
//String mapName = "";
|
||||
//String themeName = "";
|
||||
//String mapName = "";
|
||||
|
||||
int zoom = pos.zoomLevel;
|
||||
int zoom = pos.zoomLevel;
|
||||
|
||||
for (String p : urlParams) {
|
||||
try {
|
||||
if (p.startsWith("lat="))
|
||||
lat = Double.parseDouble(p.substring(4));
|
||||
for (String p : urlParams) {
|
||||
try {
|
||||
if (p.startsWith("lat="))
|
||||
lat = Double.parseDouble(p.substring(4));
|
||||
|
||||
else if (p.startsWith("lon="))
|
||||
lon = Double.parseDouble(p.substring(4));
|
||||
else if (p.startsWith("scale="))
|
||||
zoom = Integer.parseInt(p.substring(6));
|
||||
else if (p.startsWith("rot="))
|
||||
rotation = Float.parseFloat(p.substring(4));
|
||||
else if (p.startsWith("tilt="))
|
||||
tilt = Float.parseFloat(p.substring(5));
|
||||
// else if (p.startsWith("theme="))
|
||||
// themeName = p.substring(6);
|
||||
// else if (p.startsWith("map="))
|
||||
// mapName = p.substring(4);
|
||||
else {
|
||||
String[] opt = p.split("=");
|
||||
if (opt.length > 1)
|
||||
params.put(opt[0], opt[1]);
|
||||
else
|
||||
params.put(opt[0], null);
|
||||
else if (p.startsWith("lon="))
|
||||
lon = Double.parseDouble(p.substring(4));
|
||||
else if (p.startsWith("scale="))
|
||||
zoom = Integer.parseInt(p.substring(6));
|
||||
else if (p.startsWith("rot="))
|
||||
rotation = Float.parseFloat(p.substring(4));
|
||||
else if (p.startsWith("tilt="))
|
||||
tilt = Float.parseFloat(p.substring(5));
|
||||
// else if (p.startsWith("theme="))
|
||||
// themeName = p.substring(6);
|
||||
// else if (p.startsWith("map="))
|
||||
// mapName = p.substring(4);
|
||||
else {
|
||||
String[] opt = p.split("=");
|
||||
if (opt.length > 1)
|
||||
params.put(opt[0], opt[1]);
|
||||
else
|
||||
params.put(opt[0], null);
|
||||
|
||||
mParams += p + "&";
|
||||
mParams += p + "&";
|
||||
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
}
|
||||
}
|
||||
pos.setPosition(lat, lon);
|
||||
pos.setZoomLevel(zoom);
|
||||
pos.set(MercatorProjection.longitudeToX(lon),
|
||||
MercatorProjection.latitudeToY(lat),
|
||||
1 << zoom,
|
||||
rotation,
|
||||
tilt);
|
||||
}
|
||||
}
|
||||
pos.setPosition(lat, lon);
|
||||
pos.setZoomLevel(zoom);
|
||||
pos.set(MercatorProjection.longitudeToX(lon),
|
||||
MercatorProjection.latitudeToY(lat),
|
||||
1 << zoom,
|
||||
rotation,
|
||||
tilt);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mMap.viewport().getMapPosition(pos);
|
||||
int lat = (int) (MercatorProjection.toLatitude(pos.y) * 1000);
|
||||
int lon = (int) (MercatorProjection.toLongitude(pos.x) * 1000);
|
||||
int rot = (int) (pos.bearing);
|
||||
rot = (int) (pos.bearing) % 360;
|
||||
//rot = rot < 0 ? -rot : rot;
|
||||
@Override
|
||||
public void run() {
|
||||
mMap.viewport().getMapPosition(pos);
|
||||
int lat = (int) (MercatorProjection.toLatitude(pos.y) * 1000);
|
||||
int lon = (int) (MercatorProjection.toLongitude(pos.x) * 1000);
|
||||
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.bearing)) {
|
||||
if (curZoom != pos.zoomLevel || curLat != lat || curLon != lon
|
||||
|| curTilt != rot || curRot != (int) (pos.bearing)) {
|
||||
|
||||
curLat = lat;
|
||||
curLon = lon;
|
||||
curZoom = pos.zoomLevel;
|
||||
curTilt = (int) pos.tilt;
|
||||
curRot = rot;
|
||||
curLat = lat;
|
||||
curLon = lon;
|
||||
curZoom = pos.zoomLevel;
|
||||
curTilt = (int) pos.tilt;
|
||||
curRot = rot;
|
||||
|
||||
String newURL = Window.Location
|
||||
.createUrlBuilder()
|
||||
.setHash(mParams
|
||||
+ "scale=" + pos.zoomLevel
|
||||
+ "&rot=" + curRot
|
||||
+ "&tilt=" + curTilt
|
||||
+ "&lat=" + (curLat / 1000f)
|
||||
+ "&lon=" + (curLon / 1000f))
|
||||
.buildString();
|
||||
Window.Location.replace(newURL);
|
||||
}
|
||||
}
|
||||
String newURL = Window.Location
|
||||
.createUrlBuilder()
|
||||
.setHash(mParams
|
||||
+ "scale=" + pos.zoomLevel
|
||||
+ "&rot=" + curRot
|
||||
+ "&tilt=" + curTilt
|
||||
+ "&lat=" + (curLat / 1000f)
|
||||
+ "&lon=" + (curLon / 1000f))
|
||||
.buildString();
|
||||
Window.Location.replace(newURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user