Я только что попробовал ваш код и мой старый просмотрщик плиток, который раньше работал, и я получаю ту же ошибку, что и вы. Я попытался повысить уровень ведения журнала, но это не имело никакого значения для сообщения об ошибке!
Похоже, что что-то изменилось в Java 8 ImageIO или в том, как OSM обслуживает листы.
Я попробовал следующий код:
URL url = new URL("https://tile.openstreetmap.org/1/1/0.png");
Iterator<ImageReader> itr = ImageIO.getImageReadersByFormatName("png");
while (itr.hasNext()) {
ImageReader next = itr.next();
System.out.println(next.getFormatName());
next.setInput(url.openStream());
BufferedImage img = next.read(0);
}
, который дает мне:
Oct 30, 2019 5:45:18 PM sun.net.www.protocol.http.HttpURLConnection writeRequests
FINE: sun.net.www.MessageHeader@2974f2215 pairs: {GET /1/1/0.png HTTP/1.1: null}{User-Agent: Java/1.8.0_222}{Host: tile.openstreetmap.org}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}
Oct 30, 2019 5:45:18 PM sun.net.www.protocol.http.HttpURLConnection getInputStream0
FINE: sun.net.www.MessageHeader@58fe04997 pairs: {null: HTTP/1.1 429 Too Many Requests}{Server: nginx}{Date: Wed, 30 Oct 2019 17:45:18 GMT}{Content-Type: text/html}{Content-Length: 162}{Connection: keep-alive}{Strict-Transport-Security: max-age=31536000; includeSubDomains; preload}
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 429 for URL: https://tile.openstreetmap.org/1/1/0.png
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268)
at java.net.URL.openStream(URL.java:1057)
at spike.OsmMapFrame.main(OsmMapFrame.java:32)
Ясно, что что-то не так, но я не уверен, что.