diff --git a/OsmAnd/src/net/osmand/plus/server/ApiRouter.java b/OsmAnd/src/net/osmand/plus/server/ApiRouter.java index 3cbb192cb5..4f9e047290 100644 --- a/OsmAnd/src/net/osmand/plus/server/ApiRouter.java +++ b/OsmAnd/src/net/osmand/plus/server/ApiRouter.java @@ -9,10 +9,7 @@ import android.webkit.MimeTypeMap; import androidx.core.util.Pair; import com.google.gson.Gson; import fi.iki.elonen.NanoHTTPD; -import net.osmand.data.FavouritePoint; -import net.osmand.data.GeometryTile; -import net.osmand.data.QuadPointDouble; -import net.osmand.data.QuadRect; +import net.osmand.data.*; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; import net.osmand.plus.OsmandApplication; @@ -28,6 +25,7 @@ import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Scanner; import static fi.iki.elonen.NanoHTTPD.newFixedLengthResponse; @@ -63,11 +61,29 @@ public class ApiRouter { @Override public NanoHTTPD.Response call(NanoHTTPD.IHTTPSession session) { try{ + int zoom = 0; + double lat = 0;//50.901430; + double lon = 0;//34.801775; + try{ + String fullUri = session.getUri().replace("/tile/",""); + Scanner s = new Scanner(fullUri).useDelimiter("/"); + zoom = s.nextInt(); + lat = s.nextDouble();//50.901430; + lon = s.nextDouble();//34.801775; + } + catch (Exception e){ + e.printStackTrace(); + return ErrorResponses.response500; + } + Log.d("TILE","HAVING VALUES" + zoom + " " + lat + " " + lon); ITileSource map = TileSourceManager.getMapillaryVectorSource(); Bitmap bitmap = Bitmap.createBitmap(512,512,Bitmap.Config.ARGB_8888);//mapActivity.getMapView().currentCanvas; //OsmandMapTileView tileView = new OsmandMapTileView(mapActivity,300,300); OsmandMapTileMiniView tileView = new OsmandMapTileMiniView(androidContext,512,512); Canvas canvas = new Canvas(bitmap); + RotatedTileBox tileBox = tileView.getCurrentRotatedTileBox(); + tileBox.setLatLonCenter(lat,lon); + tileBox.setZoom(zoom); LayersDraw.createLayers(androidContext,canvas, tileView); Paint p = new Paint(); p.setStyle(Paint.Style.FILL_AND_STROKE); @@ -148,6 +164,10 @@ public class ApiRouter { private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) { String uri = session.getUri(); + //TODO rewrite + if (uri.contains("tile")){ + return endpoints.get("/tile").apiCall.call(session); + } ApiEndpoint endpoint = endpoints.get(uri); if (endpoint != null){ return endpoint.apiCall.call(session); @@ -157,7 +177,8 @@ public class ApiRouter { private boolean isApiUrl(String uri) { for (String endpoint : endpoints.keySet()){ - if (endpoint.equals(uri)) return true; + //TODO rewrite contains + if (endpoint.equals(uri) || uri.contains("tile")) return true; } return false; } diff --git a/OsmAnd/src/net/osmand/plus/server/map/LayersDraw.java b/OsmAnd/src/net/osmand/plus/server/map/LayersDraw.java index 6b3e3e2e80..77997d48df 100644 --- a/OsmAnd/src/net/osmand/plus/server/map/LayersDraw.java +++ b/OsmAnd/src/net/osmand/plus/server/map/LayersDraw.java @@ -25,6 +25,11 @@ public class LayersDraw { //mapView.addLayer(contextMenuLayer, 8); // mapView.addLayer(underlayLayer, -0.5f); RotatedTileBox currentTileBlock = mapView.getCurrentRotatedTileBox(); +// RotatedTileBox currentTileBlock = new RotatedTileBox.RotatedTileBoxBuilder() +// .setLocation(50.901430, 34.801775) +// .setZoom(15) +// .setPixelDimensions(canvas.getWidth(), canvas.getHeight(), 0.5f, 0.5f).build(); + MapTileMiniLayer mapTileLayer = new MapTileMiniLayer(true); mapView.addLayer(mapTileLayer, 0.0f); diff --git a/OsmAnd/src/net/osmand/plus/server/map/MapVectorMiniLayer.java b/OsmAnd/src/net/osmand/plus/server/map/MapVectorMiniLayer.java index ac08833d00..5837ced8be 100644 --- a/OsmAnd/src/net/osmand/plus/server/map/MapVectorMiniLayer.java +++ b/OsmAnd/src/net/osmand/plus/server/map/MapVectorMiniLayer.java @@ -183,11 +183,7 @@ public class MapVectorMiniLayer extends OsmandMapMiniLayer { MapRenderRepositories renderer = resourceManager.getRenderer(); - //RotatedTileBox currentTileBlock = tilesRect; - RotatedTileBox currentTileBlock = new RotatedTileBox.RotatedTileBoxBuilder() - .setLocation(50.901430, 34.801775) - .setZoom(15) - .setPixelDimensions(canvas.getWidth(), canvas.getHeight(), 0.5f, 0.5f).build(); + RotatedTileBox currentTileBlock = tilesRect; resourceManager.getRenderer().loadMap(currentTileBlock, resourceManager.getMapTileDownloader()); drawRenderedMap(canvas, renderer.getBitmap(), renderer.getBitmapLocation(), tilesRect); drawRenderedMap(canvas, renderer.getPrevBitmap(), renderer.getPrevBmpLocation(), tilesRect);