fix: GeometryBuffer.getNumPoints()

This commit is contained in:
Hannes Janetzek 2014-02-18 03:43:24 +01:00
parent 3896358ba8
commit 733d9dac96
5 changed files with 11 additions and 8 deletions

View File

@ -384,7 +384,7 @@ public class TileDecoder extends PbfDecoder {
return coordCnt; return coordCnt;
} }
@Override //@Override
protected int decodeInterleavedPoints(float[] coords, float scale) protected int decodeInterleavedPoints(float[] coords, float scale)
throws IOException { throws IOException {

View File

@ -229,7 +229,7 @@ public class OSciMap2TileSource extends UrlTileSource {
} }
mElem.ensurePointSize(coordCnt, false); mElem.ensurePointSize(coordCnt, false);
int cnt = decodeInterleavedPoints(mElem.points, mScale); int cnt = decodeInterleavedPoints(mElem, mScale);
if (cnt != coordCnt) { if (cnt != coordCnt) {
log.debug(mTile + " wrong number of coordintes"); log.debug(mTile + " wrong number of coordintes");

View File

@ -98,7 +98,7 @@ public class GeometryBuffer {
} }
public int getNumPoints() { public int getNumPoints() {
return index[0] >> 1; return pointPos >> 1;
} }
/** /**

View File

@ -19,6 +19,7 @@ package org.oscim.tiling.source.common;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.oscim.core.GeometryBuffer;
import org.oscim.tiling.source.ITileDecoder; import org.oscim.tiling.source.ITileDecoder;
import org.oscim.utils.UTF8Decoder; import org.oscim.utils.UTF8Decoder;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -187,9 +188,10 @@ public abstract class PbfDecoder implements ITileDecoder {
return buffer[bufferPos++] != 0; return buffer[bufferPos++] != 0;
} }
protected int decodeInterleavedPoints(float[] coords, float scale) protected int decodeInterleavedPoints(GeometryBuffer geom, float scale)
throws IOException { throws IOException {
float[] points = geom.points;
int bytes = decodeVarint32(); int bytes = decodeVarint32();
fillBuffer(bytes); fillBuffer(bytes);
@ -229,11 +231,11 @@ public abstract class PbfDecoder implements ITileDecoder {
if (even) { if (even) {
lastX = lastX + s; lastX = lastX + s;
coords[cnt++] = lastX / scale; points[cnt++] = lastX / scale;
even = false; even = false;
} else { } else {
lastY = lastY + s; lastY = lastY + s;
coords[cnt++] = lastY / scale; points[cnt++] = lastY / scale;
even = true; even = true;
} }
} }
@ -243,6 +245,8 @@ public abstract class PbfDecoder implements ITileDecoder {
bufferPos = pos; bufferPos = pos;
geom.pointPos = cnt;
// return number of points read // return number of points read
return (cnt >> 1); return (cnt >> 1);
} }

View File

@ -298,8 +298,7 @@ public class TileDecoder extends PbfDecoder {
} }
mElem.ensurePointSize(coordCnt, false); mElem.ensurePointSize(coordCnt, false);
int cnt = decodeInterleavedPoints(mElem.points, int cnt = decodeInterleavedPoints(mElem, mScaleFactor);
mScaleFactor);
if (cnt != coordCnt) { if (cnt != coordCnt) {
log.debug("{} wrong number of coordintes {}/{}", mTile, log.debug("{} wrong number of coordintes {}/{}", mTile,