Skip to content

Commit

Permalink
Downloading satellite maps
Browse files Browse the repository at this point in the history
  • Loading branch information
shinovon committed Jun 23, 2023
1 parent 482f8d6 commit c1d66d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/mahomaps/map/MapState.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public MapState Clone() {
ms.xOffset = xOffset;
ms.yOffset = yOffset;
ms.zoom = zoom;
ms.map = map;
return ms;
}

Expand All @@ -63,6 +64,7 @@ public MapState ZoomIn() {
ms.tileY = tileY * 2;
ms.xOffset = xOffset * 2;
ms.yOffset = yOffset * 2;
ms.map = map;
ms.ClampOffset();
return ms;
}
Expand All @@ -76,6 +78,7 @@ public MapState ZoomOut() {
ms.tileY = tileY / 2;
ms.xOffset = (xOffset - (tileX % 2 == 1 ? 256 : 0)) / 2;
ms.yOffset = (yOffset - (tileY % 2 == 1 ? 256 : 0)) / 2;
ms.map = map;
ms.ClampOffset();
return ms;
}
Expand Down
8 changes: 3 additions & 5 deletions src/mahomaps/map/TilesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,7 @@ private Image download(TileId id) throws InterruptedException {
FileConnection fc = null;
try {
hc = (HttpConnection) Connector.open(getUrl(id) + MahoMapsApp.getConnectionParams());
int len = (int) hc.getLength();
if (len <= 0)
throw new IOException("Empty response");
ByteArrayOutputStream blob = new ByteArrayOutputStream(len);
ByteArrayOutputStream blob = new ByteArrayOutputStream();
byte[] buf = new byte[8192];
InputStream s = hc.openInputStream();
while (true) {
Expand Down Expand Up @@ -570,7 +567,8 @@ public TileCache getTile(TileId tileId) {
}

private String getUrl(TileId tileId) {
String url = "https://core-renderer-tiles.maps.yandex.net/tiles?l=map&lang=" + lang + "&x=" + tileId.x + "&y="
String url = (tileId.map == 0 ? "https://core-renderer-tiles.maps.yandex.net/tiles?l=map&lang=" : "https://core-sat.maps.yandex.net/tiles?l=sat&lang=")
+ lang + "&x=" + tileId.x + "&y="
+ tileId.y + "&z=" + tileId.zoom;
if (Settings.proxyTiles) {
return Settings.proxyServer + YmapsApiBase.EncodeUrl(url);
Expand Down

0 comments on commit c1d66d2

Please sign in to comment.