cleanup
This commit is contained in:
parent
150e769709
commit
08ab7a6613
2 changed files with 6 additions and 8 deletions
|
@ -40,6 +40,10 @@ public class OsmAndHttpServer extends NanoHTTPD {
|
||||||
return getStatic(uri);
|
return getStatic(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return "http://" + getHostname() + ":" + getListeningPort();
|
||||||
|
}
|
||||||
|
|
||||||
private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) {
|
private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) {
|
||||||
String uri = session.getUri();
|
String uri = session.getUri();
|
||||||
for (String path : endpoints.keySet()) {
|
for (String path : endpoints.keySet()) {
|
||||||
|
@ -102,10 +106,6 @@ public class OsmAndHttpServer extends NanoHTTPD {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return "http://" + getHostname() + ":" + getListeningPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ApiEndpoint {
|
public interface ApiEndpoint {
|
||||||
NanoHTTPD.Response process(NanoHTTPD.IHTTPSession session);
|
NanoHTTPD.Response process(NanoHTTPD.IHTTPSession session);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
|
||||||
private static final int TILE_SIZE_PX = 512;
|
private static final int TILE_SIZE_PX = 512;
|
||||||
private static final int TIMEOUT_STEP = 500;
|
private static final int TIMEOUT_STEP = 500;
|
||||||
private static final Log LOG = PlatformUtil.getLog(TileEndpoint.class);
|
private static final Log LOG = PlatformUtil.getLog(TileEndpoint.class);
|
||||||
|
private final MapActivity mapActivity;
|
||||||
private RotatedTileBox resultBmpViewport;
|
private RotatedTileBox resultBmpViewport;
|
||||||
private Bitmap resultBitmap;
|
private Bitmap resultBitmap;
|
||||||
private MapActivity mapActivity;
|
|
||||||
|
|
||||||
public TileEndpoint(MapActivity mapActivity) {
|
public TileEndpoint(MapActivity mapActivity) {
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
|
@ -48,7 +48,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
return OsmAndHttpServer.ErrorResponses.response500;
|
return OsmAndHttpServer.ErrorResponses.response500;
|
||||||
}
|
}
|
||||||
//stream also needs to be synchronized
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
|
||||||
byte[] byteArray = stream.toByteArray();
|
byte[] byteArray = stream.toByteArray();
|
||||||
|
@ -68,7 +67,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
|
||||||
.setZoom(zoom)
|
.setZoom(zoom)
|
||||||
.setPixelDimensions(TILE_SIZE_PX, TILE_SIZE_PX, 0.5f, 0.5f).build();
|
.setPixelDimensions(TILE_SIZE_PX, TILE_SIZE_PX, 0.5f, 0.5f).build();
|
||||||
mapActivity.getMapView().setCurrentViewport(rotatedTileBox);
|
mapActivity.getMapView().setCurrentViewport(rotatedTileBox);
|
||||||
Bitmap bmp = null;
|
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
try {
|
try {
|
||||||
while (!rotatedTileBox.equals(resultBmpViewport) && timeout < SOCKET_READ_TIMEOUT) {
|
while (!rotatedTileBox.equals(resultBmpViewport) && timeout < SOCKET_READ_TIMEOUT) {
|
||||||
|
@ -80,6 +78,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.error(e);
|
LOG.error(e);
|
||||||
}
|
}
|
||||||
return bmp;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue