fix: gwt LwHttp emulation
This commit is contained in:
parent
9f626e3716
commit
ec1954a83a
@ -29,25 +29,17 @@ import com.google.gwt.xhr.client.XMLHttpRequest.ResponseType;
|
|||||||
public class LwHttp {
|
public class LwHttp {
|
||||||
//static final Logger log = LoggerFactory.getLogger(LwHttp.class);
|
//static final Logger log = LoggerFactory.getLogger(LwHttp.class);
|
||||||
|
|
||||||
private final String mUrlFileExtension;
|
|
||||||
private final String mUrlPath;
|
private final String mUrlPath;
|
||||||
private final byte[] mRequestBuffer;
|
private final byte[] mRequestBuffer;
|
||||||
|
|
||||||
final boolean mInflateContent;
|
|
||||||
final String mContentType;
|
|
||||||
|
|
||||||
private int mContentLength = -1;
|
private int mContentLength = -1;
|
||||||
private XMLHttpRequest mHttpRequest;
|
private XMLHttpRequest mHttpRequest;
|
||||||
|
|
||||||
private ReadyStateChangeHandler mResponseHandler;
|
private ReadyStateChangeHandler mResponseHandler;
|
||||||
|
|
||||||
public LwHttp(URL url, String contentType, String extension, boolean deflate) {
|
public LwHttp(URL url) {
|
||||||
mContentType = contentType;
|
|
||||||
mInflateContent = deflate;
|
|
||||||
|
|
||||||
mUrlPath = url.toString();
|
mUrlPath = url.toString();
|
||||||
mUrlFileExtension = extension;
|
|
||||||
|
|
||||||
mRequestBuffer = new byte[1024];
|
mRequestBuffer = new byte[1024];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,20 +75,10 @@ public class LwHttp {
|
|||||||
|
|
||||||
byte[] request = mRequestBuffer;
|
byte[] request = mRequestBuffer;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int newPos = 0;
|
|
||||||
|
|
||||||
if ((newPos = formatTilePath(tile, request, pos)) == 0) {
|
pos = dataSource.getTileSource().formatTilePath(tile, request, pos);
|
||||||
request[pos++] = '/';
|
|
||||||
pos = writeInt(tile.zoomLevel, pos, request);
|
|
||||||
request[pos++] = '/';
|
|
||||||
pos = writeInt(tile.tileX, pos, request);
|
|
||||||
request[pos++] = '/';
|
|
||||||
pos = writeInt(tile.tileY, pos, request);
|
|
||||||
} else {
|
|
||||||
pos = newPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
String url = mUrlPath + (new String(request, 0, pos) + mUrlFileExtension);
|
String url = mUrlPath + (new String(request, 0, pos));
|
||||||
|
|
||||||
mHttpRequest = XMLHttpRequest.create();
|
mHttpRequest = XMLHttpRequest.create();
|
||||||
mHttpRequest.open("GET", url);
|
mHttpRequest.open("GET", url);
|
||||||
@ -169,17 +151,4 @@ public class LwHttp {
|
|||||||
public int getContentLength() {
|
public int getContentLength() {
|
||||||
return mContentLength;
|
return mContentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Write custom tile url
|
|
||||||
*
|
|
||||||
* @param tile Tile
|
|
||||||
* @param path to write url string
|
|
||||||
* @param curPos current position
|
|
||||||
* @return new position
|
|
||||||
*/
|
|
||||||
protected int formatTilePath(Tile tile, byte[] path, int curPos) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import org.oscim.tiling.MapTile;
|
|||||||
import org.oscim.tiling.source.ITileDataSink;
|
import org.oscim.tiling.source.ITileDataSink;
|
||||||
import org.oscim.tiling.source.ITileDataSource;
|
import org.oscim.tiling.source.ITileDataSource;
|
||||||
import org.oscim.tiling.source.ITileDecoder;
|
import org.oscim.tiling.source.ITileDecoder;
|
||||||
import org.oscim.tiling.source.TileSource;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -30,12 +29,17 @@ public class UrlTileDataSource implements ITileDataSource {
|
|||||||
|
|
||||||
protected final LwHttp mConn;
|
protected final LwHttp mConn;
|
||||||
protected final ITileDecoder mTileDecoder;
|
protected final ITileDecoder mTileDecoder;
|
||||||
|
protected final UrlTileSource mTileSource;
|
||||||
|
|
||||||
public UrlTileDataSource(TileSource tileSource, ITileDecoder tileDecoder, LwHttp conn) {
|
public UrlTileDataSource(UrlTileSource tileSource, ITileDecoder tileDecoder, LwHttp conn) {
|
||||||
|
mTileSource = tileSource;
|
||||||
mTileDecoder = tileDecoder;
|
mTileDecoder = tileDecoder;
|
||||||
mConn = conn;
|
mConn = conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UrlTileSource getTileSource(){
|
||||||
|
return mTileSource;
|
||||||
|
}
|
||||||
private ITileDataSink mSink;
|
private ITileDataSink mSink;
|
||||||
private MapTile mTile;
|
private MapTile mTile;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user