Improve code / xml formatting, #54
This commit is contained in:
parent
e793e8851b
commit
43ca550832
@ -5,98 +5,98 @@ import com.badlogic.gdx.jnigen.BuildTarget.TargetOs;
|
||||
import com.badlogic.gdx.jnigen.NativeCodeGenerator;
|
||||
|
||||
public class JniBuilder {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String[] headers = { ".", "libtess2/Include" };
|
||||
String[] sources = {
|
||||
"gl/utils.c",
|
||||
"libtess2/Source/bucketalloc.c",
|
||||
"libtess2/Source/dict.c",
|
||||
"libtess2/Source/geom.c",
|
||||
"libtess2/Source/mesh.c",
|
||||
"libtess2/Source/priorityq.c",
|
||||
"libtess2/Source/sweep.c",
|
||||
"libtess2/Source/tess.c",
|
||||
};
|
||||
public static void main(String[] args) throws Exception {
|
||||
String[] headers = {".", "libtess2/Include"};
|
||||
String[] sources = {
|
||||
"gl/utils.c",
|
||||
"libtess2/Source/bucketalloc.c",
|
||||
"libtess2/Source/dict.c",
|
||||
"libtess2/Source/geom.c",
|
||||
"libtess2/Source/mesh.c",
|
||||
"libtess2/Source/priorityq.c",
|
||||
"libtess2/Source/sweep.c",
|
||||
"libtess2/Source/tess.c",
|
||||
};
|
||||
|
||||
String cflags = " -Wall -std=c99 -O2 -ffast-math";
|
||||
cflags += " -DNDEBUG"; /* disable debug in libtess2 */
|
||||
String cflags = " -Wall -std=c99 -O2 -ffast-math";
|
||||
cflags += " -DNDEBUG"; /* disable debug in libtess2 */
|
||||
|
||||
//BuildTarget win32home = BuildTarget
|
||||
// .newDefaultTarget(TargetOs.Windows, false);
|
||||
//win32home.compilerPrefix = "";
|
||||
//win32home.buildFileName = "build-windows32home.xml";
|
||||
//win32home.excludeFromMasterBuildFile = true;
|
||||
//win32home.headerDirs = headers;
|
||||
//win32home.cIncludes = sources;
|
||||
//win32home.cFlags += cflags;
|
||||
//win32home.cppFlags += cflags;
|
||||
//BuildTarget win32home = BuildTarget
|
||||
// .newDefaultTarget(TargetOs.Windows, false);
|
||||
//win32home.compilerPrefix = "";
|
||||
//win32home.buildFileName = "build-windows32home.xml";
|
||||
//win32home.excludeFromMasterBuildFile = true;
|
||||
//win32home.headerDirs = headers;
|
||||
//win32home.cIncludes = sources;
|
||||
//win32home.cFlags += cflags;
|
||||
//win32home.cppFlags += cflags;
|
||||
|
||||
BuildTarget win32 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Windows, false);
|
||||
win32.headerDirs = headers;
|
||||
win32.cIncludes = sources;
|
||||
win32.cFlags += cflags;
|
||||
win32.cppFlags += cflags;
|
||||
BuildTarget win32 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Windows, false);
|
||||
win32.headerDirs = headers;
|
||||
win32.cIncludes = sources;
|
||||
win32.cFlags += cflags;
|
||||
win32.cppFlags += cflags;
|
||||
|
||||
BuildTarget win64 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Windows, true);
|
||||
win64.headerDirs = headers;
|
||||
win64.cIncludes = sources;
|
||||
win64.cFlags += cflags;
|
||||
win64.cppFlags += cflags;
|
||||
BuildTarget win64 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Windows, true);
|
||||
win64.headerDirs = headers;
|
||||
win64.cIncludes = sources;
|
||||
win64.cFlags += cflags;
|
||||
win64.cppFlags += cflags;
|
||||
|
||||
BuildTarget lin32 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Linux, false);
|
||||
lin32.headerDirs = headers;
|
||||
lin32.cIncludes = sources;
|
||||
lin32.cFlags += cflags;
|
||||
lin32.cppFlags += cflags;
|
||||
BuildTarget lin32 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Linux, false);
|
||||
lin32.headerDirs = headers;
|
||||
lin32.cIncludes = sources;
|
||||
lin32.cFlags += cflags;
|
||||
lin32.cppFlags += cflags;
|
||||
|
||||
BuildTarget lin64 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Linux, true);
|
||||
lin64.headerDirs = headers;
|
||||
lin64.cIncludes = sources;
|
||||
lin64.cFlags += cflags;
|
||||
lin64.cppFlags += cflags;
|
||||
BuildTarget lin64 = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Linux, true);
|
||||
lin64.headerDirs = headers;
|
||||
lin64.cIncludes = sources;
|
||||
lin64.cFlags += cflags;
|
||||
lin64.cppFlags += cflags;
|
||||
|
||||
BuildTarget mac = BuildTarget
|
||||
.newDefaultTarget(TargetOs.MacOsX, false);
|
||||
mac.headerDirs = headers;
|
||||
mac.cIncludes = sources;
|
||||
mac.cFlags += cflags;
|
||||
mac.cppFlags += cflags;
|
||||
mac.linkerFlags += " -framework CoreServices -framework Carbon";
|
||||
BuildTarget mac = BuildTarget
|
||||
.newDefaultTarget(TargetOs.MacOsX, false);
|
||||
mac.headerDirs = headers;
|
||||
mac.cIncludes = sources;
|
||||
mac.cFlags += cflags;
|
||||
mac.cppFlags += cflags;
|
||||
mac.linkerFlags += " -framework CoreServices -framework Carbon";
|
||||
|
||||
BuildTarget android = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Android, false);
|
||||
android.headerDirs = headers;
|
||||
android.cIncludes = sources;
|
||||
android.cFlags += cflags;
|
||||
android.cppFlags += cflags;
|
||||
android.linkerFlags += " -llog";
|
||||
BuildTarget android = BuildTarget
|
||||
.newDefaultTarget(TargetOs.Android, false);
|
||||
android.headerDirs = headers;
|
||||
android.cIncludes = sources;
|
||||
android.cFlags += cflags;
|
||||
android.cppFlags += cflags;
|
||||
android.linkerFlags += " -llog";
|
||||
|
||||
BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false);
|
||||
ios.headerDirs = headers;
|
||||
ios.cIncludes = sources;
|
||||
ios.cFlags += cflags;
|
||||
ios.cppFlags += cflags;
|
||||
BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false);
|
||||
ios.headerDirs = headers;
|
||||
ios.cIncludes = sources;
|
||||
ios.cFlags += cflags;
|
||||
ios.cppFlags += cflags;
|
||||
|
||||
new NativeCodeGenerator().generate();
|
||||
new NativeCodeGenerator().generate();
|
||||
|
||||
new AntScriptGenerator()
|
||||
.generate(new BuildConfig("vtm-jni"),
|
||||
android,
|
||||
lin64,
|
||||
lin32,
|
||||
mac,
|
||||
ios,
|
||||
//win32home,
|
||||
win32,
|
||||
win64
|
||||
);
|
||||
new AntScriptGenerator()
|
||||
.generate(new BuildConfig("vtm-jni"),
|
||||
android,
|
||||
lin64,
|
||||
lin32,
|
||||
mac,
|
||||
ios,
|
||||
//win32home,
|
||||
win32,
|
||||
win64
|
||||
);
|
||||
|
||||
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v clean");
|
||||
// BuildExecutor.executeAnt("jni/build-linux64.xml", "-v");
|
||||
// BuildExecutor.executeAnt("jni/build.xml", "pack-natives -v");
|
||||
}
|
||||
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v clean");
|
||||
// BuildExecutor.executeAnt("jni/build-linux64.xml", "-v");
|
||||
// BuildExecutor.executeAnt("jni/build.xml", "pack-natives -v");
|
||||
}
|
||||
}
|
||||
|
@ -1,265 +1,277 @@
|
||||
package org.oscim.utils;
|
||||
|
||||
public class TessJNI {
|
||||
private long inst;
|
||||
private long inst;
|
||||
|
||||
public TessJNI() {
|
||||
inst = newTess(0);
|
||||
}
|
||||
public TessJNI() {
|
||||
inst = newTess(0);
|
||||
}
|
||||
|
||||
public TessJNI(int bucketSize) {
|
||||
inst = newTess(bucketSize);
|
||||
}
|
||||
public TessJNI(int bucketSize) {
|
||||
inst = newTess(bucketSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
dispose();
|
||||
}
|
||||
@Override
|
||||
protected void finalize() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (inst != 0) {
|
||||
freeTess(inst);
|
||||
inst = 0;
|
||||
}
|
||||
}
|
||||
public void dispose() {
|
||||
if (inst != 0) {
|
||||
freeTess(inst);
|
||||
inst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected long instance() {
|
||||
return inst;
|
||||
}
|
||||
protected long instance() {
|
||||
return inst;
|
||||
}
|
||||
|
||||
/**
|
||||
* See OpenGL Red Book for description of the winding rules
|
||||
* http://www.glprogramming.com/red/chapter11.html
|
||||
*/
|
||||
public static final class WindingRule {
|
||||
public static final int ODD = 0;
|
||||
public static final int NONZERO = 1;
|
||||
public static final int POSITIVE = 2;
|
||||
public static final int NEGATIVE = 3;
|
||||
public static final int ABS_GEQ_TWO = 4;
|
||||
}
|
||||
/**
|
||||
* See OpenGL Red Book for description of the winding rules
|
||||
* http://www.glprogramming.com/red/chapter11.html
|
||||
*/
|
||||
public static final class WindingRule {
|
||||
public static final int ODD = 0;
|
||||
public static final int NONZERO = 1;
|
||||
public static final int POSITIVE = 2;
|
||||
public static final int NEGATIVE = 3;
|
||||
public static final int ABS_GEQ_TWO = 4;
|
||||
}
|
||||
|
||||
public static final class ElementType {
|
||||
public static final int POLYGONS = 0;
|
||||
public static final int CONNECTED_POLYGONS = 1;
|
||||
public static final int BOUNDARY_CONTOURS = 2;
|
||||
}
|
||||
public static final class ElementType {
|
||||
public static final int POLYGONS = 0;
|
||||
public static final int CONNECTED_POLYGONS = 1;
|
||||
public static final int BOUNDARY_CONTOURS = 2;
|
||||
}
|
||||
|
||||
public void addContour2D(float[] points) {
|
||||
addContour2D(points, 0, points.length >> 1);
|
||||
}
|
||||
public void addContour2D(float[] points) {
|
||||
addContour2D(points, 0, points.length >> 1);
|
||||
}
|
||||
|
||||
public void addContour2D(float[] points, int offset, int length) {
|
||||
if (length < 6)
|
||||
return;
|
||||
if ((length % 2 != 0) || (offset % 2 != 0) || (points.length >> 1) < (offset + length))
|
||||
throw new IllegalArgumentException("Invalid input: length:" + length
|
||||
+ ", offset:" + offset
|
||||
+ ", points.length:" + points.length);
|
||||
addContour(inst, 2, points, 8, offset, length);
|
||||
}
|
||||
public void addContour2D(float[] points, int offset, int length) {
|
||||
if (length < 6)
|
||||
return;
|
||||
if ((length % 2 != 0) || (offset % 2 != 0) || (points.length >> 1) < (offset + length))
|
||||
throw new IllegalArgumentException("Invalid input: length:" + length
|
||||
+ ", offset:" + offset
|
||||
+ ", points.length:" + points.length);
|
||||
addContour(inst, 2, points, 8, offset, length);
|
||||
}
|
||||
|
||||
public void addContour2D(int[] index, float[] contour) {
|
||||
addMultiContour2D(inst, index, contour, 0, index.length);
|
||||
}
|
||||
public void addContour2D(int[] index, float[] contour) {
|
||||
addMultiContour2D(inst, index, contour, 0, index.length);
|
||||
}
|
||||
|
||||
public void addContour2D(int[] index, float[] contour, int idxStart, int idxEnd) {
|
||||
addMultiContour2D(inst, index, contour, idxStart, idxEnd);
|
||||
}
|
||||
public void addContour2D(int[] index, float[] contour, int idxStart, int idxEnd) {
|
||||
addMultiContour2D(inst, index, contour, idxStart, idxEnd);
|
||||
}
|
||||
|
||||
public boolean tesselate() {
|
||||
return tessContour2D(inst,
|
||||
TessJNI.WindingRule.POSITIVE,
|
||||
TessJNI.ElementType.POLYGONS,
|
||||
3, 2) == 1;
|
||||
}
|
||||
public boolean tesselate() {
|
||||
return tessContour2D(inst,
|
||||
TessJNI.WindingRule.POSITIVE,
|
||||
TessJNI.ElementType.POLYGONS,
|
||||
3, 2) == 1;
|
||||
}
|
||||
|
||||
public boolean tesselate(int windingRule, int elementType) {
|
||||
return tessContour2D(inst, windingRule, elementType, 3, 2) == 1;
|
||||
}
|
||||
public boolean tesselate(int windingRule, int elementType) {
|
||||
return tessContour2D(inst, windingRule, elementType, 3, 2) == 1;
|
||||
}
|
||||
|
||||
public int getVertexCount() {
|
||||
return getVertexCount(inst);
|
||||
}
|
||||
public int getVertexCount() {
|
||||
return getVertexCount(inst);
|
||||
}
|
||||
|
||||
public int getElementCount() {
|
||||
return getElementCount(inst);
|
||||
}
|
||||
public int getElementCount() {
|
||||
return getElementCount(inst);
|
||||
}
|
||||
|
||||
public void getVertices(float[] out, int offset, int length) {
|
||||
getVertices(inst, out, offset, length);
|
||||
}
|
||||
public void getVertices(float[] out, int offset, int length) {
|
||||
getVertices(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getVertices(short[] out, int offset, int length, float scale) {
|
||||
getVerticesS(inst, out, offset, length, scale);
|
||||
}
|
||||
public void getVertices(short[] out, int offset, int length, float scale) {
|
||||
getVerticesS(inst, out, offset, length, scale);
|
||||
}
|
||||
|
||||
public void getElements(int[] out, int offset, int length) {
|
||||
getElements(inst, out, offset, length);
|
||||
}
|
||||
public void getElements(int[] out, int offset, int length) {
|
||||
getElements(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getElements(short[] out, int offset, int length) {
|
||||
getElementsS(inst, out, offset, length);
|
||||
}
|
||||
public void getElements(short[] out, int offset, int length) {
|
||||
getElementsS(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getVertexIndices(int[] out, int offset, int length) {
|
||||
getVertexIndices(inst, out, offset, length);
|
||||
}
|
||||
public void getVertexIndices(int[] out, int offset, int length) {
|
||||
getVertexIndices(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getElementsWithInputVertexIds(short[] dst, int dstOffset, int offset, int length) {
|
||||
getElementsWithInputVertexIds(inst, dst, dstOffset, offset, length);
|
||||
}
|
||||
public void getElementsWithInputVertexIds(short[] dst, int dstOffset, int offset, int length) {
|
||||
getElementsWithInputVertexIds(inst, dst, dstOffset, offset, length);
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
/*JNI
|
||||
#include <tesselator.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
void* heapAlloc( void* userData, unsigned int size ){
|
||||
TESS_NOTUSED( userData );
|
||||
return malloc( size );
|
||||
}
|
||||
void* heapRealloc( void *userData, void* ptr, unsigned int size ){
|
||||
TESS_NOTUSED( userData );
|
||||
return realloc( ptr, size );
|
||||
}
|
||||
void heapFree( void* userData, void* ptr ){
|
||||
TESS_NOTUSED( userData );
|
||||
free( ptr );
|
||||
}
|
||||
*/
|
||||
static native long newTess(int size); /* {
|
||||
if (size <= 0)
|
||||
return (long)tessNewTess(0);
|
||||
if (size > 10)
|
||||
size = 10;
|
||||
TESSalloc ma;
|
||||
memset(&ma, 0, sizeof(ma));
|
||||
ma.memalloc = heapAlloc;
|
||||
ma.memfree = heapFree;
|
||||
ma.memrealloc = heapRealloc;
|
||||
//ma.userData = (void*)&allocated;
|
||||
ma.meshEdgeBucketSize = 2 << size; // 512
|
||||
ma.meshVertexBucketSize = 2 << size; // 512
|
||||
ma.meshFaceBucketSize = 1 << size; // 256
|
||||
ma.dictNodeBucketSize = 2 << size; // 512
|
||||
ma.regionBucketSize = 1 << size; // 256
|
||||
ma.extraVertices = 8;
|
||||
//ma.extraVertices = 256;
|
||||
return (long)tessNewTess(&ma);
|
||||
} */
|
||||
static native void freeTess(long inst); /* {
|
||||
tessDeleteTess((TESStesselator*) inst);
|
||||
} */
|
||||
/**
|
||||
* Adds a contour to be tesselated.
|
||||
* The type of the vertex coordinates is assumed to be TESSreal.
|
||||
*
|
||||
* @param tess - pointer to tesselator object.
|
||||
* @param size - number of coordinates per vertex. Must be 2 or 3.
|
||||
* @param pointer - pointer to the first coordinate of the first vertex in the array.
|
||||
* @param stride - defines offset in bytes between consecutive vertices.
|
||||
* @param count - number of vertices in contour.
|
||||
*/
|
||||
static native void addContour(long inst, int size, float[] contour, int stride, int offset, int count);/* {
|
||||
tessAddContour((TESStesselator*) inst, size, contour + (offset * stride), stride, count);
|
||||
} */
|
||||
static native void addMultiContour2D(long inst, int[] index, float[] contour, int idxStart, int idxCount);/* {
|
||||
TESStesselator* tess = (TESStesselator*) inst;
|
||||
int offset = 0;
|
||||
// start at 0 to get the correct offset in contour..
|
||||
for (int i = 0; i < idxStart + idxCount; i++){
|
||||
int len = index[i];
|
||||
if ((len % 2 != 0) || (len < 0))
|
||||
break;
|
||||
if (len < 6 || i < idxStart) {
|
||||
offset += len;
|
||||
continue;
|
||||
}
|
||||
tessAddContour(tess, 2, contour + offset, 8, len >> 1);
|
||||
offset += len;
|
||||
}
|
||||
} */
|
||||
/**
|
||||
* Tesselate contours.
|
||||
*
|
||||
* @param tess - pointer to tesselator object.
|
||||
* @param windingRule - winding rules used for tesselation, must be one of TessWindingRule.
|
||||
* @param elementType - defines the tesselation result element type, must be one of TessElementType.
|
||||
* @param polySize - defines maximum vertices per polygons if output is polygons.
|
||||
* @param vertexSize - defines the number of coordinates in tesselation result vertex, must be 2 or 3.
|
||||
* @param normal - defines the normal of the input contours, of null the normal is calculated automatically.
|
||||
* @return 1 if succeed, 0 if failed.
|
||||
*/
|
||||
static native int tessContour2D(long inst, int windingRule, int elementType, int polySize, int vertexSize);/*{
|
||||
return tessTesselate((TESStesselator*) inst, windingRule, elementType, polySize, vertexSize, 0);
|
||||
} */
|
||||
static native int getVertexCount(long inst); /*{
|
||||
return tessGetVertexCount((TESStesselator*) inst);
|
||||
}*/
|
||||
/**
|
||||
* Returns pointer to first coordinate of first vertex.
|
||||
*/
|
||||
static native boolean getVertices(long inst, float[] out, int offset, int length);/*{
|
||||
const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
if (!vertices)
|
||||
return 0;
|
||||
memcpy(out, vertices + offset, length * sizeof(TESSreal));
|
||||
return 1;
|
||||
}*/
|
||||
/**
|
||||
* Returns pointer to first coordinate of first vertex.
|
||||
*/
|
||||
static native void getVerticesS(long inst, short[] out, int offset, int length, float scale);/*{
|
||||
const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)(vertices[offset++] * scale + 0.5f);
|
||||
}*/
|
||||
/**
|
||||
* Returns pointer to first vertex index.
|
||||
*
|
||||
* Vertex indices can be used to map the generated vertices to the original vertices.
|
||||
* Every point added using tessAddContour() will get a new index starting at 0.
|
||||
* New vertices generated at the intersections of segments are assigned value TESS_UNDEF.
|
||||
*/
|
||||
static native boolean getVertexIndices(long inst, int[] out, int offset, int length);/* {
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
if (!indices)
|
||||
return 0;
|
||||
memcpy(out, indices + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
} */
|
||||
/**
|
||||
* Returns number of elements in the the tesselated output.
|
||||
*/
|
||||
static native int getElementCount(long inst);/*{
|
||||
return tessGetElementCount((TESStesselator*) inst);
|
||||
}*/
|
||||
/**
|
||||
* Returns pointer to the first element.
|
||||
*/
|
||||
static native boolean getElements(long inst, int[] out, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
if (!elements)
|
||||
return 0;
|
||||
memcpy(out, elements + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
}*/
|
||||
/**
|
||||
* Returns pointer to the first element.
|
||||
*/
|
||||
static native void getElementsS(long inst, short[] out, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)elements[offset++];
|
||||
}*/
|
||||
/**
|
||||
* Returns list of triangles indices (or to the first element of convex polygons).
|
||||
*/
|
||||
static native void getElementsWithInputVertexIds(long inst, short[] out, int dstOffset, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[dstOffset++] = (short)(indices[elements[offset++]]);
|
||||
}*/
|
||||
}
|
||||
// @formatter:off
|
||||
/*JNI
|
||||
#include <tesselator.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
void* heapAlloc( void* userData, unsigned int size ){
|
||||
TESS_NOTUSED( userData );
|
||||
return malloc( size );
|
||||
}
|
||||
void* heapRealloc( void *userData, void* ptr, unsigned int size ){
|
||||
TESS_NOTUSED( userData );
|
||||
return realloc( ptr, size );
|
||||
}
|
||||
void heapFree( void* userData, void* ptr ){
|
||||
TESS_NOTUSED( userData );
|
||||
free( ptr );
|
||||
}
|
||||
*/
|
||||
static native long newTess(int size); /* {
|
||||
if (size <= 0)
|
||||
return (long)tessNewTess(0);
|
||||
if (size > 10)
|
||||
size = 10;
|
||||
TESSalloc ma;
|
||||
memset(&ma, 0, sizeof(ma));
|
||||
ma.memalloc = heapAlloc;
|
||||
ma.memfree = heapFree;
|
||||
ma.memrealloc = heapRealloc;
|
||||
//ma.userData = (void*)&allocated;
|
||||
ma.meshEdgeBucketSize = 2 << size; // 512
|
||||
ma.meshVertexBucketSize = 2 << size; // 512
|
||||
ma.meshFaceBucketSize = 1 << size; // 256
|
||||
ma.dictNodeBucketSize = 2 << size; // 512
|
||||
ma.regionBucketSize = 1 << size; // 256
|
||||
ma.extraVertices = 8;
|
||||
//ma.extraVertices = 256;
|
||||
return (long)tessNewTess(&ma);
|
||||
} */
|
||||
|
||||
static native void freeTess(long inst); /* {
|
||||
tessDeleteTess((TESStesselator*) inst);
|
||||
} */
|
||||
|
||||
/**
|
||||
* Adds a contour to be tesselated.
|
||||
* The type of the vertex coordinates is assumed to be TESSreal.
|
||||
*
|
||||
* @param tess - pointer to tesselator object.
|
||||
* @param size - number of coordinates per vertex. Must be 2 or 3.
|
||||
* @param pointer - pointer to the first coordinate of the first vertex in the array.
|
||||
* @param stride - defines offset in bytes between consecutive vertices.
|
||||
* @param count - number of vertices in contour.
|
||||
*/
|
||||
static native void addContour(long inst, int size, float[] contour, int stride, int offset, int count);/* {
|
||||
tessAddContour((TESStesselator*) inst, size, contour + (offset * stride), stride, count);
|
||||
} */
|
||||
|
||||
static native void addMultiContour2D(long inst, int[] index, float[] contour, int idxStart, int idxCount);/* {
|
||||
TESStesselator* tess = (TESStesselator*) inst;
|
||||
int offset = 0;
|
||||
// start at 0 to get the correct offset in contour..
|
||||
for (int i = 0; i < idxStart + idxCount; i++){
|
||||
int len = index[i];
|
||||
if ((len % 2 != 0) || (len < 0))
|
||||
break;
|
||||
if (len < 6 || i < idxStart) {
|
||||
offset += len;
|
||||
continue;
|
||||
}
|
||||
tessAddContour(tess, 2, contour + offset, 8, len >> 1);
|
||||
offset += len;
|
||||
}
|
||||
} */
|
||||
|
||||
/**
|
||||
* Tesselate contours.
|
||||
*
|
||||
* @param tess - pointer to tesselator object.
|
||||
* @param windingRule - winding rules used for tesselation, must be one of TessWindingRule.
|
||||
* @param elementType - defines the tesselation result element type, must be one of TessElementType.
|
||||
* @param polySize - defines maximum vertices per polygons if output is polygons.
|
||||
* @param vertexSize - defines the number of coordinates in tesselation result vertex, must be 2 or 3.
|
||||
* @param normal - defines the normal of the input contours, of null the normal is calculated automatically.
|
||||
* @return 1 if succeed, 0 if failed.
|
||||
*/
|
||||
static native int tessContour2D(long inst, int windingRule, int elementType, int polySize, int vertexSize);/*{
|
||||
return tessTesselate((TESStesselator*) inst, windingRule, elementType, polySize, vertexSize, 0);
|
||||
} */
|
||||
|
||||
static native int getVertexCount(long inst); /*{
|
||||
return tessGetVertexCount((TESStesselator*) inst);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to first coordinate of first vertex.
|
||||
*/
|
||||
static native boolean getVertices(long inst, float[] out, int offset, int length);/*{
|
||||
const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
if (!vertices)
|
||||
return 0;
|
||||
memcpy(out, vertices + offset, length * sizeof(TESSreal));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to first coordinate of first vertex.
|
||||
*/
|
||||
static native void getVerticesS(long inst, short[] out, int offset, int length, float scale);/*{
|
||||
const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)(vertices[offset++] * scale + 0.5f);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to first vertex index.
|
||||
* <p/>
|
||||
* Vertex indices can be used to map the generated vertices to the original vertices.
|
||||
* Every point added using tessAddContour() will get a new index starting at 0.
|
||||
* New vertices generated at the intersections of segments are assigned value TESS_UNDEF.
|
||||
*/
|
||||
static native boolean getVertexIndices(long inst, int[] out, int offset, int length);/* {
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
if (!indices)
|
||||
return 0;
|
||||
memcpy(out, indices + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
} */
|
||||
|
||||
/**
|
||||
* Returns number of elements in the the tesselated output.
|
||||
*/
|
||||
static native int getElementCount(long inst);/*{
|
||||
return tessGetElementCount((TESStesselator*) inst);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to the first element.
|
||||
*/
|
||||
static native boolean getElements(long inst, int[] out, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
if (!elements)
|
||||
return 0;
|
||||
memcpy(out, elements + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to the first element.
|
||||
*/
|
||||
static native void getElementsS(long inst, short[] out, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)elements[offset++];
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns list of triangles indices (or to the first element of convex polygons).
|
||||
*/
|
||||
static native void getElementsWithInputVertexIds(long inst, short[] out, int dstOffset, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[dstOffset++] = (short)(indices[elements[offset++]]);
|
||||
}*/
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class BaseMapActivity extends MapActivity {
|
||||
}
|
||||
mBaseLayer = mMap.setBaseMap(mTileSource);
|
||||
|
||||
/* set initial position on first run */
|
||||
/* set initial position on first run */
|
||||
MapPosition pos = new MapPosition();
|
||||
mMap.getMapPosition(pos);
|
||||
if (pos.x == 0.5 && pos.y == 0.5)
|
||||
|
@ -98,8 +98,8 @@ public class BitmapTileMapActivity extends MapActivity {
|
||||
} else {
|
||||
//mMapView.map().setMapPosition(p);
|
||||
p.setScale(2 + (1 << (int) (Math.random() * 13)));
|
||||
// p.setX((p.getX() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
// p.setY((p.getY() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
// p.setX((p.getX() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
// p.setY((p.getY() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
p.setX(MercatorProjection.longitudeToX(Math.random() * 180));
|
||||
p.setY(MercatorProjection.latitudeToY(Math.random() * 60));
|
||||
|
||||
|
@ -62,9 +62,9 @@ public class JeoIndoorMapActivity extends BaseMapActivity {
|
||||
showToast("load data");
|
||||
InputStream is = null;
|
||||
try {
|
||||
// File file = new File(Environment.getExternalStorageDirectory()
|
||||
// .getAbsolutePath(), "osmindoor.json");
|
||||
// is = new FileInputStream(file);
|
||||
// File file = new File(Environment.getExternalStorageDirectory()
|
||||
// .getAbsolutePath(), "osmindoor.json");
|
||||
// is = new FileInputStream(file);
|
||||
|
||||
URL url = new URL(PATH);
|
||||
URLConnection conn = url.openConnection();
|
||||
@ -83,11 +83,11 @@ public class JeoIndoorMapActivity extends BaseMapActivity {
|
||||
mMap.layers().add(new BuildingLayer(mMap, mBaseLayer));
|
||||
mMap.layers().add(new LabelLayer(mMap, mBaseLayer));
|
||||
|
||||
// mMap.layers().add(new TileGridLayer(mMap));
|
||||
// String file = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
// VectorDataset data = (VectorDataset) JeoTest.getJsonData(file + "/states.json", true);
|
||||
// Style style = JeoTest.getStyle();
|
||||
// mMap.layers().add(new JeoVectorLayer(mMap, data, style));
|
||||
// mMap.layers().add(new TileGridLayer(mMap));
|
||||
// String file = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
// VectorDataset data = (VectorDataset) JeoTest.getJsonData(file + "/states.json", true);
|
||||
// Style style = JeoTest.getStyle();
|
||||
// mMap.layers().add(new JeoVectorLayer(mMap, data, style));
|
||||
}
|
||||
|
||||
void loadJson(InputStream is) {
|
||||
@ -171,7 +171,7 @@ public class JeoIndoorMapActivity extends BaseMapActivity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
/* ignore saved position */
|
||||
/* ignore saved position */
|
||||
//mMap.setMapPosition(49.417, 8.673, 1 << 17);
|
||||
mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
/* directly load bitmap from resources */
|
||||
/* directly load bitmap from resources */
|
||||
Bitmap bitmap = drawableToBitmap(getResources(), R.drawable.marker_poi);
|
||||
|
||||
MarkerSymbol symbol;
|
||||
@ -59,7 +59,7 @@ public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||
else
|
||||
symbol = new MarkerSymbol(bitmap, 0.5f, 0.5f, false);
|
||||
|
||||
/* another option: use some bitmap drawable */
|
||||
/* another option: use some bitmap drawable */
|
||||
Drawable d = getResources().getDrawable(R.drawable.ic_launcher);
|
||||
if (BILLBOARDS)
|
||||
mFocusMarker = new MarkerSymbol(drawableToBitmap(d),
|
||||
@ -91,7 +91,7 @@ public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
/* ignore saved position */
|
||||
/* ignore saved position */
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class PathOverlayActivity extends BitmapTileMapActivity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
/* ignore saved position */
|
||||
/* ignore saved position */
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class S3DBMapActivity extends BaseMapActivity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
/* ignore saved position */
|
||||
/* ignore saved position */
|
||||
mMap.setMapPosition(53.5620092, 9.9866457, 1 << 16);
|
||||
}
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ public class SimpleMapActivity extends BaseMapActivity {
|
||||
//mMapView.map().setMapPosition(p);
|
||||
|
||||
p.setScale(2 + (1 << (int) (Math.random() * 13)));
|
||||
// p.setX((p.getX() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
// p.setY((p.getY() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
// p.setX((p.getX() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
// p.setY((p.getY() + (Math.random() * 4 - 2) / p.getScale()));
|
||||
p.setX(MercatorProjection.longitudeToX(Math.random() * 180));
|
||||
p.setY(MercatorProjection.latitudeToY(Math.random() * 60));
|
||||
|
||||
|
@ -37,39 +37,39 @@ public class VectorLayerMapActivity extends BaseMapActivity {
|
||||
|
||||
VectorLayer vectorLayer = new VectorLayer(mMap);
|
||||
|
||||
// Geometry g = new GeomBuilder()
|
||||
// .point(8.8, 53.1)
|
||||
// .point()
|
||||
// .buffer(1)
|
||||
// .get();
|
||||
// Geometry g = new GeomBuilder()
|
||||
// .point(8.8, 53.1)
|
||||
// .point()
|
||||
// .buffer(1)
|
||||
// .get();
|
||||
//
|
||||
// vectorLayer.add(new PolygonDrawable(g, defaultStyle()));
|
||||
// vectorLayer.add(new PolygonDrawable(g, defaultStyle()));
|
||||
//
|
||||
// vectorLayer.add(new PointDrawable(53.1, 8.8, Style.builder()
|
||||
// .setBuffer(0.5)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.2)
|
||||
// .build()));
|
||||
// vectorLayer.add(new PointDrawable(53.1, 8.8, Style.builder()
|
||||
// .setBuffer(0.5)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.2)
|
||||
// .build()));
|
||||
//
|
||||
// Style.Builder sb = Style.builder()
|
||||
// .setBuffer(0.5)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.2);
|
||||
// Style.Builder sb = Style.builder()
|
||||
// .setBuffer(0.5)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.2);
|
||||
//
|
||||
// Style style = sb.setFillAlpha(0.2).build();
|
||||
// Style style = sb.setFillAlpha(0.2).build();
|
||||
//
|
||||
// int tileSize = 5;
|
||||
// for (int x = -180; x < 180; x += tileSize) {
|
||||
// for (int y = -90; y < 90; y += tileSize) {
|
||||
// // Style style = sb.setFillAlpha(FastMath.clamp(FastMath.length(x, y) / 180, 0.2, 1))
|
||||
// // .build();
|
||||
// int tileSize = 5;
|
||||
// for (int x = -180; x < 180; x += tileSize) {
|
||||
// for (int y = -90; y < 90; y += tileSize) {
|
||||
// // Style style = sb.setFillAlpha(FastMath.clamp(FastMath.length(x, y) / 180, 0.2, 1))
|
||||
// // .build();
|
||||
//
|
||||
// vectorLayer.add(new RectangleDrawable(FastMath.clamp(y, -85, 85), x,
|
||||
// FastMath.clamp(y + tileSize - 0.1, -85, 85),
|
||||
// x + tileSize - 0.1, style));
|
||||
// vectorLayer.add(new RectangleDrawable(FastMath.clamp(y, -85, 85), x,
|
||||
// FastMath.clamp(y + tileSize - 0.1, -85, 85),
|
||||
// x + tileSize - 0.1, style));
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Style.Builder sb = Style.builder()
|
||||
.buffer(0.5)
|
||||
|
@ -42,8 +42,8 @@ public class MapScaleBar extends Layer implements UpdateListener {
|
||||
private static final int BITMAP_HEIGHT = 64;
|
||||
private static final int BITMAP_WIDTH = 128;
|
||||
private static final double LATITUDE_REDRAW_THRESHOLD = 0.2;
|
||||
// private static final int MARGIN_BOTTOM = 5;
|
||||
// private static final int MARGIN_LEFT = 5;
|
||||
// private static final int MARGIN_BOTTOM = 5;
|
||||
// private static final int MARGIN_LEFT = 5;
|
||||
|
||||
private static final double METER_FOOT_RATIO = 0.3048;
|
||||
private static final int ONE_KILOMETER = 1000;
|
||||
|
@ -63,13 +63,13 @@ public class MapView extends GLSurfaceView {
|
||||
public MapView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
|
||||
/* Not sure if this makes sense */
|
||||
/* Not sure if this makes sense */
|
||||
this.setWillNotDraw(true);
|
||||
this.setClickable(true);
|
||||
this.setFocusable(true);
|
||||
this.setFocusableInTouchMode(true);
|
||||
|
||||
/* Setup android backedn */
|
||||
/* Setup android backedn */
|
||||
AndroidGraphics.init();
|
||||
AndroidAssets.init(context);
|
||||
GLAdapter.init(new AndroidGL());
|
||||
@ -77,10 +77,10 @@ public class MapView extends GLSurfaceView {
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
CanvasAdapter.dpi = (int) Math.max(metrics.xdpi, metrics.ydpi);
|
||||
|
||||
/* Initialize the Map */
|
||||
/* Initialize the Map */
|
||||
mMap = new AndroidMap(this);
|
||||
|
||||
/* Initialize Renderer */
|
||||
/* Initialize Renderer */
|
||||
setEGLConfigChooser(new GlConfigChooser());
|
||||
setEGLContextClientVersion(2);
|
||||
|
||||
|
@ -250,7 +250,7 @@ public class TileCache implements ITileCache {
|
||||
public synchronized TileReader getTile(Tile tile) {
|
||||
|
||||
//if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
|
||||
// return getTileApi11(tile);
|
||||
// return getTileApi11(tile);
|
||||
|
||||
mQueryVals[0] = String.valueOf(tile.zoomLevel);
|
||||
mQueryVals[1] = String.valueOf(tile.tileX);
|
||||
|
@ -16,11 +16,11 @@ public class GestureHandler implements OnGestureListener, OnDoubleTapListener {
|
||||
mMap = map;
|
||||
}
|
||||
|
||||
/* GesturListener */
|
||||
/* GesturListener */
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
// return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
||||
// return mMap.handleGesture(Gesture.TAP, mMotionEvent.wrap(e));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class TileDecoder extends PbfDecoder {
|
||||
|
||||
// FIXME, remove all tiles from cache then remove this below
|
||||
//if (layer == 0)
|
||||
// layer = 5;
|
||||
// layer = 5;
|
||||
mElem.type = polygon ? GeometryType.POLY : GeometryType.LINE;
|
||||
mElem.setLayer(layer);
|
||||
mSink.process(mElem);
|
||||
|
@ -206,7 +206,7 @@ public class Triangulator {
|
||||
|
||||
int[] V = new int[n];
|
||||
|
||||
/* we want a counter-clockwise polygon in V */
|
||||
/* we want a counter-clockwise polygon in V */
|
||||
|
||||
if (0.0f < area(contour)) {
|
||||
for (int v = 0; v < n; v++)
|
||||
@ -218,7 +218,7 @@ public class Triangulator {
|
||||
|
||||
int nv = n;
|
||||
|
||||
/* remove nv-2 Vertices, creating 1 triangle every time */
|
||||
/* remove nv-2 Vertices, creating 1 triangle every time */
|
||||
int count = 2 * nv; /* error detection */
|
||||
|
||||
//for (int m = 0, v = nv - 1; nv > 2;) {
|
||||
@ -229,7 +229,7 @@ public class Triangulator {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* three consecutive vertices in current polygon, <u,v,w> */
|
||||
/* three consecutive vertices in current polygon, <u,v,w> */
|
||||
int u = v;
|
||||
if (nv <= u)
|
||||
u = 0; /* previous */
|
||||
@ -243,25 +243,25 @@ public class Triangulator {
|
||||
if (snip(contour, u, v, w, nv, V)) {
|
||||
int a, b, c, s, t;
|
||||
|
||||
/* true names of the vertices */
|
||||
/* true names of the vertices */
|
||||
a = V[u];
|
||||
b = V[v];
|
||||
c = V[w];
|
||||
|
||||
/* output Triangle */
|
||||
/* output Triangle */
|
||||
result.add(contour.get(a));
|
||||
result.add(contour.get(b));
|
||||
result.add(contour.get(c));
|
||||
|
||||
//m++;
|
||||
|
||||
/* remove v from remaining polygon */
|
||||
/* remove v from remaining polygon */
|
||||
for (s = v, t = v + 1; t < nv; s++, t++) {
|
||||
V[s] = V[t];
|
||||
}
|
||||
nv--;
|
||||
|
||||
/* resest error detection counter */
|
||||
/* resest error detection counter */
|
||||
count = 2 * nv;
|
||||
}
|
||||
}
|
||||
@ -355,7 +355,7 @@ public class Triangulator {
|
||||
// * @param point The point to remove
|
||||
// */
|
||||
//public void remove(Point point) {
|
||||
// points.remove(point);
|
||||
// points.remove(point);
|
||||
//}
|
||||
|
||||
/**
|
||||
|
@ -88,15 +88,15 @@ public class OsmPbfParser extends BinaryParser {
|
||||
long id = i.getId();
|
||||
double latf = parseLat(i.getLat()), lonf = parseLon(i.getLon());
|
||||
|
||||
// if (i.hasInfo()) {
|
||||
// Osmformat.Info info = i.getInfo();
|
||||
// tmp = new OsmNode(new CommonEntityData(id, info.getVersion(), getDate(info),
|
||||
// getUser(info), info.getChangeset(), tags), latf, lonf);
|
||||
// } else {
|
||||
// if (i.hasInfo()) {
|
||||
// Osmformat.Info info = i.getInfo();
|
||||
// tmp = new OsmNode(new CommonEntityData(id, info.getVersion(), getDate(info),
|
||||
// getUser(info), info.getChangeset(), tags), latf, lonf);
|
||||
// } else {
|
||||
tmp = new OsmNode(latf, lonf, tags, id);
|
||||
// tmp = new Node(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE,
|
||||
// NOCHANGESET, tags), latf, lonf);
|
||||
// }
|
||||
// tmp = new Node(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE,
|
||||
// NOCHANGESET, tags), latf, lonf);
|
||||
// }
|
||||
//sink.process(new NodeContainer(tmp));
|
||||
mNodeMap.put(Long.valueOf(id), tmp);
|
||||
}
|
||||
@ -109,12 +109,12 @@ public class OsmPbfParser extends BinaryParser {
|
||||
int j = 0; // Index into the keysvals array.
|
||||
|
||||
// Stuff for dense info
|
||||
// long lasttimestamp = 0, lastchangeset = 0;
|
||||
// int lastuserSid = 0, lastuid = 0;
|
||||
// DenseInfo di = null;
|
||||
// if (nodes.hasDenseinfo()) {
|
||||
// di = nodes.getDenseinfo();
|
||||
// }
|
||||
// long lasttimestamp = 0, lastchangeset = 0;
|
||||
// int lastuserSid = 0, lastuid = 0;
|
||||
// DenseInfo di = null;
|
||||
// if (nodes.hasDenseinfo()) {
|
||||
// di = nodes.getDenseinfo();
|
||||
// }
|
||||
|
||||
for (int i = 0; i < nodes.getIdCount(); i++) {
|
||||
OsmNode tmp;
|
||||
@ -174,10 +174,10 @@ public class OsmPbfParser extends BinaryParser {
|
||||
for (int j = 0; j < tagCnt; j++) {
|
||||
tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
|
||||
}
|
||||
// List<Tag> tags = new ArrayList<Tag>();
|
||||
// for (int j = 0; j < ; j++) {
|
||||
// tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
|
||||
// }
|
||||
// List<Tag> tags = new ArrayList<Tag>();
|
||||
// for (int j = 0; j < ; j++) {
|
||||
// tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
|
||||
// }
|
||||
|
||||
long lastId = 0;
|
||||
List<OsmNode> nodes = new ArrayList<OsmNode>();
|
||||
@ -196,13 +196,13 @@ public class OsmPbfParser extends BinaryParser {
|
||||
// long changesetId, Collection<Tag> tags,
|
||||
// List<WayNode> wayNodes
|
||||
OsmWay tmp;
|
||||
// if (i.hasInfo()) {
|
||||
// Osmformat.Info info = i.getInfo();
|
||||
// tmp = new Way(new CommonEntityData(id, info.getVersion(), getDate(info),
|
||||
// getUser(info), info.getChangeset(), tags), nodes);
|
||||
// } else {
|
||||
// if (i.hasInfo()) {
|
||||
// Osmformat.Info info = i.getInfo();
|
||||
// tmp = new Way(new CommonEntityData(id, info.getVersion(), getDate(info),
|
||||
// getUser(info), info.getChangeset(), tags), nodes);
|
||||
// } else {
|
||||
tmp = new OsmWay(tags, id, nodes);
|
||||
// }
|
||||
// }
|
||||
|
||||
mWayMap.put(Long.valueOf(id), tmp);
|
||||
|
||||
@ -225,25 +225,25 @@ public class OsmPbfParser extends BinaryParser {
|
||||
List<OsmMember> nodes = new ArrayList<OsmMember>();
|
||||
int memberCnt = i.getMemidsCount();
|
||||
|
||||
// for (int j = 0; j < memberCnt; j++) {
|
||||
// long mid = lastMid + i.getMemids(j);
|
||||
// lastMid = mid;
|
||||
// String role = getStringById(i.getRolesSid(j));
|
||||
// for (int j = 0; j < memberCnt; j++) {
|
||||
// long mid = lastMid + i.getMemids(j);
|
||||
// lastMid = mid;
|
||||
// String role = getStringById(i.getRolesSid(j));
|
||||
//
|
||||
// Osmformat.Relation.MemberType t = i.getTypes(j);
|
||||
// Osmformat.Relation.MemberType t = i.getTypes(j);
|
||||
//
|
||||
// if (t == Osmformat.Relation.MemberType.NODE) {
|
||||
// etype = EntityType.Node;
|
||||
// } else if (t == Osmformat.Relation.MemberType.WAY) {
|
||||
// etype = EntityType.Way;
|
||||
// } else if (t == Osmformat.Relation.MemberType.RELATION) {
|
||||
// etype = EntityType.Relation;
|
||||
// } else {
|
||||
// assert false; // TODO; Illegal file?
|
||||
// }
|
||||
// if (t == Osmformat.Relation.MemberType.NODE) {
|
||||
// etype = EntityType.Node;
|
||||
// } else if (t == Osmformat.Relation.MemberType.WAY) {
|
||||
// etype = EntityType.Way;
|
||||
// } else if (t == Osmformat.Relation.MemberType.RELATION) {
|
||||
// etype = EntityType.Relation;
|
||||
// } else {
|
||||
// assert false; // TODO; Illegal file?
|
||||
// }
|
||||
//
|
||||
// nodes.add(new OsmMember(mid, etype, role));
|
||||
// }
|
||||
// nodes.add(new OsmMember(mid, etype, role));
|
||||
// }
|
||||
|
||||
// long id, int version, TimestampContainer timestampContainer,
|
||||
// OsmUser user,
|
||||
@ -251,15 +251,15 @@ public class OsmPbfParser extends BinaryParser {
|
||||
// List<RelationMember> members
|
||||
OsmRelation tmp = new OsmRelation(tags, id, memberCnt);
|
||||
|
||||
// if (i.hasInfo()) {
|
||||
// Osmformat.Info info = i.getInfo();
|
||||
// tmp = new Relation(new CommonEntityData(id, info.getVersion(), getDate(info),
|
||||
// getUser(info), info.getChangeset(), tags), nodes);
|
||||
// } else {
|
||||
// tmp = new Relation(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE,
|
||||
// NOCHANGESET, tags), nodes);
|
||||
// }
|
||||
// sink.process(new RelationContainer(tmp));
|
||||
// if (i.hasInfo()) {
|
||||
// Osmformat.Info info = i.getInfo();
|
||||
// tmp = new Relation(new CommonEntityData(id, info.getVersion(), getDate(info),
|
||||
// getUser(info), info.getChangeset(), tags), nodes);
|
||||
// } else {
|
||||
// tmp = new Relation(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE,
|
||||
// NOCHANGESET, tags), nodes);
|
||||
// }
|
||||
// sink.process(new RelationContainer(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,34 +294,34 @@ public class OsmPbfParser extends BinaryParser {
|
||||
|
||||
public OsmData getData() {
|
||||
|
||||
// for (Entry<OsmRelation, List<TmpRelation>> entry : relationMembersForRelation
|
||||
// .entrySet()) {
|
||||
// for (Entry<OsmRelation, List<TmpRelation>> entry : relationMembersForRelation
|
||||
// .entrySet()) {
|
||||
//
|
||||
// OsmRelation relation = entry.getKey();
|
||||
// OsmRelation relation = entry.getKey();
|
||||
//
|
||||
// for (TmpRelation member : entry.getValue()) {
|
||||
// for (TmpRelation member : entry.getValue()) {
|
||||
//
|
||||
// OsmElement memberObject = null;
|
||||
// OsmElement memberObject = null;
|
||||
//
|
||||
// if ("node".equals(member)) {
|
||||
// memberObject = nodesById.get(member.id);
|
||||
// } else if ("way".equals(member)) {
|
||||
// memberObject = waysById.get(member.id);
|
||||
// } else if ("relation".equals(member)) {
|
||||
// memberObject = relationsById.get(member.id);
|
||||
// } else {
|
||||
// // log("missing relation " + member.id);
|
||||
// continue;
|
||||
// }
|
||||
// if ("node".equals(member)) {
|
||||
// memberObject = nodesById.get(member.id);
|
||||
// } else if ("way".equals(member)) {
|
||||
// memberObject = waysById.get(member.id);
|
||||
// } else if ("relation".equals(member)) {
|
||||
// memberObject = relationsById.get(member.id);
|
||||
// } else {
|
||||
// // log("missing relation " + member.id);
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (memberObject != null) {
|
||||
// OsmMember ownMember = new OsmMember(member.role,
|
||||
// memberObject);
|
||||
// if (memberObject != null) {
|
||||
// OsmMember ownMember = new OsmMember(member.role,
|
||||
// memberObject);
|
||||
//
|
||||
// relation.relationMembers.add(ownMember);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// relation.relationMembers.add(ownMember);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// give up references to original collections
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class RenderTheme implements IRenderTheme {
|
||||
//RGB c = r.color(f, CartoCSS.MARKER_FILL, RGB.black);
|
||||
//out.println(c);
|
||||
//return new RenderInstruction[] {
|
||||
// new Caption(color(c), width)
|
||||
// new Caption(color(c), width)
|
||||
//};
|
||||
}
|
||||
|
||||
|
@ -116,10 +116,10 @@ public class JtsPathLayer extends VectorLayer {
|
||||
public void addGreatCircle(GeoPoint startPoint, GeoPoint endPoint) {
|
||||
synchronized (mPoints) {
|
||||
|
||||
/* get the great circle path length in meters */
|
||||
/* get the great circle path length in meters */
|
||||
double length = startPoint.distanceTo(endPoint);
|
||||
|
||||
/* add one point for every 100kms of the great circle path */
|
||||
/* add one point for every 100kms of the great circle path */
|
||||
int numberOfPoints = (int) (length / 100000);
|
||||
|
||||
addGreatCircle(startPoint, endPoint, numberOfPoints);
|
||||
@ -137,12 +137,12 @@ public class JtsPathLayer extends VectorLayer {
|
||||
final int numberOfPoints) {
|
||||
/* adapted from page
|
||||
* http://compastic.blogspot.co.uk/2011/07/how-to-draw-great-circle-on-map
|
||||
* -in.html
|
||||
* which was adapted from page http://maps.forum.nu/gm_flight_path.html */
|
||||
* -in.html
|
||||
* which was adapted from page http://maps.forum.nu/gm_flight_path.html */
|
||||
|
||||
GeomBuilder gb = new GeomBuilder();
|
||||
|
||||
/* convert to radians */
|
||||
/* convert to radians */
|
||||
double lat1 = startPoint.getLatitude() * Math.PI / 180;
|
||||
double lon1 = startPoint.getLongitude() * Math.PI / 180;
|
||||
double lat2 = endPoint.getLatitude() * Math.PI / 180;
|
||||
|
@ -88,7 +88,7 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> {
|
||||
Envelope e = geometry.getEnvelopeInternal();
|
||||
Box bbox = new Box(e.getMinX(), e.getMinY(), e.getMaxX(), e.getMaxY());
|
||||
//if ("Point".equals(geometry.getGeometryType())){
|
||||
// bbox.
|
||||
// bbox.
|
||||
//}
|
||||
|
||||
bbox.scale(1E6);
|
||||
@ -158,15 +158,15 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> {
|
||||
if (Double.isNaN(bbox.xmin))
|
||||
return;
|
||||
|
||||
// mEnvelope = new GeomBuilder()
|
||||
// .point(bbox.xmin, bbox.ymin)
|
||||
// .point(bbox.xmin, bbox.ymax)
|
||||
// .point(bbox.xmax, bbox.ymax)
|
||||
// .point(bbox.xmax, bbox.ymin)
|
||||
// .point(bbox.xmin, bbox.ymin)
|
||||
// .toPolygon();
|
||||
// mEnvelope = new GeomBuilder()
|
||||
// .point(bbox.xmin, bbox.ymin)
|
||||
// .point(bbox.xmin, bbox.ymax)
|
||||
// .point(bbox.xmax, bbox.ymax)
|
||||
// .point(bbox.xmax, bbox.ymin)
|
||||
// .point(bbox.xmin, bbox.ymin)
|
||||
// .toPolygon();
|
||||
|
||||
/* reduce lines points min distance */
|
||||
/* reduce lines points min distance */
|
||||
mMinX = ((bbox.xmax - bbox.xmin) / mMap.getWidth());
|
||||
mMinY = ((bbox.ymax - bbox.ymin) / mMap.getHeight());
|
||||
|
||||
@ -177,7 +177,7 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> {
|
||||
int level = 0;
|
||||
Style lastStyle = null;
|
||||
|
||||
/* go through features, find the matching style and draw */
|
||||
/* go through features, find the matching style and draw */
|
||||
synchronized (this) {
|
||||
tmpDrawables.clear();
|
||||
mDrawables.search(bbox, tmpDrawables);
|
||||
@ -294,13 +294,13 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> {
|
||||
double x = (longitudeToX(px) - pos.x) * scale;
|
||||
double y = (latitudeToY(py) - pos.y) * scale;
|
||||
|
||||
/* TODO in the next line I was only able to interpolate a function
|
||||
/* TODO in the next line I was only able to interpolate a function
|
||||
* that makes up for the zoom level. The circle should not grow, it
|
||||
* should stickto the map. 0.01 / (1 << startLvl) makes it retain
|
||||
* its size. Correction? */
|
||||
* should stickto the map. 0.01 / (1 << startLvl) makes it retain
|
||||
* its size. Correction? */
|
||||
int zoomScale = (1 << style.scalingZoomLevel);
|
||||
|
||||
/* Keep the circle's size constant in relation to the underlying map */
|
||||
/* Keep the circle's size constant in relation to the underlying map */
|
||||
double radius = style.buffer;
|
||||
|
||||
if (pos.scale > zoomScale)
|
||||
|
@ -41,8 +41,8 @@ public class Style {
|
||||
* <p/>
|
||||
* <pre>
|
||||
* {
|
||||
* Style style = Style.builder()
|
||||
* .strokeWidth(1f).strokeColor(Color.BLACK).build();
|
||||
* Style style = Style.builder()
|
||||
* .strokeWidth(1f).strokeColor(Color.BLACK).build();
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
|
@ -66,7 +66,7 @@
|
||||
<style-text style="italic" fill="#666666" id="street-label-sm-i" k="name" priority="3" size="18"
|
||||
stroke="#e4e9cc" stroke-width="1.0" />
|
||||
|
||||
<!-- <style-text id="poi-label" k="name" size="16" fill="#000000" stroke="#e8ecd3" stroke-width="0.5" dy="2" dx="2" text-align="center" /> -->
|
||||
<!-- <style-text id="poi-label" k="name" size="16" fill="#000000" stroke="#e8ecd3" stroke-width="0.5" dy="2" dx="2" text-align="center" /> -->
|
||||
<style-area fill="#afcfa2" id="park" />
|
||||
<style-area id="park-2" src="patterns/park_texture_2.png" />
|
||||
|
||||
|
@ -75,14 +75,14 @@ public class HairLineTest extends GdxMap {
|
||||
//g.translate(10, 10);
|
||||
//l1.addLine(g);
|
||||
|
||||
// int o = 0;
|
||||
// for (int k = 0; k < g.index.length && g.index[k] >= 0; k++) {
|
||||
// int o = 0;
|
||||
// for (int k = 0; k < g.index.length && g.index[k] >= 0; k++) {
|
||||
//
|
||||
// for (int j = 0; j < g.index[k];)
|
||||
// ll.addPoint(g.points[o + j++], g.points[o + j++]);
|
||||
// for (int j = 0; j < g.index[k];)
|
||||
// ll.addPoint(g.points[o + j++], g.points[o + j++]);
|
||||
//
|
||||
// o += g.index[k];
|
||||
// }
|
||||
// o += g.index[k];
|
||||
// }
|
||||
}
|
||||
g = new GeometryBuffer(4, 2);
|
||||
g.clear();
|
||||
|
@ -63,11 +63,11 @@ public class PathLayerTest extends GdxMapApp {
|
||||
|
||||
for (double lon = -180; lon <= 180; lon += 2) {
|
||||
//pts.add(new GeoPoint(lat, lon));
|
||||
// double longitude = lon + (pos * 180);
|
||||
// if (longitude < -180)
|
||||
// longitude += 360;
|
||||
// if (longitude > 180)
|
||||
// longitude -= 360;
|
||||
// double longitude = lon + (pos * 180);
|
||||
// if (longitude < -180)
|
||||
// longitude += 360;
|
||||
// if (longitude > 180)
|
||||
// longitude -= 360;
|
||||
double longitude = lon;
|
||||
|
||||
double latitude = lat + (pos * 90);
|
||||
|
@ -27,9 +27,9 @@ import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
public class TileRenderTest extends GdxMapApp {
|
||||
|
||||
static boolean loadOneTile = true;
|
||||
// static int tileX = 34365 >> 2;
|
||||
// static int tileY = 21333 >> 2;
|
||||
// static byte tileZ = 14;
|
||||
// static int tileX = 34365 >> 2;
|
||||
// static int tileY = 21333 >> 2;
|
||||
// static byte tileZ = 14;
|
||||
|
||||
static int tileX = 68747 >> 3;
|
||||
static int tileY = 42648 >> 3;
|
||||
@ -62,7 +62,7 @@ public class TileRenderTest extends GdxMapApp {
|
||||
tile.node.parent = tile.node;
|
||||
tile.node.parent.parent = tile.node;
|
||||
|
||||
/* setup TileSet contatining one tile */
|
||||
/* setup TileSet contatining one tile */
|
||||
final TileSet tiles = new TileSet();
|
||||
tiles.cnt = 1;
|
||||
tiles.tiles[0] = tile;
|
||||
@ -74,7 +74,7 @@ public class TileRenderTest extends GdxMapApp {
|
||||
tileManager = new TileManager(mMap, 100);
|
||||
}
|
||||
|
||||
/* get the loader created by VectorTileLayer ... */
|
||||
/* get the loader created by VectorTileLayer ... */
|
||||
final TestTileLoader[] tileLoader = {null};
|
||||
|
||||
TestVectorTileLayer tileLayer = new TestVectorTileLayer(mMap, tileManager);
|
||||
@ -89,7 +89,7 @@ public class TileRenderTest extends GdxMapApp {
|
||||
//tileLayer.setRenderTheme(theme);
|
||||
//tileLayer.setRenderTheme(new DebugTheme());
|
||||
|
||||
/* need to create the labellayer here to get the tileloaded event */
|
||||
/* need to create the labellayer here to get the tileloaded event */
|
||||
LabelLayer labelLayer = new LabelLayer(mMap, tileLayer);
|
||||
|
||||
//mMap.layers().add(tileLayer);
|
||||
@ -169,7 +169,7 @@ public class TileRenderTest extends GdxMapApp {
|
||||
|
||||
@Override
|
||||
public void onMapEvent(Event event, MapPosition mapPosition) {
|
||||
/* ignore map events */
|
||||
/* ignore map events */
|
||||
if (event != Map.CLEAR_EVENT)
|
||||
return;
|
||||
|
||||
|
@ -35,19 +35,19 @@ public class VectorLayerTest extends GdxMapApp {
|
||||
|
||||
VectorLayer vectorLayer = new VectorLayer(mMap);
|
||||
|
||||
// vectorLayer.add(new PointDrawable(0, 180, Style.builder()
|
||||
// .setBuffer(10)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.5)
|
||||
// .build()));
|
||||
// vectorLayer.add(new PointDrawable(0, 180, Style.builder()
|
||||
// .setBuffer(10)
|
||||
// .setFillColor(Color.RED)
|
||||
// .setFillAlpha(0.5)
|
||||
// .build()));
|
||||
//
|
||||
// Geometry g = new GeomBuilder()
|
||||
// .point(180, 0)
|
||||
// .point()
|
||||
// .buffer(6)
|
||||
// .get();
|
||||
// Geometry g = new GeomBuilder()
|
||||
// .point(180, 0)
|
||||
// .point()
|
||||
// .buffer(6)
|
||||
// .get();
|
||||
//
|
||||
// vectorLayer.add(new PolygonDrawable(g, defaultStyle()));
|
||||
// vectorLayer.add(new PolygonDrawable(g, defaultStyle()));
|
||||
//
|
||||
|
||||
Style.Builder sb = Style.builder()
|
||||
@ -55,18 +55,18 @@ public class VectorLayerTest extends GdxMapApp {
|
||||
.fillColor(Color.RED)
|
||||
.fillAlpha(0.2);
|
||||
|
||||
// int tileSize = 5;
|
||||
// for (int x = -180; x < 200; x += tileSize) {
|
||||
// for (int y = -90; y < 90; y += tileSize) {
|
||||
// // Style style = sb.setFillAlpha(FastMath.clamp(FastMath.length(x, y) / 180, 0.2, 1))
|
||||
// // .build();
|
||||
// int tileSize = 5;
|
||||
// for (int x = -180; x < 200; x += tileSize) {
|
||||
// for (int y = -90; y < 90; y += tileSize) {
|
||||
// // Style style = sb.setFillAlpha(FastMath.clamp(FastMath.length(x, y) / 180, 0.2, 1))
|
||||
// // .build();
|
||||
//
|
||||
// vectorLayer.add(new RectangleDrawable(FastMath.clamp(y, -85, 85), x,
|
||||
// FastMath.clamp(y + tileSize - 0.1, -85, 85),
|
||||
// x + tileSize - 0.1, style));
|
||||
// vectorLayer.add(new RectangleDrawable(FastMath.clamp(y, -85, 85), x,
|
||||
// FastMath.clamp(y + tileSize - 0.1, -85, 85),
|
||||
// x + tileSize - 0.1, style));
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
Style style = sb.buffer(Math.random() * 1)
|
||||
|
@ -21,24 +21,24 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
|
||||
|
||||
public GdxModelLayer(Map map) {
|
||||
super(map);
|
||||
// tileLayer.addHook(new TileLoaderProcessHook() {
|
||||
// tileLayer.addHook(new TileLoaderProcessHook() {
|
||||
//
|
||||
// @Override
|
||||
// public boolean process(MapTile tile, ElementLayers layers, MapElement element) {
|
||||
// @Override
|
||||
// public boolean process(MapTile tile, ElementLayers layers, MapElement element) {
|
||||
//
|
||||
// if (!element.tags.contains(TREE_TAG))
|
||||
// return false;
|
||||
// if (!element.tags.contains(TREE_TAG))
|
||||
// return false;
|
||||
//
|
||||
// Poi3DTileData td = get(tile);
|
||||
// PointF p = element.getPoint(0);
|
||||
// SymbolItem s = SymbolItem.pool.get();
|
||||
// s.x = p.x;
|
||||
// s.y = p.y;
|
||||
// td.symbols.push(s);
|
||||
// Poi3DTileData td = get(tile);
|
||||
// PointF p = element.getPoint(0);
|
||||
// SymbolItem s = SymbolItem.pool.get();
|
||||
// s.x = p.x;
|
||||
// s.y = p.y;
|
||||
// td.symbols.push(s);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
//mTileLayer = tileLayer;
|
||||
|
||||
mRenderer = g3d = new GdxRenderer3D(mMap);
|
||||
@ -57,11 +57,11 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
|
||||
loading = true;
|
||||
}
|
||||
|
||||
// TileSet mTileSet = new TileSet();
|
||||
// TileSet mPrevTiles = new TileSet();
|
||||
// TileSet mTileSet = new TileSet();
|
||||
// TileSet mPrevTiles = new TileSet();
|
||||
//
|
||||
// LinkedHashMap<Tile, Array<SharedModel>> mTileMap =
|
||||
// new LinkedHashMap<Tile, Array<SharedModel>>();
|
||||
// LinkedHashMap<Tile, Array<SharedModel>> mTileMap =
|
||||
// new LinkedHashMap<Tile, Array<SharedModel>>();
|
||||
|
||||
boolean loading;
|
||||
Model mModel;
|
||||
@ -92,14 +92,14 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
|
||||
@Override
|
||||
public void onMapEvent(Event ev, MapPosition pos) {
|
||||
|
||||
// if (ev == Map.CLEAR_EVENT) {
|
||||
// mTileSet = new TileSet();
|
||||
// mPrevTiles = new TileSet();
|
||||
// mTileMap = new LinkedHashMap<Tile, Array<SharedModel>>();
|
||||
// synchronized (g3d) {
|
||||
// g3d.instances.clear();
|
||||
// }
|
||||
// }
|
||||
// if (ev == Map.CLEAR_EVENT) {
|
||||
// mTileSet = new TileSet();
|
||||
// mPrevTiles = new TileSet();
|
||||
// mTileMap = new LinkedHashMap<Tile, Array<SharedModel>>();
|
||||
// synchronized (g3d) {
|
||||
// g3d.instances.clear();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
if (loading && assets.update()) {
|
||||
doneLoading();
|
||||
@ -122,116 +122,116 @@ public class GdxModelLayer extends Layer implements Map.UpdateListener {
|
||||
g3d.cam.setMapPosition(x * scale - pos.x, y * scale - pos.y, scale / pos.scale);
|
||||
|
||||
//
|
||||
// // log.debug("update");
|
||||
// // log.debug("update");
|
||||
//
|
||||
// mTileLayer.tileRenderer().getVisibleTiles(mTileSet);
|
||||
// mTileLayer.tileRenderer().getVisibleTiles(mTileSet);
|
||||
//
|
||||
// if (mTileSet.cnt == 0) {
|
||||
// mTileSet.releaseTiles();
|
||||
// return;
|
||||
// }
|
||||
// if (mTileSet.cnt == 0) {
|
||||
// mTileSet.releaseTiles();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// boolean changed = false;
|
||||
// boolean changed = false;
|
||||
//
|
||||
// Array<SharedModel> added = new Array<SharedModel>();
|
||||
// Array<SharedModel> removed = new Array<SharedModel>();
|
||||
// Array<SharedModel> added = new Array<SharedModel>();
|
||||
// Array<SharedModel> removed = new Array<SharedModel>();
|
||||
|
||||
// for (int i = 0; i < mTileSet.cnt; i++) {
|
||||
// MapTile t = mTileSet.tiles[i];
|
||||
// if (mPrevTiles.contains(t))
|
||||
// continue;
|
||||
// for (int i = 0; i < mTileSet.cnt; i++) {
|
||||
// MapTile t = mTileSet.tiles[i];
|
||||
// if (mPrevTiles.contains(t))
|
||||
// continue;
|
||||
//
|
||||
// Array<SharedModel> instances = new Array<SharedModel>();
|
||||
// Array<SharedModel> instances = new Array<SharedModel>();
|
||||
//
|
||||
// Poi3DTileData ld = (Poi3DTileData) t.getData(POI_DATA);
|
||||
// if (ld == null)
|
||||
// continue;
|
||||
// Poi3DTileData ld = (Poi3DTileData) t.getData(POI_DATA);
|
||||
// if (ld == null)
|
||||
// continue;
|
||||
//
|
||||
// for (SymbolItem it : ld.symbols) {
|
||||
// for (SymbolItem it : ld.symbols) {
|
||||
//
|
||||
// SharedModel inst = new SharedModel(mModel);
|
||||
// inst.userData = it;
|
||||
// // float r = 0.5f + 0.5f * (float) Math.random();
|
||||
// // float g = 0.5f + 0.5f * (float) Math.random();
|
||||
// // float b = 0.5f + 0.5f * (float) Math.random();
|
||||
// SharedModel inst = new SharedModel(mModel);
|
||||
// inst.userData = it;
|
||||
// // float r = 0.5f + 0.5f * (float) Math.random();
|
||||
// // float g = 0.5f + 0.5f * (float) Math.random();
|
||||
// // float b = 0.5f + 0.5f * (float) Math.random();
|
||||
//
|
||||
// // inst.transform.setTranslation(new Vector3(it.x, it.y,
|
||||
// // 10));
|
||||
// // inst.materials.get(0).set(ColorAttribute.createDiffuse(r,
|
||||
// // g, b, 0.8f));
|
||||
// instances.add(inst);
|
||||
// added.add(inst);
|
||||
// }
|
||||
// // inst.transform.setTranslation(new Vector3(it.x, it.y,
|
||||
// // 10));
|
||||
// // inst.materials.get(0).set(ColorAttribute.createDiffuse(r,
|
||||
// // g, b, 0.8f));
|
||||
// instances.add(inst);
|
||||
// added.add(inst);
|
||||
// }
|
||||
//
|
||||
// if (instances.size == 0)
|
||||
// continue;
|
||||
// if (instances.size == 0)
|
||||
// continue;
|
||||
//
|
||||
// log.debug("add " + t + " " + instances.size);
|
||||
// log.debug("add " + t + " " + instances.size);
|
||||
//
|
||||
// changed = true;
|
||||
// changed = true;
|
||||
//
|
||||
// mTileMap.put(t, instances);
|
||||
// }
|
||||
// mTileMap.put(t, instances);
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < mPrevTiles.cnt; i++) {
|
||||
// MapTile t = mPrevTiles.tiles[i];
|
||||
// if (mTileSet.contains(t))
|
||||
// continue;
|
||||
// for (int i = 0; i < mPrevTiles.cnt; i++) {
|
||||
// MapTile t = mPrevTiles.tiles[i];
|
||||
// if (mTileSet.contains(t))
|
||||
// continue;
|
||||
//
|
||||
// Array<SharedModel> instances = mTileMap.get(t);
|
||||
// if (instances == null)
|
||||
// continue;
|
||||
// Array<SharedModel> instances = mTileMap.get(t);
|
||||
// if (instances == null)
|
||||
// continue;
|
||||
//
|
||||
// changed = true;
|
||||
// changed = true;
|
||||
//
|
||||
// removed.addAll(instances);
|
||||
// mTileMap.remove(t);
|
||||
// log.debug("remove " + t);
|
||||
// }
|
||||
// removed.addAll(instances);
|
||||
// mTileMap.remove(t);
|
||||
// log.debug("remove " + t);
|
||||
// }
|
||||
//
|
||||
// mPrevTiles.releaseTiles();
|
||||
// mPrevTiles.releaseTiles();
|
||||
//
|
||||
// int zoom = mTileSet.tiles[0].zoomLevel;
|
||||
// int zoom = mTileSet.tiles[0].zoomLevel;
|
||||
//
|
||||
// TileSet tmp = mPrevTiles;
|
||||
// mPrevTiles = mTileSet;
|
||||
// mTileSet = tmp;
|
||||
// TileSet tmp = mPrevTiles;
|
||||
// mPrevTiles = mTileSet;
|
||||
// mTileSet = tmp;
|
||||
//
|
||||
// if (!changed)
|
||||
// return;
|
||||
// if (!changed)
|
||||
// return;
|
||||
//
|
||||
// // scale aka tree height
|
||||
// float scale = (float) (1f / (1 << (17 - zoom))) * 8;
|
||||
// // scale aka tree height
|
||||
// float scale = (float) (1f / (1 << (17 - zoom))) * 8;
|
||||
//
|
||||
// double tileX = (pos.x * (Tile.SIZE << zoom));
|
||||
// double tileY = (pos.y * (Tile.SIZE << zoom));
|
||||
// double tileX = (pos.x * (Tile.SIZE << zoom));
|
||||
// double tileY = (pos.y * (Tile.SIZE << zoom));
|
||||
//
|
||||
// synchronized (g3d) {
|
||||
// synchronized (g3d) {
|
||||
//
|
||||
// for (Entry<Tile, Array<SharedModel>> e : mTileMap.entrySet()) {
|
||||
// Tile t = e.getKey();
|
||||
// for (Entry<Tile, Array<SharedModel>> e : mTileMap.entrySet()) {
|
||||
// Tile t = e.getKey();
|
||||
//
|
||||
// float dx = (float) (t.tileX * Tile.SIZE - tileX);
|
||||
// float dy = (float) (t.tileY * Tile.SIZE - tileY);
|
||||
// float dx = (float) (t.tileX * Tile.SIZE - tileX);
|
||||
// float dy = (float) (t.tileY * Tile.SIZE - tileY);
|
||||
//
|
||||
// for (SharedModel inst : e.getValue()) {
|
||||
// SymbolItem it = (SymbolItem) inst.userData;
|
||||
// for (SharedModel inst : e.getValue()) {
|
||||
// SymbolItem it = (SymbolItem) inst.userData;
|
||||
//
|
||||
// // variable height
|
||||
// float s = scale + (it.x * it.y) % 3;
|
||||
// float r = (it.x * it.y) % 360;
|
||||
// // variable height
|
||||
// float s = scale + (it.x * it.y) % 3;
|
||||
// float r = (it.x * it.y) % 360;
|
||||
//
|
||||
// inst.transform.idt();
|
||||
// inst.transform.scale(s, s, s);
|
||||
// inst.transform.translate((dx + it.x) / s, (dy + it.y) / s, 0);
|
||||
// inst.transform.rotate(0, 0, 1, r);
|
||||
// inst.transform.idt();
|
||||
// inst.transform.scale(s, s, s);
|
||||
// inst.transform.translate((dx + it.x) / s, (dy + it.y) / s, 0);
|
||||
// inst.transform.rotate(0, 0, 1, r);
|
||||
//
|
||||
// // inst.transform.setToTranslationAndScaling((dx +
|
||||
// // it.x), (dy + it.y),
|
||||
// // 0, s, s, s);
|
||||
// // inst.transform.setToTranslationAndScaling((dx +
|
||||
// // it.x), (dy + it.y),
|
||||
// // 0, s, s, s);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -138,27 +138,27 @@ public class GdxModelRenderer extends LayerRenderer {
|
||||
|
||||
//renderContext.begin();
|
||||
|
||||
// if (shader == null) {
|
||||
// r = instances.get(0).getRenderable(r);
|
||||
// DefaultShader.Config c = new DefaultShader.Config();
|
||||
// c.numBones = 0;
|
||||
// c.numDirectionalLights = 1;
|
||||
// r.environment = lights;
|
||||
// if (shader == null) {
|
||||
// r = instances.get(0).getRenderable(r);
|
||||
// DefaultShader.Config c = new DefaultShader.Config();
|
||||
// c.numBones = 0;
|
||||
// c.numDirectionalLights = 1;
|
||||
// r.environment = lights;
|
||||
//
|
||||
// shader = new DefaultShader(r, c);
|
||||
// shader.init();
|
||||
// }
|
||||
// shader = new DefaultShader(r, c);
|
||||
// shader.init();
|
||||
// }
|
||||
mBatch.begin(cam);
|
||||
//shader.begin(cam, renderContext);
|
||||
|
||||
for (SharedModel instance : instances) {
|
||||
instance.transform.getTranslation(tempVector);
|
||||
//instance.getRenderables(renderables, pool);
|
||||
// if (tempVector.x * tempVector.x + tempVector.y * tempVector.y > sqRadius)
|
||||
// continue;
|
||||
// tempVector.scl(0.8f, 0.8f, 1);
|
||||
// if (!GeometryUtils.pointInPoly(tempVector.x, tempVector.y, mBox, 8, 0))
|
||||
// continue;
|
||||
// if (tempVector.x * tempVector.x + tempVector.y * tempVector.y > sqRadius)
|
||||
// continue;
|
||||
// tempVector.scl(0.8f, 0.8f, 1);
|
||||
// if (!GeometryUtils.pointInPoly(tempVector.x, tempVector.y, mBox, 8, 0))
|
||||
// continue;
|
||||
|
||||
mBatch.render(instance);
|
||||
|
||||
|
@ -317,12 +317,12 @@ public class SharedModel implements RenderableProvider {
|
||||
if (nodePart.invBoneBindTransforms != null)
|
||||
nodePartBones.put(copy, nodePart.invBoneBindTransforms);
|
||||
|
||||
// final int index = materials.indexOf(nodePart.material, false);
|
||||
// if (index < 0)
|
||||
// materials.add(copy.material = nodePart.material.copy());
|
||||
// else
|
||||
// copy.material = materials.get(index);
|
||||
//
|
||||
// final int index = materials.indexOf(nodePart.material, false);
|
||||
// if (index < 0)
|
||||
// materials.add(copy.material = nodePart.material.copy());
|
||||
// else
|
||||
// copy.material = materials.get(index);
|
||||
//
|
||||
copy.material = nodePart.material;
|
||||
|
||||
return copy;
|
||||
@ -502,29 +502,29 @@ public class SharedModel implements RenderableProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
// /** @param id The ID of the material to fetch.
|
||||
// * @return The {@link Material} with the specified id, or null if not available. */
|
||||
// public Material getMaterial(final String id) {
|
||||
// return getMaterial(id, true);
|
||||
// }
|
||||
//
|
||||
// /** @param id The ID of the material to fetch.
|
||||
// * @param ignoreCase whether to use case sensitivity when comparing the material id.
|
||||
// * @return The {@link Material} with the specified id, or null if not available. */
|
||||
// public Material getMaterial(final String id, boolean ignoreCase) {
|
||||
// final int n = materials.size;
|
||||
// Material material;
|
||||
// if (ignoreCase) {
|
||||
// for (int i = 0; i < n; i++)
|
||||
// if ((material = materials.get(i)).id.equalsIgnoreCase(id))
|
||||
// return material;
|
||||
// } else {
|
||||
// for (int i = 0; i < n; i++)
|
||||
// if ((material = materials.get(i)).id.equals(id))
|
||||
// return material;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// /** @param id The ID of the material to fetch.
|
||||
// * @return The {@link Material} with the specified id, or null if not available. */
|
||||
// public Material getMaterial(final String id) {
|
||||
// return getMaterial(id, true);
|
||||
// }
|
||||
//
|
||||
// /** @param id The ID of the material to fetch.
|
||||
// * @param ignoreCase whether to use case sensitivity when comparing the material id.
|
||||
// * @return The {@link Material} with the specified id, or null if not available. */
|
||||
// public Material getMaterial(final String id, boolean ignoreCase) {
|
||||
// final int n = materials.size;
|
||||
// Material material;
|
||||
// if (ignoreCase) {
|
||||
// for (int i = 0; i < n; i++)
|
||||
// if ((material = materials.get(i)).id.equalsIgnoreCase(id))
|
||||
// return material;
|
||||
// } else {
|
||||
// for (int i = 0; i < n; i++)
|
||||
// if ((material = materials.get(i)).id.equals(id))
|
||||
// return material;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param id The ID of the node to fetch.
|
||||
|
@ -107,7 +107,7 @@ public class CustomRenderer extends LayerRenderer {
|
||||
|
||||
GLState.enableVertexArrays(hVertexPosition, -1);
|
||||
|
||||
/* apply view and projection matrices */
|
||||
/* apply view and projection matrices */
|
||||
// set mvp (tmp) matrix relative to mMapPosition
|
||||
// i.e. fixed on the map
|
||||
|
||||
|
@ -31,11 +31,11 @@ public class HexagonRenderTest extends GdxMap {
|
||||
GdxMapApp.run(new HexagonRenderTest(), null, 400);
|
||||
}
|
||||
|
||||
/* This is an example how to integrate custom OpenGL drawing routines as map
|
||||
/* This is an example how to integrate custom OpenGL drawing routines as map
|
||||
* overlay
|
||||
*
|
||||
* based on chapter 2 from:
|
||||
* https://github.com/dalinaum/opengl-es-book-samples/tree/master/Android */
|
||||
*
|
||||
* based on chapter 2 from:
|
||||
* https://github.com/dalinaum/opengl-es-book-samples/tree/master/Android */
|
||||
|
||||
static class HexagonRenderer extends BucketRenderer {
|
||||
|
||||
@ -65,8 +65,8 @@ public class HexagonRenderTest extends GdxMap {
|
||||
}
|
||||
|
||||
//if (mZoom != v.pos.zoomLevel) {
|
||||
// mMapPosition.copy(v.pos);
|
||||
// mZoom = v.pos.zoomLevel;
|
||||
// mMapPosition.copy(v.pos);
|
||||
// mZoom = v.pos.zoomLevel;
|
||||
//}
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public class HexagonRenderTest extends GdxMap {
|
||||
|
||||
GLState.enableVertexArrays(hVertexPosition, -1);
|
||||
|
||||
/* apply view and projection matrices */
|
||||
/* apply view and projection matrices */
|
||||
// set mvp (tmp) matrix relative to mMapPosition
|
||||
// i.e. fixed on the map
|
||||
setMatrix(v);
|
||||
@ -123,7 +123,7 @@ public class HexagonRenderTest extends GdxMap {
|
||||
gl.uniform2f(hCenterPosition, xx * (mCellScale * 1.5f), yy * mCellScale);
|
||||
|
||||
//float alpha = 1 + (float) Math.log10(FastMath.clamp(
|
||||
// (float) Math.sqrt(xx * xx + yy * yy) / offset_y, 0.0f, 1.0f)) * 2;
|
||||
// (float) Math.sqrt(xx * xx + yy * yy) / offset_y, 0.0f, 1.0f)) * 2;
|
||||
|
||||
float alpha = (float) Math.sqrt(xx * xx + yy * yy) / offset_y;
|
||||
|
||||
|
@ -67,23 +67,23 @@ public class OkHttpEngineTest {
|
||||
assertThat(response).isEqualTo("TEST RESPONSE");
|
||||
}
|
||||
|
||||
// @Test(expected = IOException.class)
|
||||
// public void close_shouldCloseInputStream() throws Exception {
|
||||
// engine.sendRequest(new Tile(1, 2, new Integer(3).byteValue()));
|
||||
// engine.close();
|
||||
// // Calling read after the stream is closed should throw an exception.
|
||||
// InputStream responseStream = engine.read();
|
||||
// responseStream.read();
|
||||
// }
|
||||
// @Test(expected = IOException.class)
|
||||
// public void close_shouldCloseInputStream() throws Exception {
|
||||
// engine.sendRequest(new Tile(1, 2, new Integer(3).byteValue()));
|
||||
// engine.close();
|
||||
// // Calling read after the stream is closed should throw an exception.
|
||||
// InputStream responseStream = engine.read();
|
||||
// responseStream.read();
|
||||
// }
|
||||
//
|
||||
// @Test(expected = IOException.class)
|
||||
// public void requestCompleted_shouldCloseInputStream() throws Exception {
|
||||
// engine.sendRequest(new Tile(1, 2, new Integer(3).byteValue()));
|
||||
// engine.requestCompleted(true);
|
||||
// // Calling read after the stream is closed should throw an exception.
|
||||
// InputStream responseStream = engine.read();
|
||||
// responseStream.read();
|
||||
// }
|
||||
// @Test(expected = IOException.class)
|
||||
// public void requestCompleted_shouldCloseInputStream() throws Exception {
|
||||
// engine.sendRequest(new Tile(1, 2, new Integer(3).byteValue()));
|
||||
// engine.requestCompleted(true);
|
||||
// // Calling read after the stream is closed should throw an exception.
|
||||
// InputStream responseStream = engine.read();
|
||||
// responseStream.read();
|
||||
// }
|
||||
|
||||
@Test
|
||||
public void requestCompleted_shouldReturnValueGiven() throws Exception {
|
||||
|
@ -51,7 +51,7 @@ public class KeyMapTest {
|
||||
Assert.assertTrue(it == it2);
|
||||
}
|
||||
|
||||
/* replace the items with itself */
|
||||
/* replace the items with itself */
|
||||
for (Item it : items) {
|
||||
Item it2 = map2.put(it);
|
||||
Assert.assertTrue(it == it2);
|
||||
|
@ -41,9 +41,9 @@ public class RTreeTest {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// return val + "/"
|
||||
// + Arrays.toString(min) + "/"
|
||||
// + Arrays.toString(max);
|
||||
// return val + "/"
|
||||
// + Arrays.toString(min) + "/"
|
||||
// + Arrays.toString(max);
|
||||
return String.valueOf(val);
|
||||
}
|
||||
}
|
||||
@ -82,8 +82,8 @@ public class RTreeTest {
|
||||
|
||||
min[0] = 0;
|
||||
min[1] = 0;
|
||||
// max[0] = 4;
|
||||
// max[1] = 4;
|
||||
// max[0] = 4;
|
||||
// max[1] = 4;
|
||||
|
||||
final ArrayList<Item> results = new ArrayList<Item>();
|
||||
|
||||
@ -146,14 +146,14 @@ public class RTreeTest {
|
||||
|
||||
assertEquals(results.size(), numItems);
|
||||
|
||||
// for (int i = 999; i >= 0; i--) {
|
||||
// Item it = results.remove(i);
|
||||
// boolean removed = t.remove(it.min, it.max, it);
|
||||
// //out.println("REMOVED: " + it + " " + removed);
|
||||
// for (int i = 999; i >= 0; i--) {
|
||||
// Item it = results.remove(i);
|
||||
// boolean removed = t.remove(it.min, it.max, it);
|
||||
// //out.println("REMOVED: " + it + " " + removed);
|
||||
//
|
||||
// Assert.assertEquals(i, t.count());
|
||||
// }
|
||||
// Assert.assertEquals(0, t.count());
|
||||
// Assert.assertEquals(i, t.count());
|
||||
// }
|
||||
// Assert.assertEquals(0, t.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -189,14 +189,14 @@ public class RTreeTest {
|
||||
|
||||
assertEquals(numItems, results.size());
|
||||
|
||||
// for (int i = 999; i >= 0; i--) {
|
||||
// Item it = results.remove(i);
|
||||
// boolean removed = t.remove(it.min, it.max, it);
|
||||
// //out.println("REMOVED: " + it + " " + removed);
|
||||
// for (int i = 999; i >= 0; i--) {
|
||||
// Item it = results.remove(i);
|
||||
// boolean removed = t.remove(it.min, it.max, it);
|
||||
// //out.println("REMOVED: " + it + " " + removed);
|
||||
//
|
||||
// Assert.assertEquals(i, t.count());
|
||||
// }
|
||||
// Assert.assertEquals(0, t.count());
|
||||
// Assert.assertEquals(i, t.count());
|
||||
// }
|
||||
// Assert.assertEquals(0, t.count());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -220,22 +220,22 @@ public class RTreeTest {
|
||||
|
||||
Assert.assertEquals(10000, t.size());
|
||||
|
||||
/*SearchCb<RTreeTest.Item> cb = new SearchCb<RTreeTest.Item>() {
|
||||
/*SearchCb<RTreeTest.Item> cb = new SearchCb<RTreeTest.Item>() {
|
||||
@Override
|
||||
public boolean call(Item item, Object context) {
|
||||
//out.println("found: " + item);
|
||||
//results.add(item);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
public boolean call(Item item, Object context) {
|
||||
//out.println("found: " + item);
|
||||
//results.add(item);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int counter = 0;
|
||||
int counter = 0;
|
||||
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
counter += t.search(min, max, cb, null);
|
||||
}
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
counter += t.search(min, max, cb, null);
|
||||
}
|
||||
|
||||
System.out.println("found: " + counter);*/
|
||||
System.out.println("found: " + counter);*/
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -23,14 +23,14 @@ public class InlistTest {
|
||||
list.push(new Thing(4));
|
||||
list.push(new Thing(5));
|
||||
|
||||
/* iterate items */
|
||||
/* iterate items */
|
||||
int i = 5;
|
||||
for (Thing it : list)
|
||||
assertEquals(it.value, i--);
|
||||
|
||||
assertEquals(i, 0);
|
||||
|
||||
/* iterate with insertion order */
|
||||
/* iterate with insertion order */
|
||||
list.reverse();
|
||||
i = 1;
|
||||
for (Thing it : list)
|
||||
@ -42,7 +42,7 @@ public class InlistTest {
|
||||
|
||||
List<Thing> list2 = new List<Thing>();
|
||||
|
||||
/* pop list and append to list2 */
|
||||
/* pop list and append to list2 */
|
||||
for (int j = 5; j > 0; j--) {
|
||||
Thing t = list.pop();
|
||||
assertEquals(t.value, j);
|
||||
@ -51,7 +51,7 @@ public class InlistTest {
|
||||
list2.append(t);
|
||||
}
|
||||
|
||||
/* check nothing to iterate */
|
||||
/* check nothing to iterate */
|
||||
for (Thing t : list)
|
||||
assert (t == null && t != null);
|
||||
|
||||
@ -60,7 +60,7 @@ public class InlistTest {
|
||||
|
||||
list.push(new Thing(6));
|
||||
|
||||
/* move items from list2 to list */
|
||||
/* move items from list2 to list */
|
||||
list.appendList(list2.clear());
|
||||
|
||||
assertNull(list2.head());
|
||||
|
@ -65,10 +65,10 @@ public class GwtLauncher extends GwtApplication {
|
||||
|
||||
private static native int getWindowWidth() /*-{
|
||||
return $wnd.innerWidth;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
private static native int getWindowHeight() /*-{
|
||||
return $wnd.innerHeight;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
@ -103,31 +103,31 @@ public class SearchBox {
|
||||
public final native String getId()
|
||||
/*-{
|
||||
return this.osm_id;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native String name() /*-{
|
||||
return this.display_name;
|
||||
}-*/;
|
||||
return this.display_name;
|
||||
}-*/;
|
||||
|
||||
public final native BBox getBBox() /*-{
|
||||
return this.boundingbox
|
||||
}-*/;
|
||||
return this.boundingbox
|
||||
}-*/;
|
||||
|
||||
public final native String getWkt() /*-{
|
||||
return this.geotext;
|
||||
}-*/;
|
||||
return this.geotext;
|
||||
}-*/;
|
||||
|
||||
private final native String latitude() /*-{
|
||||
return this.lat;
|
||||
}-*/;
|
||||
return this.lat;
|
||||
}-*/;
|
||||
|
||||
private final native String longitude() /*-{
|
||||
return this.lon;
|
||||
}-*/;
|
||||
return this.lon;
|
||||
}-*/;
|
||||
|
||||
public final native String getIcon() /*-{
|
||||
return this.icon;
|
||||
}-*/;
|
||||
return this.icon;
|
||||
}-*/;
|
||||
|
||||
@Override
|
||||
public double getLatitude() {
|
||||
@ -248,7 +248,7 @@ public class SearchBox {
|
||||
mOverlay.clearPath();
|
||||
|
||||
//log.debug("selected " + d.getName() + " " + d.getLatitude() + " "
|
||||
// + d.getLongitude());
|
||||
// + d.getLongitude());
|
||||
|
||||
BoundingBox b = d.getBoundingBox();
|
||||
if (b != null) {
|
||||
|
@ -220,21 +220,21 @@ public class WKTReader {
|
||||
return neg ? -val : val;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// WKTReader r = new WKTReader();
|
||||
// GeometryBuffer geom = new GeometryBuffer(10, 10);
|
||||
// try {
|
||||
// String wkt = "MULTIPOINT(0 0,1 0)";
|
||||
// r.parse(wkt, geom);
|
||||
// for (int i = 0; i < geom.index.length; i++) {
|
||||
// int len = geom.index[i];
|
||||
// if (len < 0)
|
||||
// break;
|
||||
// for (int p = 0; p < len; p += 2)
|
||||
// System.out.println(len + ": " + geom.points[p] + "," + geom.points[p + 1]);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// public static void main(String[] args) {
|
||||
// WKTReader r = new WKTReader();
|
||||
// GeometryBuffer geom = new GeometryBuffer(10, 10);
|
||||
// try {
|
||||
// String wkt = "MULTIPOINT(0 0,1 0)";
|
||||
// r.parse(wkt, geom);
|
||||
// for (int i = 0; i < geom.index.length; i++) {
|
||||
// int len = geom.index[i];
|
||||
// if (len < 0)
|
||||
// break;
|
||||
// for (int p = 0; p < len; p += 2)
|
||||
// System.out.println(len + ": " + geom.points[p] + "," + geom.points[p + 1]);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -1,106 +1,106 @@
|
||||
.header {
|
||||
background-color: #ddd;
|
||||
text-align: center;
|
||||
background-color: #ddd;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
html,body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0 0 0 0;
|
||||
font-family: Arial, "MS Trebuchet", sans-serif;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0 0 0 0;
|
||||
font-family: Arial, "MS Trebuchet", sans-serif;
|
||||
}
|
||||
|
||||
#credits {
|
||||
position: absolute;
|
||||
bottom: 0.2em;
|
||||
right: 0.2em;
|
||||
z-index: 20000;
|
||||
color: white;
|
||||
background-color: #000;
|
||||
opacity: 0.5;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
position: absolute;
|
||||
bottom: 0.2em;
|
||||
right: 0.2em;
|
||||
z-index: 20000;
|
||||
color: white;
|
||||
background-color: #000;
|
||||
opacity: 0.5;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#credits a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-variant: small-caps;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
#search {
|
||||
z-index: 20000;
|
||||
position: absolute;
|
||||
top: 0.5em;
|
||||
left: 0.5em;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
visibility: hidden;
|
||||
z-index: 20000;
|
||||
position: absolute;
|
||||
top: 0.5em;
|
||||
left: 0.5em;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#listContainer {
|
||||
color: #FFFFFF;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
#nameFieldContainer,.gwt-TextBox {
|
||||
width: 250px;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
/* Turn on a 16x16 scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 0px;
|
||||
width: 10px;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
/* Turn on single button up on top, and down on bottom */
|
||||
::-webkit-scrollbar-button:start:decrement,::-webkit-scrollbar-button:end:increment
|
||||
{
|
||||
display: block;
|
||||
{
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Turn off the down area up on top, and up area on bottom */
|
||||
::-webkit-scrollbar-button:vertical:start:increment,::-webkit-scrollbar-button:vertical:end:decrement
|
||||
{
|
||||
display: none;
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Place The scroll down button at the bottom */
|
||||
::-webkit-scrollbar-button:end:increment {
|
||||
/*background-image: url(images/scroll_cntrl_dwn.png);*/
|
||||
|
||||
/*background-image: url(images/scroll_cntrl_dwn.png);*/
|
||||
|
||||
}
|
||||
|
||||
/* Place The scroll up button at the up */
|
||||
::-webkit-scrollbar-button:start:decrement {
|
||||
/*background-image: url(images/scroll_cntrl_up.png);*/
|
||||
|
||||
/*background-image: url(images/scroll_cntrl_up.png);*/
|
||||
|
||||
}
|
||||
|
||||
/* Top area above thumb and below up button */
|
||||
::-webkit-scrollbar-track-piece:vertical:start {
|
||||
/*background-image: url(images/scroll_gutter_top.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;*/
|
||||
|
||||
/*background-image: url(images/scroll_gutter_top.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;*/
|
||||
|
||||
}
|
||||
|
||||
/* Bottom area below thumb and down button */
|
||||
::-webkit-scrollbar-track-piece:vertical:end {
|
||||
/*background-image: url(images/scroll_gutter_btm.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;
|
||||
background-position: bottom left, 0 0;*/
|
||||
|
||||
/*background-image: url(images/scroll_gutter_btm.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;
|
||||
background-position: bottom left, 0 0;*/
|
||||
|
||||
}
|
||||
|
||||
/* The thumb itself */
|
||||
::-webkit-scrollbar-thumb:vertical {
|
||||
height: 56px;
|
||||
width: 12px;
|
||||
/* -webkit-border-image: url(images/scroll_thumb.png) 8 0 8 0 stretch stretch;*/
|
||||
background-color: #DDDDDD;
|
||||
opacity: 0.5;
|
||||
}
|
||||
height: 56px;
|
||||
width: 12px;
|
||||
/* -webkit-border-image: url(images/scroll_thumb.png) 8 0 8 0 stretch stretch;*/
|
||||
background-color: #DDDDDD;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
@ -16,15 +16,15 @@
|
||||
<link rel="stylesheet" type="text/css" href="default.css">
|
||||
|
||||
<script type="text/javascript">
|
||||
var mapconfig = {
|
||||
tilesource : "oscimap4",
|
||||
tileurl : "http://opensciencemap.org/tiles/vtm",
|
||||
zoom : 2,
|
||||
latitude : 0.0,
|
||||
longitude : 0.0,
|
||||
tileSize : 400
|
||||
}
|
||||
//background : "naturalearth"
|
||||
var mapconfig = {
|
||||
tilesource : "oscimap4",
|
||||
tileurl : "http://opensciencemap.org/tiles/vtm",
|
||||
zoom : 2,
|
||||
latitude : 0.0,
|
||||
longitude : 0.0,
|
||||
tileSize : 400
|
||||
}
|
||||
//background : "naturalearth"
|
||||
|
||||
</script>
|
||||
|
||||
@ -43,19 +43,19 @@
|
||||
</div>
|
||||
|
||||
<script type="text/Javascript">
|
||||
function canvasResize() {
|
||||
div = document.getElementById('canvas-area')
|
||||
canvas = document.getElementById('map-canvas')
|
||||
var w = div.scrollWidth;
|
||||
var h = div.scrollHeight;
|
||||
//console.log(div.clientHeight + " " + div.clientWidth)
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
canvas.style.width = w + 'px';
|
||||
canvas.style.height = h + 'px';
|
||||
}
|
||||
canvasResize();
|
||||
window.addEventListener('resize', canvasResize, false);
|
||||
function canvasResize() {
|
||||
div = document.getElementById('canvas-area')
|
||||
canvas = document.getElementById('map-canvas')
|
||||
var w = div.scrollWidth;
|
||||
var h = div.scrollHeight;
|
||||
//console.log(div.clientHeight + " " + div.clientWidth)
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
canvas.style.width = w + 'px';
|
||||
canvas.style.height = h + 'px';
|
||||
}
|
||||
canvasResize();
|
||||
window.addEventListener('resize', canvasResize, false);
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" src="VtmWebApp/js/_tessellate.js"></script>
|
||||
|
@ -75,10 +75,10 @@ public class GwtLauncher extends GwtApplication {
|
||||
|
||||
private static native int getWindowWidth() /*-{
|
||||
return $wnd.innerWidth;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
private static native int getWindowHeight() /*-{
|
||||
return $wnd.innerHeight;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class GwtMap extends GdxMap {
|
||||
|
||||
private final native void createLayersN()/*-{
|
||||
$wnd.createLayers();
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
@Override
|
||||
protected void createLayers() {
|
||||
|
@ -15,8 +15,8 @@ public class JsBitmapTileLayer extends BitmapTileLayer implements ExportOverlay<
|
||||
super(map, tileSource);
|
||||
}
|
||||
|
||||
// @ExportConstructor
|
||||
// public static BitmapTileLayer constructor(Map map, TileSource tileSource) {
|
||||
// return new JsBitmapTileLayer(map, tileSource);
|
||||
// }
|
||||
// @ExportConstructor
|
||||
// public static BitmapTileLayer constructor(Map map, TileSource tileSource) {
|
||||
// return new JsBitmapTileLayer(map, tileSource);
|
||||
// }
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ public class JsBitmapTileSource extends BitmapTileSource implements
|
||||
public ITileDataSource getDataSource() {
|
||||
return null;
|
||||
}
|
||||
// @ExportConstructor
|
||||
// public static BitmapTileSource constructor(String url, int zoomMin, int zoomMax) {
|
||||
// return new JsBitmapTileSource(url, zoomMin, zoomMax);
|
||||
// }
|
||||
// @ExportConstructor
|
||||
// public static BitmapTileSource constructor(String url, int zoomMin, int zoomMax) {
|
||||
// return new JsBitmapTileSource(url, zoomMin, zoomMax);
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class JsMap implements Exportable {
|
||||
mMap = map;
|
||||
}
|
||||
|
||||
// @ExportInstanceMethod("foo")
|
||||
// @ExportInstanceMethod("foo")
|
||||
// public static String instanceMethod(Map instance, String surname) {
|
||||
// return instance.getName() + "-" + surname;
|
||||
// }
|
||||
|
@ -122,8 +122,8 @@ public class JsOverlays implements Exportable {
|
||||
}
|
||||
}
|
||||
|
||||
// @ExportPackage("vtm")
|
||||
// @Export("Viewport")
|
||||
// public interface XViewport extends ExportOverlay
|
||||
// @ExportPackage("vtm")
|
||||
// @Export("Viewport")
|
||||
// public interface XViewport extends ExportOverlay
|
||||
//
|
||||
}
|
||||
|
@ -1,102 +1,102 @@
|
||||
.header {
|
||||
background-color: #ddd;
|
||||
text-align: center;
|
||||
background-color: #ddd;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
html,body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0 0 0 0;
|
||||
font-family: Arial, "MS Trebuchet", sans-serif;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0 0 0 0;
|
||||
font-family: Arial, "MS Trebuchet", sans-serif;
|
||||
}
|
||||
|
||||
#credits {
|
||||
position: absolute;
|
||||
bottom: 0.2em;
|
||||
right: 0.2em;
|
||||
z-index: 20000;
|
||||
color: white;
|
||||
background-color: #000;
|
||||
opacity: 0.5;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
position: absolute;
|
||||
bottom: 0.2em;
|
||||
right: 0.2em;
|
||||
z-index: 20000;
|
||||
color: white;
|
||||
background-color: #000;
|
||||
opacity: 0.5;
|
||||
padding: 0.2em 0.5em 0.2em 0.5em;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#credits a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-variant: small-caps;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
|
||||
#search {
|
||||
z-index: 20000;
|
||||
position: absolute;
|
||||
top: 0.5em;
|
||||
left: 0.5em;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
visibility: hidden;
|
||||
z-index: 20000;
|
||||
position: absolute;
|
||||
top: 0.5em;
|
||||
left: 0.5em;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#listContainer {
|
||||
color: #FFFFFF;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
#nameFieldContainer,.gwt-TextBox {
|
||||
width: 250px;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
/* Turn on a 16x16 scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 0px;
|
||||
width: 10px;
|
||||
height: 0px;
|
||||
}
|
||||
|
||||
/* Turn on single button up on top, and down on bottom */
|
||||
::-webkit-scrollbar-button:start:decrement,::-webkit-scrollbar-button:end:increment
|
||||
{
|
||||
display: block;
|
||||
{
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Turn off the down area up on top, and up area on bottom */
|
||||
::-webkit-scrollbar-button:vertical:start:increment,::-webkit-scrollbar-button:vertical:end:decrement
|
||||
{
|
||||
display: none;
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Place The scroll down button at the bottom */
|
||||
::-webkit-scrollbar-button:end:increment {
|
||||
/*background-image: url(images/scroll_cntrl_dwn.png);*/
|
||||
/*background-image: url(images/scroll_cntrl_dwn.png);*/
|
||||
}
|
||||
|
||||
/* Place The scroll up button at the up */
|
||||
::-webkit-scrollbar-button:start:decrement {
|
||||
/*background-image: url(images/scroll_cntrl_up.png);*/
|
||||
/*background-image: url(images/scroll_cntrl_up.png);*/
|
||||
}
|
||||
|
||||
/* Top area above thumb and below up button */
|
||||
::-webkit-scrollbar-track-piece:vertical:start {
|
||||
/*background-image: url(images/scroll_gutter_top.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;*/
|
||||
/*background-image: url(images/scroll_gutter_top.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;*/
|
||||
}
|
||||
|
||||
/* Bottom area below thumb and down button */
|
||||
::-webkit-scrollbar-track-piece:vertical:end {
|
||||
/*background-image: url(images/scroll_gutter_btm.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;
|
||||
background-position: bottom left, 0 0;*/
|
||||
/*background-image: url(images/scroll_gutter_btm.png), url(images/scroll_gutter_mid.png);
|
||||
background-repeat: no-repeat, repeat-y;
|
||||
background-position: bottom left, 0 0;*/
|
||||
}
|
||||
|
||||
/* The thumb itself */
|
||||
::-webkit-scrollbar-thumb:vertical {
|
||||
height: 56px;
|
||||
width: 12px;
|
||||
/* -webkit-border-image: url(images/scroll_thumb.png) 8 0 8 0 stretch stretch;*/
|
||||
background-color: #DDDDDD;
|
||||
opacity: 0.5;
|
||||
height: 56px;
|
||||
width: 12px;
|
||||
/* -webkit-border-image: url(images/scroll_thumb.png) 8 0 8 0 stretch stretch;*/
|
||||
background-color: #DDDDDD;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
@ -1,42 +1,42 @@
|
||||
var mapconfig = {
|
||||
zoom : 12,
|
||||
latitude : 53.075,
|
||||
longitude : 8.8080,
|
||||
tileSize : 400
|
||||
zoom : 12,
|
||||
latitude : 53.075,
|
||||
longitude : 8.8080,
|
||||
tileSize : 400
|
||||
}
|
||||
|
||||
function createLayers() {
|
||||
var m = map.map();
|
||||
var m = map.map();
|
||||
|
||||
// var t = map.loadTheme("DEFAULT");
|
||||
// var ts = new vtm.OSciMap4TileSource();
|
||||
// var l = new vtm.OsmTileLayer(m);
|
||||
// l.setTileSource(ts)
|
||||
// l.setRenderTheme(t)
|
||||
// var t = map.loadTheme("DEFAULT");
|
||||
// var ts = new vtm.OSciMap4TileSource();
|
||||
// var l = new vtm.OsmTileLayer(m);
|
||||
// l.setTileSource(ts)
|
||||
// l.setRenderTheme(t)
|
||||
|
||||
var s = new vtm.BitmapTileSource("http://a.tile.stamen.com/toner", 0, 18);
|
||||
var l = new vtm.BitmapTileLayer(m, s);
|
||||
map.addLayer(l)
|
||||
// map.addLayer(new vtm.BuildingLayer(m, l))
|
||||
// map.addLayer(new vtm.LabelLayer(m, l))
|
||||
var s = new vtm.BitmapTileSource("http://a.tile.stamen.com/toner", 0, 18);
|
||||
var l = new vtm.BitmapTileLayer(m, s);
|
||||
map.addLayer(l)
|
||||
// map.addLayer(new vtm.BuildingLayer(m, l))
|
||||
// map.addLayer(new vtm.LabelLayer(m, l))
|
||||
|
||||
t = map.loadTheme("TRONRENDER")
|
||||
ts = new vtm.OsmLanduseJsonTileSource()
|
||||
l = new vtm.VectorTileLayer(m, ts)
|
||||
l.setRenderTheme(t)
|
||||
map.addLayer(l)
|
||||
t = map.loadTheme("TRONRENDER")
|
||||
ts = new vtm.OsmLanduseJsonTileSource()
|
||||
l = new vtm.VectorTileLayer(m, ts)
|
||||
l.setRenderTheme(t)
|
||||
map.addLayer(l)
|
||||
}
|
||||
|
||||
function canvasResize() {
|
||||
div = document.getElementById('canvas-area')
|
||||
canvas = document.getElementById('map-canvas')
|
||||
var w = div.scrollWidth;
|
||||
var h = div.scrollHeight;
|
||||
// console.log(div.clientHeight + " " + div.clientWidth)
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
canvas.style.width = w + 'px';
|
||||
canvas.style.height = h + 'px';
|
||||
div = document.getElementById('canvas-area')
|
||||
canvas = document.getElementById('map-canvas')
|
||||
var w = div.scrollWidth;
|
||||
var h = div.scrollHeight;
|
||||
// console.log(div.clientHeight + " " + div.clientWidth)
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
canvas.style.width = w + 'px';
|
||||
canvas.style.height = h + 'px';
|
||||
}
|
||||
canvasResize();
|
||||
window.addEventListener('resize', canvasResize, false);
|
||||
|
@ -37,10 +37,10 @@ public class GdxGL extends GwtGL20 implements GL {
|
||||
this.gl = gl;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
// @Override
|
||||
// public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void glTexImage2D(int target, int level, int internalformat, int width, int height,
|
||||
|
@ -24,26 +24,26 @@ public class MapConfig extends JavaScriptObject {
|
||||
|
||||
public static native MapConfig get()/*-{
|
||||
return $wnd.mapconfig;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native double getLatitude() /*-{
|
||||
return this.latitude || 0;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native double getLongitude() /*-{
|
||||
return this.longitude || 0;
|
||||
}-*/;
|
||||
return this.longitude || 0;
|
||||
}-*/;
|
||||
|
||||
public final native int getZoom() /*-{
|
||||
return this.zoom || 2;
|
||||
}-*/;
|
||||
return this.zoom || 2;
|
||||
}-*/;
|
||||
|
||||
public final native String getTileSource() /*-{
|
||||
return this.tilesource;
|
||||
}-*/;
|
||||
return this.tilesource;
|
||||
}-*/;
|
||||
|
||||
public final native int getTileSize() /*-{
|
||||
return this.tileSize || 256;
|
||||
}-*/;
|
||||
return this.tileSize || 256;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ public class MapUrl extends Timer {
|
||||
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 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)
|
||||
|
@ -332,19 +332,19 @@ public abstract class GwtApplication implements EntryPoint, Application {
|
||||
**/
|
||||
private static native AgentInfo computeAgentInfo() /*-{
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
return {
|
||||
// browser type flags
|
||||
isFirefox : userAgent.indexOf("firefox") != -1,
|
||||
isChrome : userAgent.indexOf("chrome") != -1,
|
||||
isSafari : userAgent.indexOf("safari") != -1,
|
||||
isOpera : userAgent.indexOf("opera") != -1,
|
||||
isIE : userAgent.indexOf("msie") != -1,
|
||||
// OS type flags
|
||||
isMacOS : userAgent.indexOf("mac") != -1,
|
||||
isLinux : userAgent.indexOf("linux") != -1,
|
||||
isWindows : userAgent.indexOf("win") != -1
|
||||
};
|
||||
}-*/;
|
||||
return {
|
||||
// browser type flags
|
||||
isFirefox : userAgent.indexOf("firefox") != -1,
|
||||
isChrome : userAgent.indexOf("chrome") != -1,
|
||||
isSafari : userAgent.indexOf("safari") != -1,
|
||||
isOpera : userAgent.indexOf("opera") != -1,
|
||||
isIE : userAgent.indexOf("msie") != -1,
|
||||
// OS type flags
|
||||
isMacOS : userAgent.indexOf("mac") != -1,
|
||||
isLinux : userAgent.indexOf("linux") != -1,
|
||||
isWindows : userAgent.indexOf("win") != -1
|
||||
};
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Returned by {@link #agentInfo}. Kindly borrowed from PlayN.
|
||||
@ -352,35 +352,35 @@ public abstract class GwtApplication implements EntryPoint, Application {
|
||||
public static class AgentInfo extends JavaScriptObject {
|
||||
public final native boolean isFirefox() /*-{
|
||||
return this.isFirefox;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isChrome() /*-{
|
||||
return this.isChrome;
|
||||
}-*/;
|
||||
return this.isChrome;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isSafari() /*-{
|
||||
return this.isSafari;
|
||||
}-*/;
|
||||
return this.isSafari;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isOpera() /*-{
|
||||
return this.isOpera;
|
||||
}-*/;
|
||||
return this.isOpera;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isIE() /*-{
|
||||
return this.isIE;
|
||||
}-*/;
|
||||
return this.isIE;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isMacOS() /*-{
|
||||
return this.isMacOS;
|
||||
}-*/;
|
||||
return this.isMacOS;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isLinux() /*-{
|
||||
return this.isLinux;
|
||||
}-*/;
|
||||
return this.isLinux;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isWindows() /*-{
|
||||
return this.isWindows;
|
||||
}-*/;
|
||||
return this.isWindows;
|
||||
}-*/;
|
||||
|
||||
protected AgentInfo() {
|
||||
}
|
||||
|
@ -96,15 +96,15 @@ public class GwtGraphics implements Graphics {
|
||||
|
||||
public static native double getDevicePixelRatioJSNI() /*-{
|
||||
return $wnd.devicePixelRatio || 1.0;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public static native int getWindowWidthJSNI() /*-{
|
||||
return $wnd.innerWidth;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public static native int getWindowHeightJSNI() /*-{
|
||||
return $wnd.innerHeight;
|
||||
}-*/;
|
||||
return $wnd.innerHeight;
|
||||
}-*/;
|
||||
|
||||
public WebGLRenderingContext getContext() {
|
||||
return context;
|
||||
@ -173,22 +173,22 @@ public class GwtGraphics implements Graphics {
|
||||
}
|
||||
|
||||
private native int getScreenWidthJSNI() /*-{
|
||||
return $wnd.screen.width;
|
||||
}-*/;
|
||||
return $wnd.screen.width;
|
||||
}-*/;
|
||||
|
||||
private native int getScreenHeightJSNI() /*-{
|
||||
return $wnd.screen.height;
|
||||
}-*/;
|
||||
return $wnd.screen.height;
|
||||
}-*/;
|
||||
|
||||
private native boolean isFullscreenJSNI() /*-{
|
||||
if ("webkitIsFullScreen" in $doc) {
|
||||
return $doc.webkitIsFullScreen;
|
||||
}
|
||||
if ("mozFullScreen" in $doc) {
|
||||
return $doc.mozFullScreen;
|
||||
}
|
||||
return false
|
||||
}-*/;
|
||||
if ("webkitIsFullScreen" in $doc) {
|
||||
return $doc.webkitIsFullScreen;
|
||||
}
|
||||
if ("mozFullScreen" in $doc) {
|
||||
return $doc.mozFullScreen;
|
||||
}
|
||||
return false
|
||||
}-*/;
|
||||
|
||||
private void fullscreenChanged() {
|
||||
if (!isFullscreen()) {
|
||||
@ -198,39 +198,39 @@ public class GwtGraphics implements Graphics {
|
||||
}
|
||||
|
||||
private native boolean setFullscreenJSNI(GwtGraphics graphics, CanvasElement element) /*-{
|
||||
if (element.webkitRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||
$doc
|
||||
.addEventListener(
|
||||
"webkitfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
if (element.mozRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.mozRequestFullScreen();
|
||||
$doc
|
||||
.addEventListener(
|
||||
"mozfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
if (element.webkitRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||
$doc
|
||||
.addEventListener(
|
||||
"webkitfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
if (element.mozRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.mozRequestFullScreen();
|
||||
$doc
|
||||
.addEventListener(
|
||||
"mozfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
|
||||
private native void exitFullscreen() /*-{
|
||||
if ($doc.webkitExitFullscreen)
|
||||
$doc.webkitExitFullscreen();
|
||||
if ($doc.mozExitFullscreen)
|
||||
$doc.mozExitFullscreen();
|
||||
}-*/;
|
||||
if ($doc.webkitExitFullscreen)
|
||||
$doc.webkitExitFullscreen();
|
||||
if ($doc.mozExitFullscreen)
|
||||
$doc.mozExitFullscreen();
|
||||
}-*/;
|
||||
|
||||
@Override
|
||||
public DisplayMode getDesktopDisplayMode() {
|
||||
|
@ -271,22 +271,22 @@ public class GwtInput implements Input {
|
||||
*/
|
||||
private native boolean isCursorCatchedJSNI() /*-{
|
||||
if (!navigator.pointer) {
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
if (navigator.pointer) {
|
||||
if (typeof (navigator.pointer.isLocked) === "boolean") {
|
||||
// Chrome initially launched with this interface
|
||||
return navigator.pointer.isLocked;
|
||||
} else if (typeof (navigator.pointer.isLocked) === "function") {
|
||||
// Some older builds might provide isLocked as a function
|
||||
return navigator.pointer.isLocked();
|
||||
} else if (typeof (navigator.pointer.islocked) === "function") {
|
||||
// For compatibility with early Firefox build
|
||||
return navigator.pointer.islocked();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
if (navigator.pointer) {
|
||||
if (typeof (navigator.pointer.isLocked) === "boolean") {
|
||||
// Chrome initially launched with this interface
|
||||
return navigator.pointer.isLocked;
|
||||
} else if (typeof (navigator.pointer.isLocked) === "function") {
|
||||
// Some older builds might provide isLocked as a function
|
||||
return navigator.pointer.isLocked();
|
||||
} else if (typeof (navigator.pointer.islocked) === "function") {
|
||||
// For compatibility with early Firefox build
|
||||
return navigator.pointer.islocked();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
@ -295,40 +295,40 @@ public class GwtInput implements Input {
|
||||
*/
|
||||
private native void setCursorCatchedJSNI(CanvasElement element) /*-{
|
||||
// Navigator pointer is not the right interface according to spec.
|
||||
// Here for backwards compatibility only
|
||||
if (!navigator.pointer) {
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
// element.requestPointerLock
|
||||
if (!element.requestPointerLock) {
|
||||
element.requestPointerLock = (function() {
|
||||
return element.webkitRequestPointerLock
|
||||
|| element.mozRequestPointerLock || function() {
|
||||
if (navigator.pointer) {
|
||||
navigator.pointer.lock(element);
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
element.requestPointerLock();
|
||||
}-*/;
|
||||
// Here for backwards compatibility only
|
||||
if (!navigator.pointer) {
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
// element.requestPointerLock
|
||||
if (!element.requestPointerLock) {
|
||||
element.requestPointerLock = (function() {
|
||||
return element.webkitRequestPointerLock
|
||||
|| element.mozRequestPointerLock || function() {
|
||||
if (navigator.pointer) {
|
||||
navigator.pointer.lock(element);
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
element.requestPointerLock();
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
*/
|
||||
private native void exitCursorCatchedJSNI() /*-{
|
||||
if (!$doc.exitPointerLock) {
|
||||
$doc.exitPointerLock = (function() {
|
||||
return $doc.webkitExitPointerLock || $doc.mozExitPointerLock
|
||||
|| function() {
|
||||
if (navigator.pointer) {
|
||||
var elem = this;
|
||||
navigator.pointer.unlock();
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
}-*/;
|
||||
if (!$doc.exitPointerLock) {
|
||||
$doc.exitPointerLock = (function() {
|
||||
return $doc.webkitExitPointerLock || $doc.mozExitPointerLock
|
||||
|| function() {
|
||||
if (navigator.pointer) {
|
||||
var elem = this;
|
||||
navigator.pointer.unlock();
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
@ -337,8 +337,8 @@ public class GwtInput implements Input {
|
||||
* @return movement in x direction
|
||||
*/
|
||||
private native float getMovementXJSNI(NativeEvent event) /*-{
|
||||
return event.movementX || event.webkitMovementX || 0;
|
||||
}-*/;
|
||||
return event.movementX || event.webkitMovementX || 0;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
@ -347,12 +347,12 @@ public class GwtInput implements Input {
|
||||
* @return movement in y direction
|
||||
*/
|
||||
private native float getMovementYJSNI(NativeEvent event) /*-{
|
||||
return event.movementY || event.webkitMovementY || 0;
|
||||
}-*/;
|
||||
return event.movementY || event.webkitMovementY || 0;
|
||||
}-*/;
|
||||
|
||||
private static native boolean isTouchScreen() /*-{
|
||||
return (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
|
||||
}-*/;
|
||||
return (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* works only for Chrome > Version 18 with enabled Mouse Lock enable in
|
||||
@ -384,55 +384,55 @@ public class GwtInput implements Input {
|
||||
// kindly borrowed from our dear playn friends...
|
||||
static native void addEventListener(JavaScriptObject target, String name, GwtInput handler,
|
||||
boolean capture) /*-{
|
||||
target
|
||||
.addEventListener(
|
||||
name,
|
||||
function(e) {
|
||||
handler.@com.badlogic.gdx.backends.gwt.GwtInput::handleEvent(Lcom/google/gwt/dom/client/NativeEvent;)(e);
|
||||
}, capture);
|
||||
}-*/;
|
||||
target
|
||||
.addEventListener(
|
||||
name,
|
||||
function(e) {
|
||||
handler.@com.badlogic.gdx.backends.gwt.GwtInput::handleEvent(Lcom/google/gwt/dom/client/NativeEvent;)(e);
|
||||
}, capture);
|
||||
}-*/;
|
||||
|
||||
private static native float getMouseWheelVelocity(NativeEvent evt) /*-{
|
||||
var delta = 0.0;
|
||||
var agentInfo = @com.badlogic.gdx.backends.gwt.GwtApplication::agentInfo()();
|
||||
var delta = 0.0;
|
||||
var agentInfo = @com.badlogic.gdx.backends.gwt.GwtApplication::agentInfo()();
|
||||
|
||||
if (agentInfo.isFirefox) {
|
||||
if (agentInfo.isMacOS) {
|
||||
delta = 1.0 * evt.detail;
|
||||
} else {
|
||||
delta = 1.0 * evt.detail / 3;
|
||||
}
|
||||
} else if (agentInfo.isOpera) {
|
||||
if (agentInfo.isLinux) {
|
||||
delta = -1.0 * evt.wheelDelta / 80;
|
||||
} else {
|
||||
// on mac
|
||||
delta = -1.0 * evt.wheelDelta / 40;
|
||||
}
|
||||
} else if (agentInfo.isChrome || agentInfo.isSafari) {
|
||||
delta = -1.0 * evt.wheelDelta / 120;
|
||||
// handle touchpad for chrome
|
||||
if (Math.abs(delta) < 1) {
|
||||
if (agentInfo.isWindows) {
|
||||
delta = -1.0 * evt.wheelDelta;
|
||||
} else if (agentInfo.isMacOS) {
|
||||
delta = -1.0 * evt.wheelDelta / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return delta;
|
||||
}-*/;
|
||||
if (agentInfo.isFirefox) {
|
||||
if (agentInfo.isMacOS) {
|
||||
delta = 1.0 * evt.detail;
|
||||
} else {
|
||||
delta = 1.0 * evt.detail / 3;
|
||||
}
|
||||
} else if (agentInfo.isOpera) {
|
||||
if (agentInfo.isLinux) {
|
||||
delta = -1.0 * evt.wheelDelta / 80;
|
||||
} else {
|
||||
// on mac
|
||||
delta = -1.0 * evt.wheelDelta / 40;
|
||||
}
|
||||
} else if (agentInfo.isChrome || agentInfo.isSafari) {
|
||||
delta = -1.0 * evt.wheelDelta / 120;
|
||||
// handle touchpad for chrome
|
||||
if (Math.abs(delta) < 1) {
|
||||
if (agentInfo.isWindows) {
|
||||
delta = -1.0 * evt.wheelDelta;
|
||||
} else if (agentInfo.isMacOS) {
|
||||
delta = -1.0 * evt.wheelDelta / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return delta;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Kindly borrowed from PlayN.
|
||||
**/
|
||||
protected static native String getMouseWheelEvent() /*-{
|
||||
if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
|
||||
return "DOMMouseScroll";
|
||||
} else {
|
||||
return "mousewheel";
|
||||
}
|
||||
}-*/;
|
||||
if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
|
||||
return "DOMMouseScroll";
|
||||
} else {
|
||||
return "mousewheel";
|
||||
}
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Kindly borrowed from PlayN.
|
||||
@ -452,15 +452,15 @@ public class GwtInput implements Input {
|
||||
|
||||
private void hookEvents() {
|
||||
addEventListener(canvas, "mousedown", this, true);
|
||||
// addEventListener(Document.get(), "mousedown", this, true);
|
||||
// addEventListener(Document.get(), "mousedown", this, true);
|
||||
addEventListener(canvas, "mouseup", this, true);
|
||||
// addEventListener(Document.get(), "mouseup", this, true);
|
||||
// addEventListener(Document.get(), "mouseup", this, true);
|
||||
addEventListener(canvas, "mousemove", this, true);
|
||||
// addEventListener(Document.get(), "mousemove", this, true);
|
||||
// addEventListener(Document.get(), "mousemove", this, true);
|
||||
addEventListener(canvas, getMouseWheelEvent(), this, true);
|
||||
// addEventListener(Document.get(), "keydown", this, false);
|
||||
// addEventListener(Document.get(), "keyup", this, false);
|
||||
// addEventListener(Document.get(), "keypress", this, false);
|
||||
// addEventListener(Document.get(), "keydown", this, false);
|
||||
// addEventListener(Document.get(), "keyup", this, false);
|
||||
// addEventListener(Document.get(), "keypress", this, false);
|
||||
addEventListener(canvas, "keydown", this, false);
|
||||
addEventListener(canvas, "keyup", this, false);
|
||||
addEventListener(canvas, "keypress", this, false);
|
||||
|
@ -379,25 +379,25 @@ public class GLMatrix {
|
||||
System.arraycopy(tmp, 0, mata, 0, 16);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void finalize() {
|
||||
// if (pointer != 0)
|
||||
// delete(pointer);
|
||||
// }
|
||||
// @Override
|
||||
// public void finalize() {
|
||||
// if (pointer != 0)
|
||||
// delete(pointer);
|
||||
// }
|
||||
|
||||
/* Copyright (C) 2007 The Android Open Source Project
|
||||
/* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License. */
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License. */
|
||||
|
||||
/**
|
||||
* Define a projection matrix in terms of six clip planes
|
||||
|
@ -118,8 +118,8 @@ public class LwHttp implements HttpEngine {
|
||||
|
||||
@Override
|
||||
public boolean requestCompleted(boolean success) {
|
||||
// mHttpRequest.clearOnReadyStateChange();
|
||||
// mHttpRequest = null;
|
||||
// mHttpRequest.clearOnReadyStateChange();
|
||||
// mHttpRequest = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -87,11 +87,11 @@ public class BitmapTileSource extends UrlTileSource {
|
||||
final Image img = new Image();
|
||||
img.setVisible(false);
|
||||
|
||||
/* As if researching CORS issues doesnt result in
|
||||
/* As if researching CORS issues doesnt result in
|
||||
* enough headache...
|
||||
*
|
||||
* Here are some more special Chrome/Webkit quirks:
|
||||
* MUST SET CORS BEFORE URL! */
|
||||
*
|
||||
* Here are some more special Chrome/Webkit quirks:
|
||||
* MUST SET CORS BEFORE URL! */
|
||||
img.getElement().setAttribute("crossorigin", "anonymous");
|
||||
img.setUrl(uri);
|
||||
|
||||
|
@ -124,17 +124,17 @@ public class Tessellator {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if (vo.length() != plen) {
|
||||
// // TODO handle different output points
|
||||
// log.debug(" + io.length());
|
||||
// if (vo.length() != plen) {
|
||||
// // TODO handle different output points
|
||||
// log.debug(" + io.length());
|
||||
//
|
||||
// //for (int i = 0; i < vo.length(); i += 2)
|
||||
// // log.debug(vo.get(i) + " " + vo.get(i + 1));
|
||||
// //for (int i = ppos; i < ppos + plen; i += 2)
|
||||
// // log.debug( points[i]+ " " + points[i + 1]);
|
||||
// //for (int i = 0; i < vo.length(); i += 2)
|
||||
// // log.debug(vo.get(i) + " " + vo.get(i + 1));
|
||||
// //for (int i = ppos; i < ppos + plen; i += 2)
|
||||
// // log.debug( points[i]+ " " + points[i + 1]);
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int numIndices = io.length();
|
||||
|
||||
@ -164,17 +164,17 @@ public class Tessellator {
|
||||
static native Int32Array tessellate(JsArrayNumber points, int pOffset, int pLength,
|
||||
JsArrayInteger bounds, int bOffset, int bLength)/*-{
|
||||
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, false);
|
||||
}-*/;
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, false);
|
||||
}-*/;
|
||||
|
||||
static native TessResult tessellate2(JsArrayNumber points, int pOffset, int pLength,
|
||||
JsArrayInteger bounds, int bOffset, int bLength)
|
||||
/*-{
|
||||
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, true);
|
||||
}-*/;
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, true);
|
||||
}-*/;
|
||||
|
||||
static final class TessResult extends JavaScriptObject {
|
||||
protected TessResult() {
|
||||
@ -182,10 +182,10 @@ public class Tessellator {
|
||||
|
||||
native Float32Array getPoints(JavaScriptObject result)/*-{
|
||||
return result.vertices;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
native Int32Array getIndices(JavaScriptObject result)/*-{
|
||||
return result.triangles;
|
||||
}-*/;
|
||||
return result.triangles;
|
||||
}-*/;
|
||||
}
|
||||
}
|
||||
|
@ -1,107 +1,107 @@
|
||||
tessellate = (function() {
|
||||
|
||||
Module.TOTAL_MEMORY = 1024 * 1024;
|
||||
Module.TOTAL_MEMORY = 1024 * 1024;
|
||||
|
||||
var c_tessellate = Module.cwrap('tessellate', 'void', [ 'number', 'number',
|
||||
'number', 'number', 'number', 'number' ]);
|
||||
var c_tessellate = Module.cwrap('tessellate', 'void', [ 'number', 'number',
|
||||
'number', 'number', 'number', 'number' ]);
|
||||
|
||||
// special tessellator for extrusion layer - only returns triangle indices
|
||||
var tessellate = function(vertices, v_start, v_end, boundaries, b_start,
|
||||
b_end, mode) {
|
||||
var i;
|
||||
// special tessellator for extrusion layer - only returns triangle indices
|
||||
var tessellate = function(vertices, v_start, v_end, boundaries, b_start,
|
||||
b_end, mode) {
|
||||
var i;
|
||||
|
||||
var v_len = (v_end - v_start);
|
||||
var b_len = (b_end - b_start);
|
||||
var v_len = (v_end - v_start);
|
||||
var b_len = (b_end - b_start);
|
||||
|
||||
var p = Module._malloc(v_len * 8);
|
||||
var p = Module._malloc(v_len * 8);
|
||||
|
||||
for (i = 0; i < v_len; ++i)
|
||||
Module.setValue(p + i * 8, vertices[v_start + i], 'double');
|
||||
for (i = 0; i < v_len; ++i)
|
||||
Module.setValue(p + i * 8, vertices[v_start + i], 'double');
|
||||
|
||||
var contours = Module._malloc((b_len + 1) * 4);
|
||||
var contours = Module._malloc((b_len + 1) * 4);
|
||||
|
||||
// pointer to first contour
|
||||
Module.setValue(contours + 0, p + 0, 'i32');
|
||||
var offset = p;
|
||||
// pointer to first contour
|
||||
Module.setValue(contours + 0, p + 0, 'i32');
|
||||
var offset = p;
|
||||
|
||||
// pointer to further contours + end
|
||||
for (i = 0; i < b_len; ++i) {
|
||||
offset += 8 * boundaries[b_start + i];
|
||||
Module.setValue(contours + 4 * (i + 1), offset, 'i32');
|
||||
}
|
||||
// pointer to further contours + end
|
||||
for (i = 0; i < b_len; ++i) {
|
||||
offset += 8 * boundaries[b_start + i];
|
||||
Module.setValue(contours + 4 * (i + 1), offset, 'i32');
|
||||
}
|
||||
|
||||
var ppcoordinates_out = Module._malloc(4);
|
||||
var pptris_out = Module._malloc(4);
|
||||
var pnverts = Module._malloc(4);
|
||||
var pntris = Module._malloc(4);
|
||||
var ppcoordinates_out = Module._malloc(4);
|
||||
var pptris_out = Module._malloc(4);
|
||||
var pnverts = Module._malloc(4);
|
||||
var pntris = Module._malloc(4);
|
||||
|
||||
c_tessellate(ppcoordinates_out, pnverts, pptris_out, pntris, contours,
|
||||
contours + 4 * (b_len + 1));
|
||||
c_tessellate(ppcoordinates_out, pnverts, pptris_out, pntris, contours,
|
||||
contours + 4 * (b_len + 1));
|
||||
|
||||
var pcoordinates_out = Module.getValue(ppcoordinates_out, 'i32');
|
||||
var ptris_out = Module.getValue(pptris_out, 'i32');
|
||||
var pcoordinates_out = Module.getValue(ppcoordinates_out, 'i32');
|
||||
var ptris_out = Module.getValue(pptris_out, 'i32');
|
||||
|
||||
var nverts = Module.getValue(pnverts, 'i32');
|
||||
var ntris = Module.getValue(pntris, 'i32');
|
||||
var nverts = Module.getValue(pnverts, 'i32');
|
||||
var ntris = Module.getValue(pntris, 'i32');
|
||||
|
||||
var result_triangles = null;
|
||||
var result_vertices = null;
|
||||
var result_triangles = null;
|
||||
var result_vertices = null;
|
||||
|
||||
if (mode){
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
for (i = 0; i < 3 * ntris; ++i)
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32');
|
||||
|
||||
result_vertices = new Float32Array(nverts * 2);
|
||||
for (i = 0; i < 2 * nverts; ++i)
|
||||
result_vertices[i] = Module.getValue(pcoordinates_out + i * 8, 'double');
|
||||
|
||||
} else {
|
||||
if (nverts * 2 == v_len) {
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
|
||||
for (i = 0; i < 3 * ntris; ++i) {
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32') * 2;
|
||||
}
|
||||
// when a ring has an odd number of points one (or rather two)
|
||||
// additional vertices will be added. so the following rings
|
||||
// needs extra offset...
|
||||
var start = 0;
|
||||
for ( var j = 0, m = b_len - 1; j < m; j++) {
|
||||
start += boundaries[b_start + j];
|
||||
if (mode){
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
for (i = 0; i < 3 * ntris; ++i)
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32');
|
||||
|
||||
result_vertices = new Float32Array(nverts * 2);
|
||||
for (i = 0; i < 2 * nverts; ++i)
|
||||
result_vertices[i] = Module.getValue(pcoordinates_out + i * 8, 'double');
|
||||
|
||||
} else {
|
||||
if (nverts * 2 == v_len) {
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
|
||||
for (i = 0; i < 3 * ntris; ++i) {
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32') * 2;
|
||||
}
|
||||
// when a ring has an odd number of points one (or rather two)
|
||||
// additional vertices will be added. so the following rings
|
||||
// needs extra offset...
|
||||
var start = 0;
|
||||
for ( var j = 0, m = b_len - 1; j < m; j++) {
|
||||
start += boundaries[b_start + j];
|
||||
|
||||
// even number of points?
|
||||
if (!((boundaries[b_start + j] >> 1) & 1))
|
||||
continue;
|
||||
// even number of points?
|
||||
if (!((boundaries[b_start + j] >> 1) & 1))
|
||||
continue;
|
||||
|
||||
for ( var n = ntris * 3, tri = 0; tri < n; tri++)
|
||||
if (result_triangles[tri] >= start)
|
||||
result_triangles[tri] += 2;
|
||||
for ( var n = ntris * 3, tri = 0; tri < n; tri++)
|
||||
if (result_triangles[tri] >= start)
|
||||
result_triangles[tri] += 2;
|
||||
|
||||
start += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Module._free(pnverts);
|
||||
Module._free(pntris);
|
||||
|
||||
Module._free(ppcoordinates_out);
|
||||
Module._free(pcoordinates_out);
|
||||
|
||||
Module._free(pptris_out);
|
||||
Module._free(ptris_out);
|
||||
start += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Module._free(pnverts);
|
||||
Module._free(pntris);
|
||||
|
||||
Module._free(ppcoordinates_out);
|
||||
Module._free(pcoordinates_out);
|
||||
|
||||
Module._free(pptris_out);
|
||||
Module._free(ptris_out);
|
||||
|
||||
Module._free(p);
|
||||
Module._free(contours);
|
||||
|
||||
if (mode)
|
||||
return { vertices: result_vertices, triangles: result_triangles };
|
||||
else
|
||||
return result_triangles;
|
||||
|
||||
};
|
||||
Module._free(p);
|
||||
Module._free(contours);
|
||||
|
||||
if (mode)
|
||||
return { vertices: result_vertices, triangles: result_triangles };
|
||||
else
|
||||
return result_triangles;
|
||||
|
||||
};
|
||||
|
||||
return tessellate;
|
||||
return tessellate;
|
||||
|
||||
})();
|
||||
|
@ -27,15 +27,15 @@ public class Feature extends GeoJsonObject {
|
||||
|
||||
public final native Geometry<?> getGeometry() /*-{
|
||||
return this.geometry;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native String getId() /*-{
|
||||
return this.id;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native void setId(String id) /*-{
|
||||
this.id = id;
|
||||
}-*/;
|
||||
this.id = id;
|
||||
}-*/;
|
||||
|
||||
public final Map<String, Object> getProperties(HashMap<String, Object> map) {
|
||||
map.clear();
|
||||
@ -45,8 +45,8 @@ public class Feature extends GeoJsonObject {
|
||||
}
|
||||
|
||||
public final native void fromJavascriptObject(HashMap<String, Object> s) /*-{
|
||||
for(var key in this.properties) {
|
||||
s.@java.util.HashMap::put(Ljava/lang/Object;Ljava/lang/Object;)(key, Object(this.properties[key]));
|
||||
}
|
||||
}-*/;
|
||||
for(var key in this.properties) {
|
||||
s.@java.util.HashMap::put(Ljava/lang/Object;Ljava/lang/Object;)(key, Object(this.properties[key]));
|
||||
}
|
||||
}-*/;
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ public class FeatureCollection extends JavaScriptObject {
|
||||
|
||||
public final native JsArray<Feature> getFeaturesInternal()/*-{
|
||||
return this.features;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ public abstract class GeoJsonObject extends JavaScriptObject {
|
||||
|
||||
public final native double[] getBbox()/*-{
|
||||
return bbox;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native void setBbox(double[] bbox) /*-{
|
||||
this.bbox = bbox;
|
||||
}-*/;
|
||||
}-*/;
|
||||
}
|
||||
|
@ -65,12 +65,12 @@ public class GeoJsonTileDecoder implements ITileDecoder {
|
||||
mapElement.clear();
|
||||
mapElement.tags.clear();
|
||||
|
||||
/* add tag information */
|
||||
/* add tag information */
|
||||
mTileSource.decodeTags(mapElement, f.getProperties(mProperties));
|
||||
if (mapElement.tags.numTags == 0)
|
||||
continue;
|
||||
|
||||
/* add geometry information */
|
||||
/* add geometry information */
|
||||
decodeGeometry(f.getGeometry());
|
||||
|
||||
if (mapElement.type == GeometryType.NONE)
|
||||
|
@ -27,9 +27,9 @@ public abstract class Geometry<T extends JavaScriptObject> extends JsArray<T> {
|
||||
|
||||
public final native String type()/*-{
|
||||
return this.type
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native JsArray<T> getCoordinates() /*-{
|
||||
return this.coordinates;
|
||||
}-*/;
|
||||
}-*/;
|
||||
}
|
||||
|
@ -83,19 +83,19 @@ public class JsArrayCollection<T> extends AbstractCollection<T> {
|
||||
|
||||
public native final JsArr<T> slice(int start, int end)/*-{
|
||||
return this.slice(start, end);
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public static final native <T> JsArr<T> create() /*-{
|
||||
return [];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int size() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
return this.length;
|
||||
}-*/;
|
||||
|
||||
public final native T get(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
return this[i];
|
||||
}-*/;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ public class LngLat extends JavaScriptObject {
|
||||
|
||||
public final native double getLongitude() /*-{
|
||||
return this[0];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native double getLatitude() /*-{
|
||||
return this[1];
|
||||
}-*/;
|
||||
}-*/;
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ public class MultiLineString extends Geometry<LineString> {
|
||||
|
||||
public final native LineString getGeometryN(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int getNumGeometries() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ public class MultiPolygon extends Geometry<Polygon> {
|
||||
|
||||
public final native Polygon getGeometryN(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int getNumGeometries() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ public class Polygon extends Geometry<LineString> {
|
||||
|
||||
public final native LineString getExteriorRing()/*-{
|
||||
return this[0];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native LineString getRing(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int getNumRings() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
return this.length;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
@ -212,18 +212,18 @@ public class GeometryBuffer {
|
||||
public GeometryBuffer startLine() {
|
||||
setOrCheckMode(GeometryType.LINE);
|
||||
|
||||
/* ignore */
|
||||
/* ignore */
|
||||
if (index[indexPos] > 0) {
|
||||
|
||||
/* start next */
|
||||
/* start next */
|
||||
if ((index[0] >= 0) && (++indexPos >= index.length))
|
||||
ensureIndexSize(indexPos, true);
|
||||
|
||||
/* initialize with zero points */
|
||||
/* initialize with zero points */
|
||||
index[indexPos] = 0;
|
||||
}
|
||||
|
||||
/* set new end marker */
|
||||
/* set new end marker */
|
||||
if (index.length > indexPos + 1)
|
||||
index[indexPos + 1] = -1;
|
||||
return this;
|
||||
@ -243,14 +243,14 @@ public class GeometryBuffer {
|
||||
/* end polygon */
|
||||
index[++indexPos] = 0;
|
||||
|
||||
/* next polygon start */
|
||||
/* next polygon start */
|
||||
indexPos++;
|
||||
}
|
||||
|
||||
/* initialize with zero points */
|
||||
/* initialize with zero points */
|
||||
index[indexPos] = 0;
|
||||
|
||||
/* set new end marker */
|
||||
/* set new end marker */
|
||||
if (index.length > indexPos + 1)
|
||||
index[indexPos + 1] = -1;
|
||||
|
||||
@ -266,10 +266,10 @@ public class GeometryBuffer {
|
||||
if ((indexPos + 2) > index.length)
|
||||
ensureIndexSize(indexPos + 1, true);
|
||||
|
||||
/* initialize with zero points */
|
||||
/* initialize with zero points */
|
||||
index[++indexPos] = 0;
|
||||
|
||||
/* set new end marker */
|
||||
/* set new end marker */
|
||||
if (index.length > indexPos + 1)
|
||||
index[indexPos + 1] = -1;
|
||||
}
|
||||
@ -378,7 +378,7 @@ public class GeometryBuffer {
|
||||
float px = points[inPos++];
|
||||
float py = points[inPos++];
|
||||
|
||||
/* add first point */
|
||||
/* add first point */
|
||||
points[outPos++] = px;
|
||||
points[outPos++] = py;
|
||||
int cnt = 2;
|
||||
|
@ -172,7 +172,7 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
||||
pivotY = mPrevY1 - mMap.getHeight() / 2;
|
||||
}
|
||||
|
||||
/* handle double tap zoom */
|
||||
/* handle double tap zoom */
|
||||
mMap.animator().animateZoom(300, 2, pivotX, pivotY);
|
||||
|
||||
} else if (mStartMove > 0) {
|
||||
@ -181,7 +181,7 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
||||
float vx = mTracker.getVelocityX();
|
||||
float vy = mTracker.getVelocityY();
|
||||
|
||||
/* reduce velocity for short moves */
|
||||
/* reduce velocity for short moves */
|
||||
float t = e.getTime() - mStartMove;
|
||||
if (t < FLING_MIN_THREHSHOLD) {
|
||||
t = t / FLING_MIN_THREHSHOLD;
|
||||
@ -227,9 +227,9 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
||||
mPrevX1 = x1;
|
||||
mPrevY1 = y1;
|
||||
|
||||
/* double-tap drag zoom */
|
||||
/* double-tap drag zoom */
|
||||
if (mDoubleTap) {
|
||||
/* just ignore first move event to set mPrevX/Y */
|
||||
/* just ignore first move event to set mPrevX/Y */
|
||||
if (!mDown) {
|
||||
mDown = true;
|
||||
return;
|
||||
@ -248,7 +248,7 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
||||
return;
|
||||
}
|
||||
|
||||
/* simple move */
|
||||
/* simple move */
|
||||
if (!mEnableMove)
|
||||
return;
|
||||
|
||||
@ -290,7 +290,7 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
||||
if (mDoTilt) {
|
||||
tiltBy = my / 5;
|
||||
} else if (Math.abs(my) > (dpi / PINCH_TILT_THRESHOLD)) {
|
||||
/* enter exclusive tilt mode */
|
||||
/* enter exclusive tilt mode */
|
||||
mCanScale = false;
|
||||
mCanRotate = false;
|
||||
mDoTilt = true;
|
||||
@ -317,25 +317,25 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
||||
} else {
|
||||
r = Math.abs(r);
|
||||
if (r > PINCH_ROTATE_THRESHOLD) {
|
||||
/* start rotate, disable tilt */
|
||||
/* start rotate, disable tilt */
|
||||
mDoRotate = true;
|
||||
mCanTilt = false;
|
||||
|
||||
mAngle = rad;
|
||||
} else if (!mDoScale) {
|
||||
/* reduce pinch trigger by the amount of rotation */
|
||||
/* reduce pinch trigger by the amount of rotation */
|
||||
deltaPinch *= 1 - (r / PINCH_ROTATE_THRESHOLD);
|
||||
} else {
|
||||
mPrevPinchWidth = pinchWidth;
|
||||
}
|
||||
}
|
||||
} else if (mDoScale && mEnableRotate) {
|
||||
/* re-enable rotation when higher threshold is reached */
|
||||
/* re-enable rotation when higher threshold is reached */
|
||||
double rad = Math.atan2(dy, dx);
|
||||
double r = rad - mAngle;
|
||||
|
||||
if (r > PINCH_ROTATE_THRESHOLD2) {
|
||||
/* start rotate again */
|
||||
/* start rotate again */
|
||||
mDoRotate = true;
|
||||
mCanRotate = true;
|
||||
mAngle = rad;
|
||||
@ -344,7 +344,7 @@ public class MapEventLayer extends Layer implements InputListener, GestureListen
|
||||
|
||||
if (mCanScale || mDoRotate) {
|
||||
if (!(mDoScale || mDoRotate)) {
|
||||
/* enter exclusive scale mode */
|
||||
/* enter exclusive scale mode */
|
||||
if (Math.abs(deltaPinch) > (dpi / PINCH_ZOOM_THRESHOLD)) {
|
||||
|
||||
if (!mDoRotate) {
|
||||
|
@ -129,10 +129,10 @@ public class PathLayer extends Layer {
|
||||
public void addGreatCircle(GeoPoint startPoint, GeoPoint endPoint) {
|
||||
synchronized (mPoints) {
|
||||
|
||||
/* get the great circle path length in meters */
|
||||
/* get the great circle path length in meters */
|
||||
double length = startPoint.distanceTo(endPoint);
|
||||
|
||||
/* add one point for every 100kms of the great circle path */
|
||||
/* add one point for every 100kms of the great circle path */
|
||||
int numberOfPoints = (int) (length / 100000);
|
||||
|
||||
addGreatCircle(startPoint, endPoint, numberOfPoints);
|
||||
|
@ -117,10 +117,10 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
|
||||
* easily override behavior without resorting to overriding the
|
||||
* ItemGestureListener methods.
|
||||
*/
|
||||
// @Override
|
||||
// public boolean onTap(MotionEvent event, MapPosition pos) {
|
||||
// return activateSelectedItems(event, mActiveItemSingleTap);
|
||||
// }
|
||||
// @Override
|
||||
// public boolean onTap(MotionEvent event, MapPosition pos) {
|
||||
// return activateSelectedItems(event, mActiveItemSingleTap);
|
||||
// }
|
||||
protected boolean onSingleTapUpHelper(int index, Item item) {
|
||||
return mOnItemGestureListener.onItemSingleTapUp(index, item);
|
||||
}
|
||||
@ -175,7 +175,7 @@ public class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer<Item>
|
||||
int inside = -1;
|
||||
double insideY = -Double.MAX_VALUE;
|
||||
|
||||
/* squared dist: 50*50 pixel ~ 2mm on 400dpi */
|
||||
/* squared dist: 50*50 pixel ~ 2mm on 400dpi */
|
||||
double dist = 2500;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
@ -101,7 +101,7 @@ public class MarkerRenderer extends BucketRenderer {
|
||||
float cos = (float) Math.cos(angle);
|
||||
float sin = (float) Math.sin(angle);
|
||||
|
||||
/* check visibility */
|
||||
/* check visibility */
|
||||
for (InternalItem it : mItems) {
|
||||
it.changes = false;
|
||||
it.x = (float) ((it.px - mx) * scale);
|
||||
@ -131,10 +131,10 @@ public class MarkerRenderer extends BucketRenderer {
|
||||
|
||||
//log.debug(numVisible + " " + changedVisible + " " + changesInvisible);
|
||||
|
||||
/* only update when zoomlevel changed, new items are visible
|
||||
/* only update when zoomlevel changed, new items are visible
|
||||
* or more than 10 of the current items became invisible */
|
||||
//if ((numVisible == 0) && (changedVisible == 0 && changesInvisible < 10))
|
||||
// return;
|
||||
// return;
|
||||
buckets.clear();
|
||||
|
||||
if (numVisible == 0) {
|
||||
@ -182,7 +182,7 @@ public class MarkerRenderer extends BucketRenderer {
|
||||
tmp[i] = it;
|
||||
it.item = mMarkerLayer.createItem(i);
|
||||
|
||||
/* pre-project points */
|
||||
/* pre-project points */
|
||||
MercatorProjection.project(it.item.getPoint(), mMapPoint);
|
||||
it.px = mMapPoint.x;
|
||||
it.py = mMapPoint.y;
|
||||
@ -228,24 +228,24 @@ public class MarkerRenderer extends BucketRenderer {
|
||||
}
|
||||
};
|
||||
|
||||
// /**
|
||||
// * Returns the Item at the given index.
|
||||
// *
|
||||
// * @param position
|
||||
// * the position of the item to return
|
||||
// * @return the Item of the given index.
|
||||
// */
|
||||
// public final Item getItem(int position) {
|
||||
// /**
|
||||
// * Returns the Item at the given index.
|
||||
// *
|
||||
// * @param position
|
||||
// * the position of the item to return
|
||||
// * @return the Item of the given index.
|
||||
// */
|
||||
// public final Item getItem(int position) {
|
||||
//
|
||||
// synchronized (lock) {
|
||||
// InternalItem item = mItems;
|
||||
// for (int i = mSize - position - 1; i > 0 && item != null; i--)
|
||||
// item = item.next;
|
||||
// synchronized (lock) {
|
||||
// InternalItem item = mItems;
|
||||
// for (int i = mSize - position - 1; i > 0 && item != null; i--)
|
||||
// item = item.next;
|
||||
//
|
||||
// if (item != null)
|
||||
// return item.item;
|
||||
// if (item != null)
|
||||
// return item.item;
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ public class MapTile extends Tile {
|
||||
node.child(i).refs--;
|
||||
}
|
||||
|
||||
/* removed all proxy references for this tile */
|
||||
/* removed all proxy references for this tile */
|
||||
proxy = 0;
|
||||
|
||||
if (state == DEADBEEF) {
|
||||
@ -411,9 +411,9 @@ public class MapTile extends Tile {
|
||||
if (state == newState)
|
||||
return;
|
||||
|
||||
/* Renderer could have uploaded the tile while the layer
|
||||
* was cleared. This prevents to set tile to READY state. */
|
||||
/* All other state changes are on the main-thread. */
|
||||
/* Renderer could have uploaded the tile while the layer
|
||||
* was cleared. This prevents to set tile to READY state. */
|
||||
/* All other state changes are on the main-thread. */
|
||||
if (state == DEADBEEF)
|
||||
return;
|
||||
|
||||
|
@ -198,28 +198,28 @@ public class TileManager {
|
||||
|
||||
mIndex.drop();
|
||||
|
||||
/* Pass VBOs and VertexItems back to pools */
|
||||
/* Pass VBOs and VertexItems back to pools */
|
||||
for (int i = 0; i < mTilesEnd; i++) {
|
||||
MapTile t = mTiles[i];
|
||||
if (t == null)
|
||||
continue;
|
||||
|
||||
/* Check if tile is used by another thread */
|
||||
/* Check if tile is used by another thread */
|
||||
if (!t.isLocked())
|
||||
t.clear();
|
||||
|
||||
/* In case the tile is still loading or used by
|
||||
/* In case the tile is still loading or used by
|
||||
* another thread: clear when returned from loader
|
||||
* or becomes unlocked */
|
||||
* or becomes unlocked */
|
||||
t.setState(DEADBEEF);
|
||||
}
|
||||
|
||||
/* clear references to cached MapTiles */
|
||||
/* clear references to cached MapTiles */
|
||||
Arrays.fill(mTiles, null);
|
||||
mTilesEnd = 0;
|
||||
mTilesCount = 0;
|
||||
|
||||
/* set up TileSet large enough to hold current tiles */
|
||||
/* set up TileSet large enough to hold current tiles */
|
||||
int num = Math.max(mMap.getWidth(), mMap.getHeight());
|
||||
int size = Tile.SIZE >> 1;
|
||||
int numTiles = (num * num) / (size * size) * 4;
|
||||
@ -244,11 +244,11 @@ public class TileManager {
|
||||
init();
|
||||
}
|
||||
/* clear JobQueue and set tiles to state == NONE.
|
||||
* one could also append new tiles and sort in JobQueue
|
||||
* but this has the nice side-effect that MapWorkers dont
|
||||
* start with old jobs while new jobs are calculated, which
|
||||
* should increase the chance that they are free when new
|
||||
* jobs come in. */
|
||||
* one could also append new tiles and sort in JobQueue
|
||||
* but this has the nice side-effect that MapWorkers dont
|
||||
* start with old jobs while new jobs are calculated, which
|
||||
* should increase the chance that they are free when new
|
||||
* jobs come in. */
|
||||
jobQueue.clear();
|
||||
|
||||
if (pos.zoomLevel < mMinZoom) {
|
||||
@ -263,29 +263,29 @@ public class TileManager {
|
||||
int tileZoom = clamp(pos.zoomLevel, mMinZoom, mMaxZoom);
|
||||
|
||||
if (mZoomTable == null) {
|
||||
/* greater 1 when zoomed in further than
|
||||
* tile zoomlevel, so [1..2] while whithin
|
||||
* min/maxZoom */
|
||||
/* greater 1 when zoomed in further than
|
||||
* tile zoomlevel, so [1..2] while whithin
|
||||
* min/maxZoom */
|
||||
double scaleDiv = pos.scale / (1 << tileZoom);
|
||||
mLoadParent = scaleDiv < 1.5;
|
||||
|
||||
int zoomDiff = tileZoom - mPrevZoomlevel;
|
||||
if (zoomDiff == 1) {
|
||||
/* dont switch zoomlevel up yet */
|
||||
/* dont switch zoomlevel up yet */
|
||||
if (scaleDiv < mLevelUpThreshold) {
|
||||
tileZoom = mPrevZoomlevel;
|
||||
mLoadParent = false;
|
||||
}
|
||||
} else if (zoomDiff == -1) {
|
||||
/* dont switch zoomlevel down yet */
|
||||
/* dont switch zoomlevel down yet */
|
||||
if (scaleDiv > mLevelDownThreshold) {
|
||||
tileZoom = mPrevZoomlevel;
|
||||
mLoadParent = true;
|
||||
}
|
||||
}
|
||||
// log.debug("p:{} {}:{}=>{} | {} <> {}", mLoadParent,
|
||||
// mPrevZoomlevel, pos.zoomLevel, tileZoom,
|
||||
// scaleDiv, (pos.scale / (1 << tileZoom)));
|
||||
// log.debug("p:{} {}:{}=>{} | {} <> {}", mLoadParent,
|
||||
// mPrevZoomlevel, pos.zoomLevel, tileZoom,
|
||||
// scaleDiv, (pos.scale / (1 << tileZoom)));
|
||||
} else {
|
||||
mLoadParent = false;
|
||||
int match = 0;
|
||||
@ -302,8 +302,8 @@ public class TileManager {
|
||||
|
||||
mViewport.getMapExtents(mMapPlane, Tile.SIZE / 2);
|
||||
|
||||
/* scan visible tiles. callback function calls 'addTile'
|
||||
* which updates mNewTiles */
|
||||
/* scan visible tiles. callback function calls 'addTile'
|
||||
* which updates mNewTiles */
|
||||
mNewTiles.cnt = 0;
|
||||
mScanBox.scan(pos.x, pos.y, pos.scale, tileZoom, mMapPlane);
|
||||
|
||||
@ -318,7 +318,7 @@ public class TileManager {
|
||||
Arrays.sort(newTiles, 0, newCnt, TileSet.coordComparator);
|
||||
|
||||
if (!changed) {
|
||||
/* compare if any tile has changed */
|
||||
/* compare if any tile has changed */
|
||||
for (int i = 0; i < newCnt; i++) {
|
||||
if (newTiles[i] != curTiles[i]) {
|
||||
changed = true;
|
||||
@ -329,13 +329,13 @@ public class TileManager {
|
||||
|
||||
if (changed) {
|
||||
synchronized (mTilelock) {
|
||||
/* lock new tiles */
|
||||
/* lock new tiles */
|
||||
mNewTiles.lockTiles();
|
||||
|
||||
/* unlock previous tiles */
|
||||
/* unlock previous tiles */
|
||||
mCurrentTiles.releaseTiles();
|
||||
|
||||
/* swap newTiles with currentTiles */
|
||||
/* swap newTiles with currentTiles */
|
||||
TileSet tmp = mCurrentTiles;
|
||||
mCurrentTiles = mNewTiles;
|
||||
mNewTiles = tmp;
|
||||
@ -343,11 +343,11 @@ public class TileManager {
|
||||
mUpdateSerial++;
|
||||
}
|
||||
|
||||
/* request rendering as tiles changed */
|
||||
/* request rendering as tiles changed */
|
||||
mMap.render();
|
||||
}
|
||||
|
||||
/* Add tile jobs to queue */
|
||||
/* Add tile jobs to queue */
|
||||
if (mJobs.isEmpty())
|
||||
return false;
|
||||
|
||||
@ -355,7 +355,7 @@ public class TileManager {
|
||||
jobs = mJobs.toArray(jobs);
|
||||
updateDistances(jobs, jobs.length, pos);
|
||||
|
||||
/* sets tiles to state == LOADING */
|
||||
/* sets tiles to state == LOADING */
|
||||
jobQueue.setJobs(jobs);
|
||||
mJobs.clear();
|
||||
|
||||
@ -369,7 +369,7 @@ public class TileManager {
|
||||
}
|
||||
}
|
||||
|
||||
/* limit cache items */
|
||||
/* limit cache items */
|
||||
int remove = mTilesCount - (mCacheLimit - mCacheReduce);
|
||||
|
||||
if (remove > CACHE_THRESHOLD || mTilesToUpload > MAX_TILES_IN_QUEUE) {
|
||||
@ -411,7 +411,7 @@ public class TileManager {
|
||||
if (tileSet.serial == mUpdateSerial)
|
||||
return false;
|
||||
|
||||
/* do not flip mNew/mCurrentTiles while copying */
|
||||
/* do not flip mNew/mCurrentTiles while copying */
|
||||
synchronized (mTilelock) {
|
||||
tileSet.setTiles(mCurrentTiles);
|
||||
tileSet.serial = mUpdateSerial;
|
||||
@ -434,13 +434,13 @@ public class TileManager {
|
||||
}
|
||||
|
||||
if (mLoadParent && (zoomLevel > mMinZoom) && (mZoomTable == null)) {
|
||||
/* prefetch parent */
|
||||
/* prefetch parent */
|
||||
MapTile p = tile.node.parent();
|
||||
if (p == null) {
|
||||
TileNode n = mIndex.add(x >> 1, y >> 1, zoomLevel - 1);
|
||||
p = n.item = new MapTile(n, x >> 1, y >> 1, zoomLevel - 1);
|
||||
addToCache(p);
|
||||
/* this prevents to add tile twice to queue */
|
||||
/* this prevents to add tile twice to queue */
|
||||
p.setState(LOADING);
|
||||
mJobs.add(p);
|
||||
} else if (!p.isActive()) {
|
||||
@ -456,8 +456,8 @@ public class TileManager {
|
||||
if (mTilesEnd == mTiles.length) {
|
||||
if (mTilesEnd > mTilesCount) {
|
||||
TileDistanceSort.sort(mTiles, 0, mTilesEnd);
|
||||
/* sorting also repacks the 'sparse' filled array
|
||||
* so end of mTiles is at mTilesCount now */
|
||||
/* sorting also repacks the 'sparse' filled array
|
||||
* so end of mTiles is at mTilesCount now */
|
||||
mTilesEnd = mTilesCount;
|
||||
}
|
||||
|
||||
@ -474,8 +474,8 @@ public class TileManager {
|
||||
}
|
||||
|
||||
private boolean removeFromCache(MapTile t) {
|
||||
/* TODO check valid states here:When in CANCEL state tile belongs to
|
||||
* TileLoader thread, defer clearing to jobCompleted() */
|
||||
/* TODO check valid states here:When in CANCEL state tile belongs to
|
||||
* TileLoader thread, defer clearing to jobCompleted() */
|
||||
|
||||
if (dbg)
|
||||
log.debug("remove from cache {} {} {}",
|
||||
@ -497,10 +497,10 @@ public class TileManager {
|
||||
private void limitCache(MapPosition pos, int remove) {
|
||||
MapTile[] tiles = mTiles;
|
||||
|
||||
/* count tiles that have new data */
|
||||
/* count tiles that have new data */
|
||||
int newTileCnt = 0;
|
||||
|
||||
/* remove tiles that were never loaded */
|
||||
/* remove tiles that were never loaded */
|
||||
for (int i = 0; i < mTilesEnd; i++) {
|
||||
MapTile t = tiles[i];
|
||||
if (t == null)
|
||||
@ -516,7 +516,7 @@ public class TileManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* make sure tile cannot be used by GL or MapWorker Thread */
|
||||
/* make sure tile cannot be used by GL or MapWorker Thread */
|
||||
if (t.state(NONE) && removeFromCache(t)) {
|
||||
tiles[i] = null;
|
||||
remove--;
|
||||
@ -529,16 +529,16 @@ public class TileManager {
|
||||
updateDistances(tiles, mTilesEnd, pos);
|
||||
TileDistanceSort.sort(tiles, 0, mTilesEnd);
|
||||
|
||||
/* sorting also repacks the 'sparse' filled array
|
||||
* so end of mTiles is at mTilesCount now */
|
||||
/* sorting also repacks the 'sparse' filled array
|
||||
* so end of mTiles is at mTilesCount now */
|
||||
mTilesEnd = mTilesCount;
|
||||
|
||||
/* start with farest away tile */
|
||||
/* start with farest away tile */
|
||||
for (int i = mTilesCount - 1; i >= 0 && remove > 0; i--) {
|
||||
MapTile t = tiles[i];
|
||||
|
||||
/* dont remove tile used by TileRenderer, or somewhere else
|
||||
* try again in next run. */
|
||||
/* dont remove tile used by TileRenderer, or somewhere else
|
||||
* try again in next run. */
|
||||
if (t.isLocked()) {
|
||||
if (dbg)
|
||||
log.debug("{} locked (state={}, d={})",
|
||||
@ -550,7 +550,7 @@ public class TileManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* cancel loading of tiles that should not even be cached */
|
||||
/* cancel loading of tiles that should not even be cached */
|
||||
if (t.state(LOADING)) {
|
||||
t.setState(CANCEL);
|
||||
if (dbg)
|
||||
@ -558,7 +558,7 @@ public class TileManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* clear new and unused tile */
|
||||
/* clear new and unused tile */
|
||||
if (t.state(NEW_DATA)) {
|
||||
newTileCnt--;
|
||||
if (dbg)
|
||||
@ -596,11 +596,11 @@ public class TileManager {
|
||||
*/
|
||||
public void jobCompleted(MapTile tile, QueryResult result) {
|
||||
|
||||
/* send TILE_LOADED event on main-loop */
|
||||
/* send TILE_LOADED event on main-loop */
|
||||
mMap.post(new JobCompletedEvent(tile, result));
|
||||
|
||||
/* locked means the tile is visible or referenced by
|
||||
* a tile that might be visible. */
|
||||
/* locked means the tile is visible or referenced by
|
||||
* a tile that might be visible. */
|
||||
if (tile.isLocked()) {
|
||||
if (result == QueryResult.DELAYED && tile.isLocked())
|
||||
mMap.updateMap(false);
|
||||
@ -631,7 +631,7 @@ public class TileManager {
|
||||
tile, result,
|
||||
tile.state());
|
||||
|
||||
/* got orphaned tile */
|
||||
/* got orphaned tile */
|
||||
if (tile.state(DEADBEEF)) {
|
||||
tile.clear();
|
||||
return;
|
||||
@ -642,7 +642,7 @@ public class TileManager {
|
||||
}
|
||||
|
||||
private static void updateDistances(MapTile[] tiles, int size, MapPosition pos) {
|
||||
/* TODO there is probably a better quad-tree distance function */
|
||||
/* TODO there is probably a better quad-tree distance function */
|
||||
int zoom = 20;
|
||||
long x = (long) (pos.x * (1 << zoom));
|
||||
long y = (long) (pos.y * (1 << zoom));
|
||||
@ -696,7 +696,7 @@ public class TileManager {
|
||||
int xx = x;
|
||||
|
||||
if (x < 0 || x >= xmax) {
|
||||
/* flip-around date line */
|
||||
/* flip-around date line */
|
||||
if (x < 0)
|
||||
xx = xmax + x;
|
||||
else
|
||||
@ -706,7 +706,7 @@ public class TileManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check if tile is already added */
|
||||
/* check if tile is already added */
|
||||
for (int i = 0; i < cnt; i++)
|
||||
if (tiles[i].tileX == xx && tiles[i].tileY == y) {
|
||||
tile = tiles[i];
|
||||
|
@ -88,11 +88,11 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
/* keep constant while rendering frame */
|
||||
/* keep constant while rendering frame */
|
||||
mLayerAlpha = mAlpha;
|
||||
mOverdrawColor = mOverdraw;
|
||||
|
||||
/* get current tiles to draw */
|
||||
/* get current tiles to draw */
|
||||
synchronized (tilelock) {
|
||||
boolean tilesChanged = mTileManager.getActiveTiles(mDrawTiles);
|
||||
|
||||
@ -102,10 +102,10 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
/* update isVisible flag true for tiles that intersect view */
|
||||
/* update isVisible flag true for tiles that intersect view */
|
||||
if (tilesChanged || v.changed()) {
|
||||
|
||||
/* lock tiles while updating isVisible state */
|
||||
/* lock tiles while updating isVisible state */
|
||||
mProxyTileCnt = 0;
|
||||
|
||||
MapTile[] tiles = mDrawTiles.tiles;
|
||||
@ -114,7 +114,7 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
for (int i = 0; i < mDrawTiles.cnt; i++)
|
||||
tiles[i].isVisible = false;
|
||||
|
||||
/* check visibile tiles */
|
||||
/* check visibile tiles */
|
||||
mScanBox.scan(v.pos.x, v.pos.y, v.pos.scale, tileZoom, v.plane);
|
||||
}
|
||||
}
|
||||
@ -128,8 +128,8 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
|
||||
public void clearTiles() {
|
||||
synchronized (tilelock) {
|
||||
/* Clear all references to MapTiles as all current
|
||||
* tiles will also be removed from TileManager. */
|
||||
/* Clear all references to MapTiles as all current
|
||||
* tiles will also be removed from TileManager. */
|
||||
mDrawTiles.releaseTiles();
|
||||
mDrawTiles.tiles = new MapTile[1];
|
||||
mDrawTiles.cnt = 0;
|
||||
@ -156,7 +156,7 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* load tile that is referenced by this holder */
|
||||
/* load tile that is referenced by this holder */
|
||||
MapTile proxy = tile.holder;
|
||||
if (proxy != null && proxy.state(NEW_DATA)) {
|
||||
uploadCnt += uploadTileData(proxy);
|
||||
@ -164,11 +164,11 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* check near relatives than can serve as proxy */
|
||||
/* check near relatives than can serve as proxy */
|
||||
proxy = tile.getProxy(PROXY_PARENT, NEW_DATA);
|
||||
if (proxy != null) {
|
||||
uploadCnt += uploadTileData(proxy);
|
||||
/* dont load child proxies */
|
||||
/* dont load child proxies */
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -188,7 +188,7 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
tile.setState(READY);
|
||||
RenderBuckets buckets = tile.getBuckets();
|
||||
|
||||
/* tile might only contain label layers */
|
||||
/* tile might only contain label layers */
|
||||
if (buckets == null)
|
||||
return 0;
|
||||
|
||||
@ -217,18 +217,18 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
|
||||
int prevSerial = tileSet.serial;
|
||||
|
||||
/* ensure tiles keep visible state */
|
||||
/* ensure tiles keep visible state */
|
||||
synchronized (tilelock) {
|
||||
|
||||
MapTile[] newTiles = mDrawTiles.tiles;
|
||||
int cnt = mDrawTiles.cnt;
|
||||
|
||||
/* ensure same size */
|
||||
/* ensure same size */
|
||||
if (tileSet.tiles.length != newTiles.length) {
|
||||
tileSet.tiles = new MapTile[newTiles.length];
|
||||
}
|
||||
|
||||
/* lock tiles to not be removed from cache */
|
||||
/* lock tiles to not be removed from cache */
|
||||
tileSet.cnt = 0;
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
MapTile t = newTiles[i];
|
||||
@ -236,7 +236,7 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
t.lock();
|
||||
}
|
||||
|
||||
/* unlock previous tiles */
|
||||
/* unlock previous tiles */
|
||||
tileSet.releaseTiles();
|
||||
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
@ -271,8 +271,8 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
t.isVisible = true;
|
||||
}
|
||||
|
||||
/* add placeholder tiles to show both sides
|
||||
* of date line. a little too complicated... */
|
||||
/* add placeholder tiles to show both sides
|
||||
* of date line. a little too complicated... */
|
||||
int xmax = 1 << mZoom;
|
||||
if (x1 >= 0 && x2 < xmax)
|
||||
return;
|
||||
@ -326,7 +326,7 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
public static long getMinFade(MapTile tile, int proxyLevel) {
|
||||
long minFade = MapRenderer.frametime - 50;
|
||||
|
||||
/* check children for grandparent, parent or current */
|
||||
/* check children for grandparent, parent or current */
|
||||
if (proxyLevel <= 0) {
|
||||
for (int c = 0; c < 4; c++) {
|
||||
MapTile ci = tile.node.child(c);
|
||||
@ -336,9 +336,9 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
if (ci.fadeTime > 0 && ci.fadeTime < minFade)
|
||||
minFade = ci.fadeTime;
|
||||
|
||||
/* when drawing the parent of the current level
|
||||
* we also check if the children of current level
|
||||
* are visible */
|
||||
/* when drawing the parent of the current level
|
||||
* we also check if the children of current level
|
||||
* are visible */
|
||||
if (proxyLevel >= -1) {
|
||||
long m = getMinFade(ci, proxyLevel - 1);
|
||||
if (m < minFade)
|
||||
@ -347,7 +347,7 @@ public abstract class TileRenderer extends LayerRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
/* check parents for child, current or parent */
|
||||
/* check parents for child, current or parent */
|
||||
TileNode p = tile.node.parent;
|
||||
|
||||
for (int i = proxyLevel; i >= -1; i--) {
|
||||
|
@ -81,7 +81,7 @@ public final class TileSet {
|
||||
/* lock tiles (and their proxies) to not be removed from cache */
|
||||
source.lockTiles();
|
||||
|
||||
/* unlock previous tiles */
|
||||
/* unlock previous tiles */
|
||||
releaseTiles();
|
||||
|
||||
if (source.tiles.length != tiles.length) {
|
||||
|
@ -47,7 +47,7 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
@Override
|
||||
public synchronized void render(GLViewport v) {
|
||||
|
||||
/* discard depth projection from tilt, depth buffer
|
||||
/* discard depth projection from tilt, depth buffer
|
||||
* is used for clipping */
|
||||
mClipProj.copy(v.proj);
|
||||
mClipProj.setValue(10, 0);
|
||||
@ -71,9 +71,9 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
gl.depthMask(true);
|
||||
gl.clear(GL.DEPTH_BUFFER_BIT);
|
||||
|
||||
/* always write depth for non-proxy tiles
|
||||
/* always write depth for non-proxy tiles
|
||||
* this is used in drawProxies pass to not
|
||||
* draw where tiles were already drawn */
|
||||
* draw where tiles were already drawn */
|
||||
gl.depthFunc(GL.ALWAYS);
|
||||
|
||||
mClipMode = PolygonBucket.CLIP_DEPTH;
|
||||
@ -83,24 +83,24 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
/* draw visible tiles */
|
||||
/* draw visible tiles */
|
||||
for (int i = 0; i < tileCnt; i++) {
|
||||
MapTile t = tiles[i];
|
||||
if (t.isVisible && t.state(READY))
|
||||
drawTile(t, v, 0);
|
||||
}
|
||||
|
||||
/* draw parent or children as proxy for visibile tiles that dont
|
||||
* have data yet. Proxies are clipped to the region where nothing
|
||||
* was drawn to depth buffer.
|
||||
* TODO draw proxies for placeholder */
|
||||
/* draw parent or children as proxy for visibile tiles that dont
|
||||
* have data yet. Proxies are clipped to the region where nothing
|
||||
* was drawn to depth buffer.
|
||||
* TODO draw proxies for placeholder */
|
||||
if (!drawProxies)
|
||||
return;
|
||||
|
||||
/* only draw where no other tile is drawn */
|
||||
/* only draw where no other tile is drawn */
|
||||
gl.depthFunc(GL.LESS);
|
||||
|
||||
/* draw child or parent proxies */
|
||||
/* draw child or parent proxies */
|
||||
boolean preferParent = (v.pos.getZoomScale() < 1.5)
|
||||
|| (v.pos.zoomLevel < tiles[0].zoomLevel);
|
||||
|
||||
@ -127,7 +127,7 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
/* draw grandparents */
|
||||
/* draw grandparents */
|
||||
for (int i = 0; i < tileCnt; i++) {
|
||||
MapTile t = tiles[i];
|
||||
if ((!t.isVisible) || (t.lastDraw == mDrawSerial))
|
||||
@ -137,19 +137,19 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
|
||||
gl.depthMask(false);
|
||||
|
||||
/* make sure stencil buffer write is disabled */
|
||||
/* make sure stencil buffer write is disabled */
|
||||
//GL.stencilMask(0x00);
|
||||
}
|
||||
|
||||
private void drawTile(MapTile tile, GLViewport v, int proxyLevel) {
|
||||
|
||||
/* ensure to draw parents only once */
|
||||
/* ensure to draw parents only once */
|
||||
if (tile.lastDraw == mDrawSerial)
|
||||
return;
|
||||
|
||||
tile.lastDraw = mDrawSerial;
|
||||
|
||||
/* use holder proxy when it is set */
|
||||
/* use holder proxy when it is set */
|
||||
RenderBuckets buckets = (tile.holder == null)
|
||||
? tile.getBuckets()
|
||||
: tile.holder.getBuckets();
|
||||
@ -160,14 +160,14 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
}
|
||||
|
||||
MapPosition pos = v.pos;
|
||||
/* place tile relative to map position */
|
||||
/* place tile relative to map position */
|
||||
int z = tile.zoomLevel;
|
||||
float div = FastMath.pow(z - pos.zoomLevel);
|
||||
double tileScale = Tile.SIZE * pos.scale;
|
||||
float x = (float) ((tile.x - pos.x) * tileScale);
|
||||
float y = (float) ((tile.y - pos.y) * tileScale);
|
||||
|
||||
/* scale relative to zoom-level of this tile */
|
||||
/* scale relative to zoom-level of this tile */
|
||||
float scale = (float) (pos.scale / (1 << z));
|
||||
|
||||
v.mvp.setTransScale(x, y, scale / COORD_SCALE);
|
||||
@ -186,7 +186,7 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
case POLYGON:
|
||||
b = PolygonBucket.Renderer.draw(b, v, div, first);
|
||||
first = false;
|
||||
/* set test for clip to tile region */
|
||||
/* set test for clip to tile region */
|
||||
gl.stencilFunc(GL.EQUAL, 0x80, 0x80);
|
||||
break;
|
||||
case LINE:
|
||||
@ -205,13 +205,13 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
b = BitmapBucket.Renderer.draw(b, v, 1, mLayerAlpha);
|
||||
break;
|
||||
default:
|
||||
/* just in case */
|
||||
/* just in case */
|
||||
log.error("unknown layer {}", b.type);
|
||||
b = b.next;
|
||||
break;
|
||||
}
|
||||
|
||||
/* make sure buffers are bound again */
|
||||
/* make sure buffers are bound again */
|
||||
buckets.bind();
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
if (tile.holder == null) {
|
||||
fadeTime = getMinFade(tile, proxyLevel);
|
||||
} else {
|
||||
/* need to use time from original tile */
|
||||
/* need to use time from original tile */
|
||||
fadeTime = tile.holder.fadeTime;
|
||||
if (fadeTime == 0)
|
||||
fadeTime = getMinFade(tile.holder, proxyLevel);
|
||||
|
@ -117,30 +117,30 @@ public class BitmapTileLayer extends TileLayer {
|
||||
*/
|
||||
final TexturePool pool = new TexturePool(POOL_FILL) {
|
||||
|
||||
// int sum = 0;
|
||||
// int sum = 0;
|
||||
//
|
||||
// public TextureItem release(TextureItem item) {
|
||||
// log.debug(getFill() + " " + sum + " release tex " + item.id);
|
||||
// return super.release(item);
|
||||
// };
|
||||
// public TextureItem release(TextureItem item) {
|
||||
// log.debug(getFill() + " " + sum + " release tex " + item.id);
|
||||
// return super.release(item);
|
||||
// };
|
||||
//
|
||||
// public synchronized TextureItem get() {
|
||||
// log.debug(getFill() + " " + sum + " get tex ");
|
||||
// public synchronized TextureItem get() {
|
||||
// log.debug(getFill() + " " + sum + " get tex ");
|
||||
//
|
||||
// return super.get();
|
||||
// };
|
||||
// return super.get();
|
||||
// };
|
||||
//
|
||||
// protected TextureItem createItem() {
|
||||
// log.debug(getFill() + " " + (sum++) + " create tex ");
|
||||
// protected TextureItem createItem() {
|
||||
// log.debug(getFill() + " " + (sum++) + " create tex ");
|
||||
//
|
||||
// return super.createItem();
|
||||
// };
|
||||
// return super.createItem();
|
||||
// };
|
||||
//
|
||||
// protected void freeItem(TextureItem t) {
|
||||
// log.debug(getFill() + " " + (sum--) + " free tex ");
|
||||
// super.freeItem(t);
|
||||
// protected void freeItem(TextureItem t) {
|
||||
// log.debug(getFill() + " " + (sum--) + " free tex ");
|
||||
// super.freeItem(t);
|
||||
//
|
||||
// };
|
||||
// };
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
|
||||
if (v != null)
|
||||
minHeight = Integer.parseInt(v);
|
||||
|
||||
/* 12m default */
|
||||
/* 12m default */
|
||||
if (height == 0)
|
||||
height = 12 * 100;
|
||||
|
||||
@ -130,27 +130,27 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
|
||||
get(tile).setBuckets(null);
|
||||
}
|
||||
|
||||
// private int multi;
|
||||
// @Override
|
||||
// public void onInputEvent(Event event, MotionEvent e) {
|
||||
// int action = e.getAction() & MotionEvent.ACTION_MASK;
|
||||
// if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||
// multi++;
|
||||
// } else if (action == MotionEvent.ACTION_POINTER_UP) {
|
||||
// multi--;
|
||||
// if (!mActive && mAlpha > 0) {
|
||||
// // finish hiding
|
||||
// //log.debug("add multi hide timer " + mAlpha);
|
||||
// addShowTimer(mFadeTime * mAlpha, false);
|
||||
// }
|
||||
// } else if (action == MotionEvent.ACTION_CANCEL) {
|
||||
// multi = 0;
|
||||
// log.debug("cancel " + multi);
|
||||
// if (mTimer != null) {
|
||||
// mTimer.cancel();
|
||||
// mTimer = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private int multi;
|
||||
// @Override
|
||||
// public void onInputEvent(Event event, MotionEvent e) {
|
||||
// int action = e.getAction() & MotionEvent.ACTION_MASK;
|
||||
// if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||
// multi++;
|
||||
// } else if (action == MotionEvent.ACTION_POINTER_UP) {
|
||||
// multi--;
|
||||
// if (!mActive && mAlpha > 0) {
|
||||
// // finish hiding
|
||||
// //log.debug("add multi hide timer " + mAlpha);
|
||||
// addShowTimer(mFadeTime * mAlpha, false);
|
||||
// }
|
||||
// } else if (action == MotionEvent.ACTION_CANCEL) {
|
||||
// multi = 0;
|
||||
// log.debug("cancel " + multi);
|
||||
// if (mTimer != null) {
|
||||
// mTimer.cancel();
|
||||
// mTimer = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class BuildingRenderer extends ExtrusionRenderer {
|
||||
|
||||
int diff = (v.pos.zoomLevel - mZoomMin);
|
||||
|
||||
/* if below min zoom or already faded out */
|
||||
/* if below min zoom or already faded out */
|
||||
if (diff < -1) {
|
||||
mAlpha = 0;
|
||||
mShow = false;
|
||||
@ -100,12 +100,12 @@ public class BuildingRenderer extends ExtrusionRenderer {
|
||||
MapTile[] tiles = mTileSet.tiles;
|
||||
TileDistanceSort.sort(tiles, 0, mTileSet.cnt);
|
||||
|
||||
/* keep a list of tiles available for rendering */
|
||||
/* keep a list of tiles available for rendering */
|
||||
int maxTiles = mTileSet.cnt * 4;
|
||||
if (mExtrusionBucketSet.length < maxTiles)
|
||||
mExtrusionBucketSet = new ExtrusionBuckets[maxTiles];
|
||||
|
||||
/* compile one tile max per frame */
|
||||
/* compile one tile max per frame */
|
||||
boolean compiled = false;
|
||||
|
||||
int activeTiles = 0;
|
||||
@ -134,9 +134,9 @@ public class BuildingRenderer extends ExtrusionRenderer {
|
||||
if (t == null)
|
||||
continue;
|
||||
|
||||
// for (MapTile c : mTiles)
|
||||
// if (c == t)
|
||||
// continue O;
|
||||
// for (MapTile c : mTiles)
|
||||
// if (c == t)
|
||||
// continue O;
|
||||
|
||||
ExtrusionBuckets ebs = getBuckets(t);
|
||||
if (ebs == null)
|
||||
@ -151,7 +151,7 @@ public class BuildingRenderer extends ExtrusionRenderer {
|
||||
}
|
||||
}
|
||||
} else if (zoom == mZoomMin - 1) {
|
||||
/* check if proxy children are ready */
|
||||
/* check if proxy children are ready */
|
||||
for (int i = 0; i < mTileSet.cnt; i++) {
|
||||
MapTile t = tiles[i];
|
||||
for (byte j = 0; j < 4; j++) {
|
||||
@ -169,7 +169,7 @@ public class BuildingRenderer extends ExtrusionRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
/* load more tiles on next frame */
|
||||
/* load more tiles on next frame */
|
||||
if (compiled)
|
||||
MapRenderer.animate();
|
||||
|
||||
@ -189,7 +189,7 @@ public class BuildingRenderer extends ExtrusionRenderer {
|
||||
public void render(GLViewport v) {
|
||||
super.render(v);
|
||||
|
||||
/* release lock on tile data */
|
||||
/* release lock on tile data */
|
||||
mTileRenderer.releaseTiles(mTileSet);
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ class S3DBTileLoader extends TileLoader {
|
||||
|
||||
boolean isRoof = element.tags.containsKey(ROOF_KEY);
|
||||
//if (isRoof)
|
||||
// log.debug(element.tags.toString());
|
||||
// log.debug(element.tags.toString());
|
||||
|
||||
int c = 0;
|
||||
if (element.tags.containsKey(COLOR_KEY)) {
|
||||
|
@ -108,13 +108,13 @@ public class VectorTileLayer extends TileLayer {
|
||||
public void setRenderTheme(IRenderTheme theme) {
|
||||
/* wait for loaders to finish all current jobs to
|
||||
* not change theme instance hold by loader instance
|
||||
* while running */
|
||||
* while running */
|
||||
pauseLoaders(true);
|
||||
mTileManager.clearJobs();
|
||||
|
||||
mTheme = theme;
|
||||
// for (TileLoader l : mTileLoader)
|
||||
// ((VectorTileLoader) l).setRenderTheme(theme);
|
||||
// for (TileLoader l : mTileLoader)
|
||||
// ((VectorTileLoader) l).setRenderTheme(theme);
|
||||
|
||||
tileRenderer().setOverdrawColor(theme.getMapBackground());
|
||||
|
||||
@ -203,8 +203,8 @@ public class VectorTileLayer extends TileLayer {
|
||||
}
|
||||
|
||||
public void callHooksComplete(MapTile tile, boolean success) {
|
||||
/* NB: cannot use internal iterater as this function
|
||||
* is called concurently by TileLoaders */
|
||||
/* NB: cannot use internal iterater as this function
|
||||
* is called concurently by TileLoaders */
|
||||
|
||||
LList<TileLoaderThemeHook> th = mLoaderThemeHooks.head();
|
||||
while (th != null) {
|
||||
|
@ -119,13 +119,13 @@ public class VectorTileLoader extends TileLoader implements RenderStyle.Callback
|
||||
|
||||
//mTileLayer.getLoaderHooks();
|
||||
|
||||
/* account for area changes with latitude */
|
||||
/* account for area changes with latitude */
|
||||
double lat = MercatorProjection.toLatitude(tile.y);
|
||||
mLineScale = (float) Math.pow(STROKE_INCREASE, tile.zoomLevel - STROKE_MIN_ZOOM);
|
||||
if (mLineScale < 1)
|
||||
mLineScale = 1;
|
||||
|
||||
/* scale line width relative to latitude + PI * thumb */
|
||||
/* scale line width relative to latitude + PI * thumb */
|
||||
mLineScale *= 0.4f + 0.6f * ((float) Math.sin(Math.abs(lat) * (Math.PI / 180)));
|
||||
mBuckets = new RenderBuckets();
|
||||
tile.data = mBuckets;
|
||||
@ -150,7 +150,7 @@ public class VectorTileLoader extends TileLoader implements RenderStyle.Callback
|
||||
|
||||
mTileLayer.callHooksComplete(mTile, ok);
|
||||
|
||||
/* finish buckets- tessellate and cleanup on worker-thread */
|
||||
/* finish buckets- tessellate and cleanup on worker-thread */
|
||||
mBuckets.prepare();
|
||||
clearState();
|
||||
|
||||
@ -205,7 +205,7 @@ public class VectorTileLoader extends TileLoader implements RenderStyle.Callback
|
||||
|
||||
mElement = element;
|
||||
|
||||
/* get and apply render instructions */
|
||||
/* get and apply render instructions */
|
||||
if (element.type == GeometryType.POINT) {
|
||||
renderNode(renderTheme.matchElement(element.type, tags, mTile.zoomLevel));
|
||||
} else {
|
||||
@ -265,7 +265,7 @@ public class VectorTileLoader extends TileLoader implements RenderStyle.Callback
|
||||
|
||||
lb.addLine(mElement);
|
||||
|
||||
/* keep reference for outline layer(s) */
|
||||
/* keep reference for outline layer(s) */
|
||||
mCurLineBucket = lb;
|
||||
|
||||
} else {
|
||||
|
@ -79,18 +79,18 @@ class Debug {
|
||||
}
|
||||
|
||||
public static void draw(MapPosition pos, GLViewport m, RenderBuckets layers) {
|
||||
// if (layers.baseLayers != null) {
|
||||
// //setMatrix(pos, m, true);
|
||||
// if (layers.baseLayers != null) {
|
||||
// //setMatrix(pos, m, true);
|
||||
//
|
||||
// for (RenderElement l = layers.baseLayers; l != null;) {
|
||||
// if (l.type == RenderElement.POLYGON) {
|
||||
// l = PolygonLayer.Renderer.draw(pos, l, m, true, 1, false);
|
||||
// } else {
|
||||
// //float div = (float) (mMapPosition.scale / (1 << pos.zoomLevel));
|
||||
// l = LineLayer.Renderer.draw(layers, l, pos, m, div);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (RenderElement l = layers.baseLayers; l != null;) {
|
||||
// if (l.type == RenderElement.POLYGON) {
|
||||
// l = PolygonLayer.Renderer.draw(pos, l, m, true, 1, false);
|
||||
// } else {
|
||||
// //float div = (float) (mMapPosition.scale / (1 << pos.zoomLevel));
|
||||
// l = LineLayer.Renderer.draw(layers, l, pos, m, div);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,22 +103,22 @@ public class LabelLayer extends Layer implements Map.UpdateListener, TileManager
|
||||
mWorker.submit(MAX_RELABEL_DELAY);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onMotionEvent(MotionEvent e) {
|
||||
// // int action = e.getAction() & MotionEvent.ACTION_MASK;
|
||||
// // if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||
// // multi++;
|
||||
// // mTextRenderer.hold(true);
|
||||
// // } else if (action == MotionEvent.ACTION_POINTER_UP) {
|
||||
// // multi--;
|
||||
// // if (multi == 0)
|
||||
// // mTextRenderer.hold(false);
|
||||
// // } else if (action == MotionEvent.ACTION_CANCEL) {
|
||||
// // multi = 0;
|
||||
// // log.debug("cancel " + multi);
|
||||
// // mTextRenderer.hold(false);
|
||||
// // }
|
||||
// }
|
||||
// @Override
|
||||
// public void onMotionEvent(MotionEvent e) {
|
||||
// // int action = e.getAction() & MotionEvent.ACTION_MASK;
|
||||
// // if (action == MotionEvent.ACTION_POINTER_DOWN) {
|
||||
// // multi++;
|
||||
// // mTextRenderer.hold(true);
|
||||
// // } else if (action == MotionEvent.ACTION_POINTER_UP) {
|
||||
// // multi--;
|
||||
// // if (multi == 0)
|
||||
// // mTextRenderer.hold(false);
|
||||
// // } else if (action == MotionEvent.ACTION_CANCEL) {
|
||||
// // multi = 0;
|
||||
// // log.debug("cancel " + multi);
|
||||
// // mTextRenderer.hold(false);
|
||||
// // }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onTileManagerEvent(Event e, MapTile tile) {
|
||||
|
@ -177,11 +177,11 @@ public class LabelPlacement {
|
||||
if (ti.text.caption)
|
||||
continue;
|
||||
|
||||
/* acquire a TextItem to add to TextLayer */
|
||||
/* acquire a TextItem to add to TextLayer */
|
||||
if (l == null)
|
||||
l = getLabel();
|
||||
|
||||
/* check if path at current scale is long enough */
|
||||
/* check if path at current scale is long enough */
|
||||
if (!dbg && ti.width > ti.length * scale)
|
||||
continue;
|
||||
|
||||
@ -277,7 +277,7 @@ public class LabelPlacement {
|
||||
|
||||
boolean updateLabels(LabelTask work) {
|
||||
|
||||
/* get current tiles */
|
||||
/* get current tiles */
|
||||
boolean changedTiles = mTileRenderer.getVisibleTiles(mTileSet);
|
||||
|
||||
if (mTileSet.cnt == 0) {
|
||||
@ -287,7 +287,7 @@ public class LabelPlacement {
|
||||
MapPosition pos = work.pos;
|
||||
boolean changedPos = mMap.viewport().getMapPosition(pos);
|
||||
|
||||
/* do not loop! */
|
||||
/* do not loop! */
|
||||
if (!changedTiles && !changedPos)
|
||||
return false;
|
||||
|
||||
@ -296,12 +296,12 @@ public class LabelPlacement {
|
||||
MapTile[] tiles = mTileSet.tiles;
|
||||
int zoom = tiles[0].zoomLevel;
|
||||
|
||||
/* estimation for visible area to be labeled */
|
||||
/* estimation for visible area to be labeled */
|
||||
int mw = (mMap.getWidth() + Tile.SIZE) / 2;
|
||||
int mh = (mMap.getHeight() + Tile.SIZE) / 2;
|
||||
mSquareRadius = mw * mw + mh * mh;
|
||||
|
||||
/* scale of tiles zoom-level relative to current position */
|
||||
/* scale of tiles zoom-level relative to current position */
|
||||
double scale = pos.scale / (1 << zoom);
|
||||
|
||||
double angle = Math.toRadians(pos.bearing);
|
||||
@ -317,14 +317,14 @@ public class LabelPlacement {
|
||||
double tileX = (pos.x * (Tile.SIZE << zoom));
|
||||
double tileY = (pos.y * (Tile.SIZE << zoom));
|
||||
|
||||
/* put current label to previous label */
|
||||
/* put current label to previous label */
|
||||
Label prevLabels = mLabels;
|
||||
|
||||
/* new labels */
|
||||
/* new labels */
|
||||
mLabels = null;
|
||||
Label l = null;
|
||||
|
||||
/* add currently active labels first */
|
||||
/* add currently active labels first */
|
||||
for (l = prevLabels; l != null; ) {
|
||||
|
||||
if (l.text.caption) {
|
||||
@ -381,7 +381,7 @@ public class LabelPlacement {
|
||||
l = mPool.releaseAndGetNext(l);
|
||||
}
|
||||
|
||||
/* add way labels */
|
||||
/* add way labels */
|
||||
for (int i = 0, n = mTileSet.cnt; i < n; i++) {
|
||||
MapTile t = tiles[i];
|
||||
if (!t.state(READY | NEW_DATA))
|
||||
@ -394,7 +394,7 @@ public class LabelPlacement {
|
||||
l = addWayLabels(t, l, dx, dy, scale);
|
||||
}
|
||||
|
||||
/* add caption */
|
||||
/* add caption */
|
||||
for (int i = 0, n = mTileSet.cnt; i < n; i++) {
|
||||
MapTile t = tiles[i];
|
||||
if (!t.state(READY | NEW_DATA))
|
||||
@ -421,7 +421,7 @@ public class LabelPlacement {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* flip way label orientation */
|
||||
/* flip way label orientation */
|
||||
if (cos * (ti.x2 - ti.x1) - sin * (ti.y2 - ti.y1) < 0) {
|
||||
float tmp = ti.x1;
|
||||
ti.x1 = ti.x2;
|
||||
@ -433,7 +433,7 @@ public class LabelPlacement {
|
||||
}
|
||||
}
|
||||
|
||||
/* add symbol items */
|
||||
/* add symbol items */
|
||||
for (int i = 0, n = mTileSet.cnt; i < n; i++) {
|
||||
MapTile t = tiles[i];
|
||||
if (!t.state(READY | NEW_DATA))
|
||||
@ -466,15 +466,15 @@ public class LabelPlacement {
|
||||
}
|
||||
}
|
||||
|
||||
/* temporary used Label */
|
||||
/* temporary used Label */
|
||||
l = (Label) mPool.release(l);
|
||||
|
||||
/* draw text to bitmaps and create vertices */
|
||||
/* draw text to bitmaps and create vertices */
|
||||
work.textLayer.labels = groupLabels(mLabels);
|
||||
work.textLayer.prepare();
|
||||
work.textLayer.labels = null;
|
||||
|
||||
/* remove tile locks */
|
||||
/* remove tile locks */
|
||||
mTileRenderer.releaseTiles(mTileSet);
|
||||
|
||||
return true;
|
||||
@ -495,7 +495,7 @@ public class LabelPlacement {
|
||||
TextStyle t = cur.text;
|
||||
float w = cur.width;
|
||||
|
||||
/* iterate through following */
|
||||
/* iterate through following */
|
||||
for (Label l = (Label) cur.next; l != null; l = (Label) l.next) {
|
||||
|
||||
if (w != l.width || t != l.text || !cur.string.equals(l.string)) {
|
||||
@ -508,18 +508,18 @@ public class LabelPlacement {
|
||||
}
|
||||
l.string = cur.string;
|
||||
|
||||
/* insert l after cur */
|
||||
/* insert l after cur */
|
||||
Label tmp = (Label) cur.next;
|
||||
cur.next = l;
|
||||
|
||||
/* continue outer loop at l */
|
||||
/* continue outer loop at l */
|
||||
cur = l;
|
||||
|
||||
/* remove l from previous place */
|
||||
/* remove l from previous place */
|
||||
p.next = l.next;
|
||||
l.next = tmp;
|
||||
|
||||
/* continue from previous */
|
||||
/* continue from previous */
|
||||
l = p;
|
||||
}
|
||||
}
|
||||
|
@ -52,32 +52,32 @@ public final class WayDecorator {
|
||||
|
||||
//int clip;
|
||||
//if ((clip = clipper.clipNext(curX, curY)) != 0) {
|
||||
// if (clip < 0) {
|
||||
// prevX = clipper.out[0];
|
||||
// prevY = clipper.out[1];
|
||||
// curX = clipper.out[2];
|
||||
// curY = clipper.out[3];
|
||||
// if (clip < 0) {
|
||||
// prevX = clipper.out[0];
|
||||
// prevY = clipper.out[1];
|
||||
// curX = clipper.out[2];
|
||||
// curY = clipper.out[3];
|
||||
//
|
||||
// if (prevX == min)
|
||||
// edge |= 1 << 0;
|
||||
// else if (prevX == max)
|
||||
// edge |= 1 << 1;
|
||||
// if (prevX == min)
|
||||
// edge |= 1 << 0;
|
||||
// else if (prevX == max)
|
||||
// edge |= 1 << 1;
|
||||
//
|
||||
// if (prevY == min)
|
||||
// edge |= 1 << 2;
|
||||
// else if (prevY == max)
|
||||
// edge |= 1 << 3;
|
||||
// if (prevY == min)
|
||||
// edge |= 1 << 2;
|
||||
// else if (prevY == max)
|
||||
// edge |= 1 << 3;
|
||||
//
|
||||
// if (curX == min)
|
||||
// edge |= 1 << 4;
|
||||
// else if (curX == max)
|
||||
// edge |= 1 << 5;
|
||||
// if (curX == min)
|
||||
// edge |= 1 << 4;
|
||||
// else if (curX == max)
|
||||
// edge |= 1 << 5;
|
||||
//
|
||||
// if (curY == min)
|
||||
// edge |= 1 << 5;
|
||||
// else if (curY == max)
|
||||
// edge |= 1 << 6;
|
||||
// }
|
||||
// if (curY == min)
|
||||
// edge |= 1 << 5;
|
||||
// else if (curY == max)
|
||||
// edge |= 1 << 6;
|
||||
// }
|
||||
//}
|
||||
|
||||
int last = i;
|
||||
@ -101,13 +101,13 @@ public final class WayDecorator {
|
||||
float nextY = coordinates[j + 1];
|
||||
|
||||
//if ((clip = clipper.clipNext(nextX, nextY)) != 0) {
|
||||
// if (clip < 0) {
|
||||
// curX = clipper.out[0];
|
||||
// curY = clipper.out[1];
|
||||
// // TODO break when cur has changed
|
||||
// nextX = clipper.out[2];
|
||||
// nextY = clipper.out[3];
|
||||
// }
|
||||
// if (clip < 0) {
|
||||
// curX = clipper.out[0];
|
||||
// curY = clipper.out[1];
|
||||
// // TODO break when cur has changed
|
||||
// nextX = clipper.out[2];
|
||||
// nextY = clipper.out[3];
|
||||
// }
|
||||
//}
|
||||
|
||||
float wx = nextX - curX;
|
||||
@ -146,15 +146,15 @@ public final class WayDecorator {
|
||||
last = j - 2;
|
||||
|
||||
//if (clip < 0) {
|
||||
// if (nextX == min)
|
||||
// edge |= 1 << 4;
|
||||
// else if (nextX == max)
|
||||
// edge |= 1 << 5;
|
||||
// if (nextX == min)
|
||||
// edge |= 1 << 4;
|
||||
// else if (nextX == max)
|
||||
// edge |= 1 << 5;
|
||||
//
|
||||
// if (nextY == min)
|
||||
// edge |= 1 << 6;
|
||||
// else if (nextY == max)
|
||||
// edge |= 1 << 7;
|
||||
// if (nextY == min)
|
||||
// edge |= 1 << 6;
|
||||
// else if (nextY == max)
|
||||
// edge |= 1 << 7;
|
||||
//}
|
||||
}
|
||||
|
||||
@ -198,8 +198,8 @@ public final class WayDecorator {
|
||||
|
||||
// link items together
|
||||
//if (t != null) {
|
||||
// t.n1 = n;
|
||||
// n.n2 = t;
|
||||
// t.n1 = n;
|
||||
// n.n2 = t;
|
||||
//}
|
||||
|
||||
t = n;
|
||||
|
@ -95,42 +95,42 @@ public abstract class AbstractVectorLayer<T> extends Layer implements UpdateList
|
||||
v.getMapPosition(t.position);
|
||||
}
|
||||
|
||||
/* Hmm what is this for? */
|
||||
// double scale = t.position.scale * Tile.SIZE;
|
||||
// t.position.x = (long) (t.position.x * scale) / scale;
|
||||
// t.position.y = (long) (t.position.y * scale) / scale;
|
||||
/* Hmm what is this for? */
|
||||
// double scale = t.position.scale * Tile.SIZE;
|
||||
// t.position.x = (long) (t.position.x * scale) / scale;
|
||||
// t.position.y = (long) (t.position.y * scale) / scale;
|
||||
|
||||
bbox.map2mercator();
|
||||
|
||||
// double xmin = bbox.xmin;
|
||||
// double xmax = bbox.xmax;
|
||||
// Box lbox = null;
|
||||
// Box rbox = null;
|
||||
// if (bbox.xmin < -180) {
|
||||
// bbox.xmin = -180;
|
||||
// lbox = new Box(bbox);
|
||||
// }
|
||||
// if (bbox.xmax > 180) {
|
||||
// bbox.xmax = 180;
|
||||
// rbox = new Box(bbox);
|
||||
// }
|
||||
// double xmin = bbox.xmin;
|
||||
// double xmax = bbox.xmax;
|
||||
// Box lbox = null;
|
||||
// Box rbox = null;
|
||||
// if (bbox.xmin < -180) {
|
||||
// bbox.xmin = -180;
|
||||
// lbox = new Box(bbox);
|
||||
// }
|
||||
// if (bbox.xmax > 180) {
|
||||
// bbox.xmax = 180;
|
||||
// rbox = new Box(bbox);
|
||||
// }
|
||||
|
||||
processFeatures(t, bbox);
|
||||
|
||||
//if (lbox != null) {
|
||||
// t.position.x += 1;
|
||||
// lbox.xmax = 180;
|
||||
// lbox.xmin = xmin + 180;
|
||||
// processFeatures(t, lbox);
|
||||
// t.position.x -= 1;
|
||||
// t.position.x += 1;
|
||||
// lbox.xmax = 180;
|
||||
// lbox.xmin = xmin + 180;
|
||||
// processFeatures(t, lbox);
|
||||
// t.position.x -= 1;
|
||||
//}
|
||||
//
|
||||
//if (rbox != null) {
|
||||
// t.position.x -= 1;
|
||||
// rbox.xmin = -180;
|
||||
// rbox.xmax = xmax - 180;
|
||||
// processFeatures(t, rbox);
|
||||
// t.position.x += 1;
|
||||
// t.position.x -= 1;
|
||||
// rbox.xmin = -180;
|
||||
// rbox.xmax = xmax - 180;
|
||||
// processFeatures(t, rbox);
|
||||
// t.position.x += 1;
|
||||
//}
|
||||
|
||||
t.buckets.prepare();
|
||||
|
@ -67,7 +67,7 @@ public class Animator {
|
||||
mMap.getMapPosition(mStartPos);
|
||||
/* TODO for large distance first scale out, then in
|
||||
* calculate the maximum scale at which the BoundingBox
|
||||
* is completely visible */
|
||||
* is completely visible */
|
||||
double dx = Math.abs(longitudeToX(bbox.getMaxLongitude())
|
||||
- longitudeToX(bbox.getMinLongitude()));
|
||||
|
||||
@ -211,8 +211,8 @@ public class Animator {
|
||||
|
||||
ViewController v = mMap.viewport();
|
||||
|
||||
/* cancel animation when position was changed since last
|
||||
* update, i.e. when it was modified outside the animator. */
|
||||
/* cancel animation when position was changed since last
|
||||
* update, i.e. when it was modified outside the animator. */
|
||||
if (v.getMapPosition(mCurPos)) {
|
||||
log.debug("cancel anim - changed");
|
||||
cancel();
|
||||
@ -255,7 +255,7 @@ public class Animator {
|
||||
cancel();
|
||||
}
|
||||
|
||||
/* remember current map position */
|
||||
/* remember current map position */
|
||||
final boolean changed = v.getMapPosition(mCurPos);
|
||||
|
||||
if (changed) {
|
||||
|
@ -37,13 +37,13 @@ public class ViewController extends Viewport {
|
||||
mHeight = height;
|
||||
mWidth = width;
|
||||
|
||||
/* setup projection matrix:
|
||||
/* setup projection matrix:
|
||||
* 0. scale to window coordinates
|
||||
* 1. translate to VIEW_DISTANCE
|
||||
* 2. apply projection
|
||||
* setup inverse projection:
|
||||
* 0. invert projection
|
||||
* 1. invert translate to VIEW_DISTANCE */
|
||||
* 1. translate to VIEW_DISTANCE
|
||||
* 2. apply projection
|
||||
* setup inverse projection:
|
||||
* 0. invert projection
|
||||
* 1. invert translate to VIEW_DISTANCE */
|
||||
|
||||
float ratio = (mHeight / mWidth) * VIEW_SCALE;
|
||||
|
||||
@ -55,14 +55,14 @@ public class ViewController extends Viewport {
|
||||
mTmpMatrix.setTranslation(0, 0, -VIEW_DISTANCE);
|
||||
mProjMatrix.multiplyRhs(mTmpMatrix);
|
||||
|
||||
/* set inverse projection matrix (without scaling) */
|
||||
/* set inverse projection matrix (without scaling) */
|
||||
mProjMatrix.get(mat);
|
||||
GLMatrix.invertM(mat, 0, mat, 0);
|
||||
mProjMatrixInverse.set(mat);
|
||||
|
||||
mProjMatrixUnscaled.copy(mProjMatrix);
|
||||
|
||||
/* scale to window coordinates */
|
||||
/* scale to window coordinates */
|
||||
mTmpMatrix.setScale(1 / mWidth, 1 / mWidth, 1 / mWidth);
|
||||
mProjMatrix.multiplyRhs(mTmpMatrix);
|
||||
|
||||
@ -97,16 +97,16 @@ public class ViewController extends Viewport {
|
||||
mPos.x = x;
|
||||
mPos.y = y;
|
||||
|
||||
/* clamp latitude */
|
||||
/* clamp latitude */
|
||||
mPos.y = FastMath.clamp(mPos.y, 0, 1);
|
||||
|
||||
/* wrap longitude */
|
||||
/* wrap longitude */
|
||||
while (mPos.x > 1)
|
||||
mPos.x -= 1;
|
||||
while (mPos.x < 0)
|
||||
mPos.x += 1;
|
||||
|
||||
/* limit longitude */
|
||||
/* limit longitude */
|
||||
if (mPos.x > mMaxX)
|
||||
mPos.x = mMaxX;
|
||||
else if (mPos.x < mMinX)
|
||||
@ -228,24 +228,24 @@ public class ViewController extends Viewport {
|
||||
mPos.copy(mapPosition);
|
||||
limitPosition(mPos);
|
||||
|
||||
// mPos.scale = clamp(mapPosition.scale, mMinScale, mMaxScale);
|
||||
// mPos.x = mapPosition.x;
|
||||
// mPos.y = mapPosition.y;
|
||||
// mPos.tilt = limitTilt(mapPosition.tilt);
|
||||
// mPos.bearing = mapPosition.bearing;
|
||||
// mPos.scale = clamp(mapPosition.scale, mMinScale, mMaxScale);
|
||||
// mPos.x = mapPosition.x;
|
||||
// mPos.y = mapPosition.y;
|
||||
// mPos.tilt = limitTilt(mapPosition.tilt);
|
||||
// mPos.bearing = mapPosition.bearing;
|
||||
|
||||
updateMatrices();
|
||||
}
|
||||
|
||||
private void updateMatrices() {
|
||||
/* - view matrix:
|
||||
* 0. apply rotate
|
||||
* 1. apply tilt */
|
||||
/* - view matrix:
|
||||
* 0. apply rotate
|
||||
* 1. apply tilt */
|
||||
|
||||
mRotationMatrix.setRotation(mPos.bearing, 0, 0, 1);
|
||||
mTmpMatrix.setRotation(mPos.tilt, 1, 0, 0);
|
||||
|
||||
/* apply first rotation, then tilt */
|
||||
/* apply first rotation, then tilt */
|
||||
mRotationMatrix.multiplyLhs(mTmpMatrix);
|
||||
|
||||
mViewMatrix.copy(mRotationMatrix);
|
||||
|
@ -195,9 +195,9 @@ public class Viewport {
|
||||
unproject(1, -1, box, 0);
|
||||
/* top-left */
|
||||
unproject(-1, -1, box, 2);
|
||||
/* bottom-left */
|
||||
/* bottom-left */
|
||||
unproject(-1, 1, box, 4);
|
||||
/* bottom-right */
|
||||
/* bottom-right */
|
||||
unproject(1, 1, box, 6);
|
||||
|
||||
if (add == 0)
|
||||
@ -290,7 +290,7 @@ public class Viewport {
|
||||
}
|
||||
|
||||
protected void unprojectScreen(double x, double y, float[] out) {
|
||||
/* scale to -1..1 */
|
||||
/* scale to -1..1 */
|
||||
float mx = (float) (1 - (x / mWidth * 2));
|
||||
float my = (float) (1 - (y / mHeight * 2));
|
||||
|
||||
|
@ -67,7 +67,7 @@ public final class BufferObject extends Inlist<BufferObject> {
|
||||
|
||||
GLState.bindBuffer(target, id);
|
||||
|
||||
/* reuse memory allocated for vbo when possible and allocated
|
||||
/* reuse memory allocated for vbo when possible and allocated
|
||||
* memory is less then four times the new data */
|
||||
if (!GLAdapter.NO_BUFFER_SUB_DATA && !clear &&
|
||||
(size > newSize) && (size < newSize * 4)) {
|
||||
@ -125,7 +125,7 @@ public final class BufferObject extends Inlist<BufferObject> {
|
||||
if (size != 0) {
|
||||
/* find the item with minimal size greater 'size' bytes. */
|
||||
BufferObject bo = pool[t];
|
||||
/* actually points to BufferObject before min */
|
||||
/* actually points to BufferObject before min */
|
||||
BufferObject min = null;
|
||||
BufferObject prev = null;
|
||||
|
||||
|
@ -78,12 +78,12 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
||||
|
||||
int sumIndices = eb.idx[0] + eb.idx[1] + eb.idx[2];
|
||||
|
||||
/* extrusion */
|
||||
/* extrusion */
|
||||
if (sumIndices > 0)
|
||||
gl.drawElements(GL.TRIANGLES, sumIndices,
|
||||
GL.UNSIGNED_SHORT, eb.off[0]);
|
||||
|
||||
/* mesh */
|
||||
/* mesh */
|
||||
if (eb.idx[4] > 0) {
|
||||
gl.drawElements(GL.TRIANGLES, eb.idx[4],
|
||||
GL.UNSIGNED_SHORT, eb.off[4]);
|
||||
@ -106,7 +106,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
||||
s.useProgram();
|
||||
GLState.enableVertexArrays(s.aPos, -1);
|
||||
|
||||
/* only use face-culling when it's unlikely
|
||||
/* only use face-culling when it's unlikely
|
||||
* that one'moves through the building' */
|
||||
if (v.pos.zoomLevel < 18)
|
||||
gl.enable(GL.CULL_FACE);
|
||||
@ -140,7 +140,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
||||
renderCombined(s.aPos, ebs[i]);
|
||||
}
|
||||
|
||||
/* only draw to color buffer */
|
||||
/* only draw to color buffer */
|
||||
gl.colorMask(true, true, true, true);
|
||||
gl.depthMask(false);
|
||||
gl.depthFunc(GL.EQUAL);
|
||||
@ -183,32 +183,32 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
||||
gl.vertexAttribPointer(s.aLight, 2, GL.UNSIGNED_BYTE,
|
||||
false, 8, eb.getVertexOffset() + 6);
|
||||
|
||||
/* draw extruded outlines */
|
||||
/* draw extruded outlines */
|
||||
if (eb.idx[0] > 0) {
|
||||
if (mTranslucent) {
|
||||
gl.depthFunc(GL.EQUAL);
|
||||
setMatrix(s, v, ebs[i]);
|
||||
}
|
||||
|
||||
/* draw roof */
|
||||
/* draw roof */
|
||||
gl.uniform1i(s.uMode, 0);
|
||||
gl.drawElements(GL.TRIANGLES, eb.idx[2],
|
||||
GL.UNSIGNED_SHORT, eb.off[2]);
|
||||
|
||||
/* draw sides 1 */
|
||||
/* draw sides 1 */
|
||||
gl.uniform1i(s.uMode, 1);
|
||||
gl.drawElements(GL.TRIANGLES, eb.idx[0],
|
||||
GL.UNSIGNED_SHORT, eb.off[0]);
|
||||
|
||||
/* draw sides 2 */
|
||||
/* draw sides 2 */
|
||||
gl.uniform1i(s.uMode, 2);
|
||||
gl.drawElements(GL.TRIANGLES, eb.idx[1],
|
||||
GL.UNSIGNED_SHORT, eb.off[1]);
|
||||
|
||||
if (mTranslucent) {
|
||||
/* drawing gl_lines with the same coordinates
|
||||
* does not result in same depth values as
|
||||
* polygons, so add offset and draw gl_lequal */
|
||||
/* drawing gl_lines with the same coordinates
|
||||
* does not result in same depth values as
|
||||
* polygons, so add offset and draw gl_lequal */
|
||||
gl.depthFunc(GL.LEQUAL);
|
||||
v.mvp.addDepthOffset(100);
|
||||
v.mvp.setAsUniform(s.uMVP);
|
||||
@ -220,14 +220,14 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
||||
GL.UNSIGNED_SHORT, eb.off[3]);
|
||||
}
|
||||
|
||||
/* draw triangle meshes */
|
||||
/* draw triangle meshes */
|
||||
if (eb.idx[4] > 0) {
|
||||
gl.drawElements(GL.TRIANGLES, eb.idx[4],
|
||||
GL.UNSIGNED_SHORT, eb.off[4]);
|
||||
}
|
||||
}
|
||||
|
||||
/* just a temporary reference! */
|
||||
/* just a temporary reference! */
|
||||
ebs[i] = null;
|
||||
}
|
||||
|
||||
@ -259,8 +259,8 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
|
||||
v.mvp.multiplyLhs(v.viewproj);
|
||||
|
||||
if (mTranslucent) {
|
||||
/* should avoid z-fighting of overlapping
|
||||
* building from different tiles */
|
||||
/* should avoid z-fighting of overlapping
|
||||
* building from different tiles */
|
||||
int zoom = (1 << z);
|
||||
int delta = (int) (l.x * zoom) % 4 + (int) (l.y * zoom) % 4 * 4;
|
||||
v.mvp.addDepthOffset(delta);
|
||||
|
@ -300,19 +300,19 @@ public class GLMatrix {
|
||||
|
||||
private native static ByteBuffer getBuffer(long self);
|
||||
|
||||
/* Copyright (C) 2007 The Android Open Source Project
|
||||
/* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License. */
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License. */
|
||||
|
||||
/**
|
||||
* Define a projection matrix in terms of six clip planes
|
||||
|
@ -48,12 +48,12 @@ public class GridRenderer extends BucketRenderer {
|
||||
public GridRenderer(int numLines, LineStyle lineStyle, TextStyle textStyle) {
|
||||
int size = Tile.SIZE;
|
||||
|
||||
/* not needed to set but we know: 16 lines 'a' two points */
|
||||
/* not needed to set but we know: 16 lines 'a' two points */
|
||||
mLines = new GeometryBuffer(2 * 16, 16);
|
||||
|
||||
float pos = -size * 4;
|
||||
|
||||
/* 8 vertical lines */
|
||||
/* 8 vertical lines */
|
||||
for (int i = 0; i < 8 * numLines; i++) {
|
||||
float x = pos + i * size / numLines;
|
||||
mLines.startLine();
|
||||
@ -61,7 +61,7 @@ public class GridRenderer extends BucketRenderer {
|
||||
mLines.addPoint(x, pos + size * 8);
|
||||
}
|
||||
|
||||
/* 8 horizontal lines */
|
||||
/* 8 horizontal lines */
|
||||
for (int j = 0; j < 8 * numLines; j++) {
|
||||
float y = pos + j * size / numLines;
|
||||
mLines.startLine();
|
||||
@ -119,7 +119,7 @@ public class GridRenderer extends BucketRenderer {
|
||||
int x = (int) (v.pos.x * z);
|
||||
int y = (int) (v.pos.y * z);
|
||||
|
||||
/* update buckets when map moved by at least one tile */
|
||||
/* update buckets when map moved by at least one tile */
|
||||
if (x == mCurX && y == mCurY && z == mCurZ)
|
||||
return;
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class MapRenderer {
|
||||
mViewport = new GLViewport();
|
||||
mBufferPool = new NativeBufferPool();
|
||||
|
||||
/* FIXME should be done in 'destroy' method
|
||||
/* FIXME should be done in 'destroy' method
|
||||
* clear all previous vbo refs */
|
||||
BufferObject.clear();
|
||||
setBackgroundColor(Color.DKGRAY);
|
||||
@ -115,13 +115,13 @@ public class MapRenderer {
|
||||
|
||||
if (GLAdapter.debugView) {
|
||||
/* modify this to scale only the view, to see
|
||||
* which tiles are rendered */
|
||||
* which tiles are rendered */
|
||||
mViewport.mvp.setScale(0.5f, 0.5f, 1);
|
||||
mViewport.viewproj.multiplyLhs(mViewport.mvp);
|
||||
mViewport.proj.multiplyLhs(mViewport.mvp);
|
||||
}
|
||||
|
||||
/* update layers */
|
||||
/* update layers */
|
||||
LayerRenderer[] layers = mMap.layers().getLayerRenderer();
|
||||
|
||||
for (int i = 0, n = layers.length; i < n; i++) {
|
||||
|
@ -203,7 +203,7 @@ public class OffscreenRenderer extends LayerRenderer {
|
||||
|
||||
mShader.useProgram();
|
||||
|
||||
/* bind depth texture */
|
||||
/* bind depth texture */
|
||||
if (useDepthTexture) {
|
||||
gl.activeTexture(GL.TEXTURE1);
|
||||
GLState.bindTex2D(renderDepth);
|
||||
|
@ -251,10 +251,10 @@ public class TextureAtlas extends Inlist<TextureAtlas> {
|
||||
return new TextureAtlas(width, height);
|
||||
}
|
||||
|
||||
// /// FIXME
|
||||
// @Override
|
||||
// protected void finalize(){
|
||||
// if (texture != null)
|
||||
// TextureItem.releaseTexture(texture);
|
||||
// }
|
||||
// /// FIXME
|
||||
// @Override
|
||||
// protected void finalize(){
|
||||
// if (texture != null)
|
||||
// TextureItem.releaseTexture(texture);
|
||||
// }
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user