http://blog.youkuaiyun.com/warrenwyf/article/details/6069711中缺失的代码:
@Override
public byte[] getTile(int level, int row, int col) throws Exception {
byte[] result = null;
try {
String bundlesDir = location + File.separator + "_alllayers";
Log.i("location", bundlesDir);
String l = "0" + level;
int lLength = l.length();
if (lLength > 2) {
l = l.substring(lLength - 2);
}
l = "L" + l;
int rGroup = 128 * (row / 128);
String r = "000" + Integer.toHexString(rGroup);
int rLength = r.length();
if (rLength > 4) {
r = r.substring(rLength - 4);
}
r = "R" + r;
int cGroup = 128 * (col / 128);
String c = "000" + Integer.toHexString(cGroup);
int cLength = c.length();
if (cLength > 4) {
c = c.substring(cLength - 4);
}
c = "C" + c;
String bundleBase = String
.format("%s/%s/%s%s", bundlesDir, l, r, c);
String bundlxFileName = bundleBase + ".bundlx";
String bundleFileName = bundleBase + ".bundle";
int index = 128 * (col - cGroup) + (row - rGroup);
FileInputStream isBundlx = new FileInputStream(bundlxFileName);
isBundlx.skip(16 + 5 * index);
byte[] buffer = new byte[5];
isBundlx.read(buffer);
long offset = (long) (buffer[0] & 0xff) + (long) (buffer[1] & 0xff)
* 256 + (long) (buffer[2] & 0xff) * 65536
+ (long) (buffer[3] & 0xff) * 16777216
+ (long) (buffer[4] & 0xff) * 4294967296L;
FileInputStream isBundle = new FileInputStream(bundleFileName);
isBundle.skip(offset);
byte[] lengthBytes = new byte[4];
isBundle.read(lengthBytes);
int length = (int) (lengthBytes[0] & 0xff)
+ (int) (lengthBytes[1] & 0xff) * 256
+ (int) (lengthBytes[2] & 0xff) * 65536
+ (int) (lengthBytes[3] & 0xff) * 16777216;
result = new byte[length];
isBundle.read(result);
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
override protected function getTileURL(level:Number, row:Number,col:Number):URLRequest
{
var url:String = "http://localhost:8777/restserver/tile/"+level+"/"+row+"/"+col;
return new URLRequest(url);
}