Skip to content

Commit

Permalink
Revert "[GEOT-6608] Fix user-agent for OSM tiles (#2954)" (#3185)
Browse files Browse the repository at this point in the history
This reverts commit d311d23.
  • Loading branch information
ianturton committed Oct 21, 2020
1 parent 49bd332 commit f523b2a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.geotools.data.ows.HTTPClient;
import org.geotools.data.ows.SimpleHttpClient;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.image.io.ImageIOExt;
import org.geotools.util.logging.Logging;
Expand Down Expand Up @@ -176,19 +171,8 @@ public BufferedImage getBufferedImage() {
}
}

@Override
public BufferedImage loadImageTileImage(Tile tile) throws IOException {

Map<String, String> headers = new HashMap<>();
headers.put("User-Agent", "Geotools Http client");
try (InputStream is = setupInputStream(getUrl(), headers)) {
return ImageIOExt.readBufferedImage(is);
}
}

private InputStream setupInputStream(URL url, Map<String, String> headers) throws IOException {
HTTPClient client = new SimpleHttpClient();
return client.get(url, headers).getResponseStream();
return ImageIOExt.readBufferedImage(getUrl());
}

/**
Expand Down Expand Up @@ -388,7 +372,6 @@ public boolean equals(Object other) {
return getUrl().equals(((Tile) other).getUrl());
}

@Override
public String toString() {
return this.getId(); // this.getUrl().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
*/
package org.geotools.tile.impl.osm;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.awt.image.BufferedImage;
import java.io.IOException;
import org.geotools.tile.Tile;
import org.geotools.tile.TileService;
import org.geotools.tile.impl.WebMercatorZoomLevel;
Expand Down Expand Up @@ -54,17 +49,4 @@ public void testGetURL() {
Assert.assertEquals(
"http://tile.openstreetmap.org/5/10/12.png", this.tile.getUrl().toString());
}

/**
* Make sure we can actually fetch the image of the tile for display.
*
* @throws IOException
*/
@Test
public void testFetchTile() throws IOException {
BufferedImage img = tile.loadImageTileImage(tile);
assertNotNull(img);
assertEquals("wrong height", OSMTile.DEFAULT_TILE_SIZE, img.getHeight());
assertEquals("wrong width", OSMTile.DEFAULT_TILE_SIZE, img.getWidth());
}
}

0 comments on commit f523b2a

Please sign in to comment.