- initial way labeling

- add no-projection option for mapdata
- use depth buffer for line clipping to tile - no more scissor, yay!
- extract line and poly render function from maprenderer
- use one vbo for both polys and lines
- use linear interpolator for fling-scroller
- add 'exclusive' negative matcher to rendertheme
- add some more options to rendertheme, kind of inheritance at least for
  lines, see theme
- add caching for node tags -> renderinstructions
- ...
This commit is contained in:
Hannes Janetzek
2012-08-28 09:25:06 +02:00
parent 1cf0c02dd2
commit 2fccf0f214
46 changed files with 3591 additions and 2815 deletions

View File

@@ -24,6 +24,7 @@ import org.mapsforge.android.rendertheme.RenderTheme;
import org.mapsforge.android.rendertheme.renderinstruction.Area;
import org.mapsforge.android.rendertheme.renderinstruction.Caption;
import org.mapsforge.android.rendertheme.renderinstruction.Line;
import org.mapsforge.android.rendertheme.renderinstruction.PathText;
import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile;
import org.mapsforge.database.IMapDatabase;
@@ -414,24 +415,24 @@ public class MapGenerator implements IMapGenerator, IRenderCallback,
private List<ShapeContainer> mCurLevelContainer2;
@Override
public void renderWay(Line line) {
List<ShapeContainer> c = mDrawingLayer.add(line.level, mWayDataContainer,
line.paint);
if (mCurLevelContainer1 == null)
mCurLevelContainer1 = c;
else if (mCurLevelContainer2 == null)
mCurLevelContainer2 = c;
public void renderWay(Line line, int level) {
// List<ShapeContainer> c = mDrawingLayer.add(level, mWayDataContainer,
// line.paint);
//
// if (mCurLevelContainer1 == null)
// mCurLevelContainer1 = c;
// else if (mCurLevelContainer2 == null)
// mCurLevelContainer2 = c;
}
@Override
public void renderArea(Area area) {
if (area.paintFill != null)
mCurLevelContainer1 = mDrawingLayer.add(area.level, mWayDataContainer,
area.paintFill);
if (area.paintOutline != null)
mCurLevelContainer1 = mDrawingLayer.add(area.level, mWayDataContainer,
area.paintOutline);
public void renderArea(Area area, int level) {
// if (area.paintFill != null)
// mCurLevelContainer1 = mDrawingLayer.add(level, mWayDataContainer,
// area.paintFill);
// if (area.paintOutline != null)
// mCurLevelContainer1 = mDrawingLayer.add(level, mWayDataContainer,
// area.paintOutline);
}
@Override
@@ -443,7 +444,7 @@ public class MapGenerator implements IMapGenerator, IRenderCallback,
}
@Override
public void renderWayText(String textKey, Paint paint, Paint outline) {
public void renderWayText(PathText pathText) {
// if (mWayDataContainer.textPos[0] >= 0)
// WayDecorator.renderText(this, paint, outline, mCoords, mWayDataContainer, mWayNames);
}

View File

@@ -33,6 +33,7 @@ import org.mapsforge.android.mapgenerator.JobParameters;
import org.mapsforge.android.mapgenerator.MapGeneratorJob;
import org.mapsforge.android.mapgenerator.TileCacheKey;
import org.mapsforge.android.mapgenerator.TileDistanceSort;
import org.mapsforge.android.rendertheme.RenderTheme;
import org.mapsforge.android.utils.GlUtils;
import org.mapsforge.core.MapPosition;
import org.mapsforge.core.MercatorProjection;
@@ -213,7 +214,7 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
newTiles[tiles++] = tile;
if (!tile.isReady || (tile.getScale() != scale)) {
tile.isLoading = true;
// tile.isLoading = true;
// approximation for TileScheduler
if (tileY < tileTop || tileY > tileBottom || tileX < tileLeft
|| tileX > tileRight)
@@ -494,12 +495,6 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
}
}
}
// FIXME
// if (loadedTexture) {
// synchronized (mMapWorker) {
// mMapWorker.notify();
// }
// }
}
@Override
@@ -588,4 +583,10 @@ public class MapRenderer implements org.mapsforge.android.IMapRenderer {
public IMapGenerator createMapGenerator() {
return new MapGenerator();
}
@Override
public void setRenderTheme(RenderTheme t) {
// TODO Auto-generated method stub
}
}

