bring back TestTileSource

This commit is contained in:
Hannes Janetzek 2013-06-28 04:11:41 +02:00
parent eb05c29495
commit dea77fbd5b

View File

@ -22,43 +22,64 @@ import org.oscim.layers.tile.MapTile;
import org.oscim.tilesource.ITileDataSink;
import org.oscim.tilesource.ITileDataSource;
import org.oscim.tilesource.MapInfo;
import org.oscim.tilesource.TileSource;
/**
*
*
*/
public class TestTileSource implements ITileDataSource {
private final Tag[] mTags = {
new Tag("natural", "water")
};
private final Tag[] mTagsWay = {
new Tag("highway", "primary"),
new Tag("name", "Highway Rd")
};
private final Tag[] mTagsBoundary = {
new Tag("boundary", "administrative"),
new Tag("admin_level", "2")
};
private final Tag[] mTagsPlace = {
new Tag("place", "city"),
null
};
public class TestTileSource extends TileSource {
private final MapInfo mMapInfo =
new MapInfo(new BoundingBox(-180, -90, 180, 90),
new Byte((byte) 5), null, null, 0, 0, 0,
"", "", "", null);
private final boolean mOpenFile = false;
// private boolean mOpenFile = false;
@Override
public ITileDataSource getDataSource() {
return new TileDataSource();
}
@Override
public OpenResult open() {
// mOpenFile =true;
return OpenResult.SUCCESS;
}
@Override
public void close() {
// mOpenFile = false;
}
@Override
public MapInfo getMapInfo() {
return mMapInfo;
}
static class TileDataSource implements ITileDataSource {
private static final Tag[] mTags = {
new Tag("natural", "water")
};
private static final Tag[] mTagsWay = {
new Tag("highway", "primary"),
new Tag("name", "Highway Rd")
};
private static final Tag[] mTagsBoundary = {
new Tag("boundary", "administrative"),
new Tag("admin_level", "2")
};
private static final Tag[] mTagsPlace = {
new Tag("place", "city"),
null
};
private final MapElement mElem;
public TestTileSource() {
public TileDataSource() {
mElem = new MapElement();
}
private final boolean renderWays = false;
private final boolean renderWays = true;
private final boolean renderBoundary = false;
private final boolean renderPlace = false;
@ -94,7 +115,8 @@ public class TestTileSource implements ITileDataSource {
e.addPoint(x2, y2);
e.addPoint(x1, y2);
//// FIXME e.setLayer(mTags, 0);
e.setLayer(0);
e.tags.set(mTags);
mapDataSink.process(e);
if (renderWays) {
@ -115,7 +137,7 @@ public class TestTileSource implements ITileDataSource {
e.addPoint(size / 2, size / 2);
e.addPoint(size / 2, size / 2 + size);
////e.setLayer(mTagsWay, 0);
// //e.setLayer(mTagsWay, 0);
mapDataSink.process(e);
e.clear();
@ -132,7 +154,8 @@ public class TestTileSource implements ITileDataSource {
e.addPoint(10, 0);
e.addPoint(10, size);
//// --e.setLayer(mTagsWay, 1);
e.setLayer(1);
e.tags.set(mTagsWay);
mapDataSink.process(e);
}
@ -147,7 +170,8 @@ public class TestTileSource implements ITileDataSource {
r + (float) Math.sin(d) * (r - 40));
}
//// e.setLayer(mTagsBoundary, 1);
e.setLayer(1);
e.tags.set(mTagsWay);
mapDataSink.process(e);
}
@ -157,38 +181,18 @@ public class TestTileSource implements ITileDataSource {
e.addPoint(size / 2, size / 2);
mTagsPlace[1] = new Tag("name", tile.toString());
//// e.setLayer(mTagsPlace, 0);
e.tags.set(mTagsPlace);
mapDataSink.process(e);
}
mapDataSink.completed(true);
return QueryResult.SUCCESS;
}
// @Override
// public boolean isOpen() {
// return mOpenFile;
// }
//
// @Override
// public OpenResult open(MapOptions options) {
// mOpenFile = true;
// return OpenResult.SUCCESS;
// }
//
// @Override
// public void close() {
// mOpenFile = false;
// }
//
// @Override
// public void cancel() {
// }
@Override
public void destroy() {
// TODO Auto-generated method stub
}
}
}