Fix Mapbox rester image api url. Add support for hightDPI. (#1873)

* Fix Mapbox rester image api url. Add support for hightDPI.

According to the MapBox raster images API docs here:
https://docs.mapbox.com/api/maps/raster-tiles/

The url for this api has changed to
https://api.mapbox.com/v4/{tileset_id}/{zoom}/{x}/{y}{@2x}.{format}

* small change to retrigger merge check.

---------

Co-authored-by: xyz32 <xyz.relativity@gmail.com>
This commit is contained in:
Radu 2023-03-31 18:56:56 -04:00 committed by GitHub
parent ddfef5ec55
commit 5cdc4e21f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,10 +24,11 @@ public class MapBoxTileSource extends OnlineTileSourceBase {
private static final String ACCESS_TOKEN = "MAPBOX_ACCESS_TOKEN";
private static final String[] mapBoxBaseUrl = new String[]{
"https://api.mapbox.com/styles/v1/mapbox/"};
"https://api.mapbox.com/v4/"};
private String mapBoxMapId = "";
private String accessToken;
private String highDPI = "";
/**
* Creates a MapBox TileSource. You won't be able to use it until you set the access token and map id.
@ -124,18 +125,17 @@ public class MapBoxTileSource extends OnlineTileSourceBase {
public String getTileURLString(final long pMapTileIndex) {
StringBuilder url = new StringBuilder(getBaseUrl());
url.append(getMapBoxMapId());
url.append("/tiles/");
url.append("/");
url.append(MapTileIndex.getZoom(pMapTileIndex));
url.append("/");
url.append(MapTileIndex.getX(pMapTileIndex));
url.append("/");
url.append(MapTileIndex.getY(pMapTileIndex));
//url.append(".png");
//url.append("@2x"); //for high-res?
url.append(highDPI); //for high-DPI
url.append(mImageFilenameEnding);
url.append("?access_token=").append(getAccessToken());
String res = url.toString();
return res;
return url.toString();
}
public String getAccessToken() {
@ -145,4 +145,12 @@ public class MapBoxTileSource extends OnlineTileSourceBase {
public void setAccessToken(String accessTokeninput) {
accessToken = accessTokeninput;
}
public void enableHighDPI(boolean isHighDPI) {
if (isHighDPI) {
highDPI = "@2x";
} else {
highDPI = "";
}
}
}