收藏

http://blog.csdn.net/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);
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值