This commit is contained in:
simon 2020-09-07 17:32:21 +03:00
parent 150e769709
commit 08ab7a6613
2 changed files with 6 additions and 8 deletions

View file

@ -40,6 +40,10 @@ public class OsmAndHttpServer extends NanoHTTPD {
return getStatic(uri);
}
public String getUrl() {
return "http://" + getHostname() + ":" + getListeningPort();
}
private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) {
String uri = session.getUri();
for (String path : endpoints.keySet()) {
@ -102,10 +106,6 @@ public class OsmAndHttpServer extends NanoHTTPD {
return type;
}
public String getUrl() {
return "http://" + getHostname() + ":" + getListeningPort();
}
public interface ApiEndpoint {
NanoHTTPD.Response process(NanoHTTPD.IHTTPSession session);
}

View file

@ -20,9 +20,9 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
private static final int TILE_SIZE_PX = 512;
private static final int TIMEOUT_STEP = 500;
private static final Log LOG = PlatformUtil.getLog(TileEndpoint.class);
private final MapActivity mapActivity;
private RotatedTileBox resultBmpViewport;
private Bitmap resultBitmap;
private MapActivity mapActivity;
public TileEndpoint(MapActivity mapActivity) {
this.mapActivity = mapActivity;
@ -48,7 +48,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
if (bitmap == null) {
return OsmAndHttpServer.ErrorResponses.response500;
}
//stream also needs to be synchronized
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
@ -68,7 +67,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
.setZoom(zoom)
.setPixelDimensions(TILE_SIZE_PX, TILE_SIZE_PX, 0.5f, 0.5f).build();
mapActivity.getMapView().setCurrentViewport(rotatedTileBox);
Bitmap bmp = null;
int timeout = 0;
try {
while (!rotatedTileBox.equals(resultBmpViewport) && timeout < SOCKET_READ_TIMEOUT) {
@ -80,6 +78,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile
} catch (InterruptedException e) {
LOG.error(e);
}
return bmp;
return null;
}
}