diff --git a/vtm/src/org/oscim/layers/PathLayer.java b/vtm/src/org/oscim/layers/PathLayer.java index a518c2f5..13799d4a 100644 --- a/vtm/src/org/oscim/layers/PathLayer.java +++ b/vtm/src/org/oscim/layers/PathLayer.java @@ -163,8 +163,8 @@ public class PathLayer extends Layer { float[] projected = mPPoints; int i = addPoint(projected, 0, x, y); - int prevX = x; - int prevY = y; + float prevX = x; + float prevY = y; for (int j = 2; j < size * 2; j += 2) { x = (int) ((mPreprojected[j + 0] - mx) * scale); @@ -207,8 +207,8 @@ public class PathLayer extends Layer { continue; } - int dx = x - prevX; - int dy = y - prevY; + float dx = x - prevX; + float dy = y - prevY; if ((i == 0) || FastMath.absMaxCmp(dx, dy, MIN_DIST)) { projected[i++] = prevX = x; projected[i++] = prevY = y; diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java b/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java index 604a116c..2446fc5c 100644 --- a/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java +++ b/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java @@ -39,16 +39,16 @@ public final class WayDecorator { // find way segments long enough to draw the way name on them for (int i = pos; i < pos + len - 2; i += 2) { // get the first way point coordinates - int prevX = (int) coordinates[i + 0]; - int prevY = (int) coordinates[i + 1]; + float prevX = coordinates[i + 0]; + float prevY = coordinates[i + 1]; byte edge = 0; clipper.clipStart(prevX, prevY); // get the current way point coordinates - int curX = (int) coordinates[i + 2]; - int curY = (int) coordinates[i + 3]; + float curX = coordinates[i + 2]; + float curY = coordinates[i + 3]; int clip; if ((clip = clipper.clipNext(curX, curY)) != 0) { @@ -97,8 +97,8 @@ public final class WayDecorator { // add additional segments if possible for (int j = i + 4; j < pos + len; j += 2) { - int nextX = (int) coordinates[j + 0]; - int nextY = (int) coordinates[j + 1]; + float nextX = coordinates[j + 0]; + float nextY = coordinates[j + 1]; if ((clip = clipper.clipNext(nextX, nextY)) != 0) { if (clip < 0) { diff --git a/vtm/src/org/oscim/utils/LineClipper.java b/vtm/src/org/oscim/utils/LineClipper.java index 22c6dbb0..7d9f244b 100644 --- a/vtm/src/org/oscim/utils/LineClipper.java +++ b/vtm/src/org/oscim/utils/LineClipper.java @@ -30,7 +30,7 @@ public class LineClipper { public static final int TOP = 8; // 1000 private final int xmin, xmax, ymin, ymax; - public final int[] out; + public final float[] out; public LineClipper(int minx, int miny, int maxx, int maxy) { this.xmin = minx; @@ -46,19 +46,19 @@ public class LineClipper { this.xmax = maxx; this.ymax = maxy; if (keepResult) - this.out = new int[4]; + this.out = new float[4]; else this.out = null; } private int mPrevOutcode; - private int mPrevX; - private int mPrevY; + private float mPrevX; + private float mPrevY; - public int outX; - public int outY; + //public int outX; + //public int outY; - public void clipStart(int x0, int y0) { + public boolean clipStart(float x0, float y0) { mPrevX = x0; mPrevY = y0; @@ -71,6 +71,8 @@ public class LineClipper { mPrevOutcode |= BOTTOM; else if (y0 > ymax) mPrevOutcode |= TOP; + + return mPrevOutcode == INSIDE; } /** @@ -79,7 +81,7 @@ public class LineClipper { * @return 0 if not intersection, 1 fully within, -1 clipped (and 'out' set * to new points) */ - public int clipNext(int x1, int y1) { + public int clipNext(float x1, float y1) { int accept; int outcode = INSIDE; @@ -112,8 +114,8 @@ public class LineClipper { // CohenSutherland clipping algorithm clips a line from // P0 = (x0, y0) to P1 = (x1, y1) against a rectangle with // diagonal from (xmin, ymin) to (xmax, ymax). - private static boolean clip(int x0, int y0, int x1, int y1, - int xmin, int ymin, int xmax, int ymax, int outcode0, int outcode1, int[] out) { + private static boolean clip(float x0, float y0, float x1, float y1, + int xmin, int ymin, int xmax, int ymax, int outcode0, int outcode1, float[] out) { boolean accept = false; @@ -128,8 +130,8 @@ public class LineClipper { } else { // failed both tests, so calculate the line segment to clip // from an outside point to an intersection with clip edge - int x = 0; - int y = 0; + float x = 0; + float y = 0; // At least one endpoint is outside the clip rectangle; pick it. int outcodeOut = (outcode0 == 0) ? outcode1 : outcode0;