View File

@@ -38,7 +38,8 @@ final class WayDecorator {
*/
private static final int SEGMENT_SAFETY_DISTANCE = 30;
static void renderSymbol(Bitmap symbolBitmap, boolean alignCenter, boolean repeatSymbol, float[][] coordinates,
static void renderSymbol(Bitmap symbolBitmap, boolean alignCenter,
boolean repeatSymbol, float[][] coordinates,
List<SymbolContainer> waySymbols) {
int skipPixels = SEGMENT_SAFETY_DISTANCE;
@@ -68,9 +69,11 @@ final class WayDecorator {
// move the previous point forward towards the current point
previousX += diffX * segmentSkipPercentage;
previousY += diffY * segmentSkipPercentage;
symbolAngle = (float) Math.toDegrees(Math.atan2(currentY - previousY, currentX - previousX));
symbolAngle = (float) Math.toDegrees(Math.atan2(currentY - previousY,
currentX - previousX));
waySymbols.add(new SymbolContainer(symbolBitmap, previousX, previousY, alignCenter, symbolAngle));
waySymbols.add(new SymbolContainer(symbolBitmap, previousX, previousY,
alignCenter, symbolAngle));
// check if the symbol should only be rendered once
if (!repeatSymbol) {
@@ -145,7 +148,8 @@ final class WayDecorator {
} else if ((currentY - nextY) == 0)
break;
float diff = ((float) (diffX) / (diffY) - (float) (currentX - nextX) / (currentY - nextY));
float diff = ((float) (diffX) / (diffY) - (float) (currentX - nextX)
/ (currentY - nextY));
// skip segments with corners
if (diff >= 0.2 || diff <= -0.2)
@@ -210,7 +214,7 @@ final class WayDecorator {
y2 = previousY;
}
// estimate position of test on path
// estimate position of text on path
width = (x2 - x1) / 2;
x2 = x2 - (int) (width - s * width);
x1 = x1 + (int) (width - s * width);
@@ -234,7 +238,8 @@ final class WayDecorator {
break;
// check crossings
if (GeometryUtils.lineIntersect(x1, y1, x2, y2, wtc2.x1, wtc2.y1, wtc2.x2, wtc2.y2)) {
if (GeometryUtils.lineIntersect(x1, y1, x2, y2, wtc2.x1, wtc2.y1,
wtc2.x2, wtc2.y2)) {
intersects = true;
break;
}
@@ -244,7 +249,8 @@ final class WayDecorator {
short top2 = (wtc2.y1 < wtc2.y2 ? wtc2.y1 : wtc2.y2);
short bot2 = (wtc2.y1 < wtc2.y2 ? wtc2.y2 : wtc2.y1);
if (x1 - 10 < wtc2.x2 && wtc2.x1 - 10 < x2 && top - 10 < bot2 && top2 - 10 < bot) {
if (x1 - 10 < wtc2.x2 && wtc2.x1 - 10 < x2 && top - 10 < bot2
&& top2 - 10 < bot) {
if (wtc2.text.equals(text)) {
intersects = true;
@@ -260,7 +266,8 @@ final class WayDecorator {
}
Log.d("mapsforge", "add " + text + " " + first + " " + last);
WayTextContainer wtc = new WayTextContainer(first, last, wayDataContainer, text,
WayTextContainer wtc = new WayTextContainer(first, last,
wayDataContainer, text,
paint);
wtc.x1 = (short) x1;
wtc.y1 = (short) y1;
@@ -272,7 +279,8 @@ final class WayDecorator {
containerSize++;
if (outline != null) {
wayNames.add(new WayTextContainer(first, last, wayDataContainer, text, outline));
wayNames.add(new WayTextContainer(first, last, wayDataContainer,
text, outline));
containerSize++;
}
// 500 ??? how big is a tile?!