下载OSM磁片,连接复位对等



我一直在尝试下载OSM Tiles用于基于固定区域的离线使用,并且代码已经工作了一段时间。

然而,我最近一直面临这个错误:

ERROR(8936): recvfrom failed: ECONNRESET (Connection reset by peer)

我只是想知道这是由于OSM的服务器问题,还是某种类型的低效编码约定导致了这个问题?

这些是我的下载代码:

for (int y = placeTopLeft.getYTile(); y <= placeBottomLeft.getYTile(); y++){
    for(int x = placeTopLeft.getXTile(); x <= placeBottomRight.getXTile(); x++){
        try {
            String urlStr = "http://a.tile.openstreetmap.org/"+ v +"/"+x+"/"+y+".png";
            URL url = new URL(urlStr);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            InputStream in = new BufferedInputStream(urlConnection.getInputStream());
            File newFileDir = new File(Environment.getExternalStorageDirectory().toString() 
                                + "/test/"+ tID+ "/"+v+"/"+x);
            newFileDir.mkdirs();
            File newFile = new File(newFileDir, y+".png");
            OutputStream output = new FileOutputStream(newFile);
            int read;
            while ((read = in.read()) != -1) {
                output.write(read);
                output.flush();
            }
            urlConnection.disconnect();
        } catch (Exception e) {
            mNotificationHelper.cancelled();
            Log.e("URL::: ERROR", e.getMessage());
            e.printStackTrace();
        }
        loopCount++;
        publishProgress( (int) ((loopCount/totalLoopCount) * 100 ) );
    }
}

让我知道如果我错过了任何其他细节,以便更清楚地展示这个错误,谢谢!

你看过你之前买的瓷砖吗?它们是真正的地砖吗?当我使用a.tile.openstreetmap.org, b.tile.openstreetmap.org或c.tile.openstreetmap.org时,很快瓷砖只显示开放街道地图徽标和消息"此应用程序因过度使用....而被阻止。我们的服务器"。

最新更新