disable clipping of way label segments for now

This commit is contained in:
Hannes Janetzek 2014-01-27 00:56:24 +01:00
parent d70a6c5997
commit 2c0eb751a7
2 changed files with 67 additions and 71 deletions

View File

@ -32,11 +32,11 @@ public final class WayDecorator {
TextItem t = null; TextItem t = null;
// calculate the way name length plus some margin of safety // calculate the way name length plus some margin of safety
float wayNameWidth = -1; float labelWidth = -1;
float minWidth = Tile.SIZE / 10; float minWidth = Tile.SIZE / 10;
final int min = 0; //final int min = 0;
final int max = Tile.SIZE; //final int max = Tile.SIZE;
// find way segments long enough to draw the way name on them // find way segments long enough to draw the way name on them
for (int i = pos; i < pos + len - 2; i += 2) { for (int i = pos; i < pos + len - 2; i += 2) {
@ -45,42 +45,41 @@ public final class WayDecorator {
float prevY = coordinates[i + 1]; float prevY = coordinates[i + 1];
byte edge = 0; byte edge = 0;
//clipper.clipStart(prevX, prevY);
clipper.clipStart(prevX, prevY);
// get the current way point coordinates // get the current way point coordinates
float curX = coordinates[i + 2]; float curX = coordinates[i + 2];
float curY = coordinates[i + 3]; float curY = coordinates[i + 3];
int clip; //int clip;
if ((clip = clipper.clipNext(curX, curY)) != 0) { //if ((clip = clipper.clipNext(curX, curY)) != 0) {
if (clip < 0) { // if (clip < 0) {
prevX = clipper.out[0]; // prevX = clipper.out[0];
prevY = clipper.out[1]; // prevY = clipper.out[1];
curX = clipper.out[2]; // curX = clipper.out[2];
curY = clipper.out[3]; // curY = clipper.out[3];
//
if (prevX == min) // if (prevX == min)
edge |= 1 << 0; // edge |= 1 << 0;
else if (prevX == max) // else if (prevX == max)
edge |= 1 << 1; // edge |= 1 << 1;
//
if (prevY == min) // if (prevY == min)
edge |= 1 << 2; // edge |= 1 << 2;
else if (prevY == max) // else if (prevY == max)
edge |= 1 << 3; // edge |= 1 << 3;
//
if (curX == min) // if (curX == min)
edge |= 1 << 4; // edge |= 1 << 4;
else if (curX == max) // else if (curX == max)
edge |= 1 << 5; // edge |= 1 << 5;
//
if (curY == min) // if (curY == min)
edge |= 1 << 5; // edge |= 1 << 5;
else if (curY == max) // else if (curY == max)
edge |= 1 << 6; // edge |= 1 << 6;
} // }
} //}
int last = i; int last = i;
@ -102,15 +101,15 @@ public final class WayDecorator {
float nextX = coordinates[j + 0]; float nextX = coordinates[j + 0];
float nextY = coordinates[j + 1]; float nextY = coordinates[j + 1];
if ((clip = clipper.clipNext(nextX, nextY)) != 0) { //if ((clip = clipper.clipNext(nextX, nextY)) != 0) {
if (clip < 0) { // if (clip < 0) {
curX = clipper.out[0]; // curX = clipper.out[0];
curY = clipper.out[1]; // curY = clipper.out[1];
// TODO break when cur has changed // // TODO break when cur has changed
nextX = clipper.out[2]; // nextX = clipper.out[2];
nextY = clipper.out[3]; // nextY = clipper.out[3];
} // }
} //}
float wx = nextX - curX; float wx = nextX - curX;
float wy = nextY - curY; float wy = nextY - curY;
@ -147,17 +146,17 @@ public final class WayDecorator {
curY = nextY; curY = nextY;
last = j - 2; last = j - 2;
if (clip < 0) { //if (clip < 0) {
if (nextX == min) // if (nextX == min)
edge |= 1 << 4; // edge |= 1 << 4;
else if (nextX == max) // else if (nextX == max)
edge |= 1 << 5; // edge |= 1 << 5;
//
if (nextY == min) // if (nextY == min)
edge |= 1 << 6; // edge |= 1 << 6;
else if (nextY == max) // else if (nextY == max)
edge |= 1 << 7; // edge |= 1 << 7;
} //}
} }
vx = curX - prevX; vx = curX - prevX;
@ -172,15 +171,15 @@ public final class WayDecorator {
continue; continue;
} }
if (wayNameWidth < 0) { if (labelWidth < 0) {
wayNameWidth = text.paint.measureText(string); labelWidth = text.paint.measureText(string);
} }
if (segmentLength < wayNameWidth * 0.50) { if (segmentLength < labelWidth * 0.50) {
continue; continue;
} }
} else if (wayNameWidth < 0) { } else if (labelWidth < 0) {
wayNameWidth = text.paint.measureText(string); labelWidth = text.paint.measureText(string);
} }
float x1, y1, x2, y2; float x1, y1, x2, y2;
@ -199,17 +198,17 @@ public final class WayDecorator {
TextItem n = TextItem.pool.get(); TextItem n = TextItem.pool.get();
// link items together // link items together
if (t != null) { //if (t != null) {
t.n1 = n; // t.n1 = n;
n.n2 = t; // n.n2 = t;
} //}
t = n; t = n;
t.x = x1 + (x2 - x1) / 2f; t.x = x1 + (x2 - x1) / 2f;
t.y = y1 + (y2 - y1) / 2f; t.y = y1 + (y2 - y1) / 2f;
t.string = string; t.string = string;
t.text = text; t.text = text;
t.width = wayNameWidth; t.width = labelWidth;
t.x1 = x1; t.x1 = x1;
t.y1 = y1; t.y1 = y1;
t.x2 = x2; t.x2 = x2;

View File

@ -36,8 +36,8 @@ public class TextItem extends Inlist<TextItem> {
// drop references // drop references
ti.string = null; ti.string = null;
ti.text = null; ti.text = null;
ti.n1 = null; //ti.n1 = null;
ti.n2 = null; //ti.n2 = null;
return true; return true;
} }
}; };
@ -70,9 +70,6 @@ public class TextItem extends Inlist<TextItem> {
return this; return this;
} }
// link to next node
//public TextItem next;
// center // center
public float x, y; public float x, y;
@ -92,8 +89,8 @@ public class TextItem extends Inlist<TextItem> {
public short length; public short length;
// link to next/prev label of the way // link to next/prev label of the way
public TextItem n1; //public TextItem n1;
public TextItem n2; //public TextItem n2;
public byte edges; public byte edges;