Changeset 31142 in osm


Ignore:
Timestamp:
2015-05-23T00:47:24+02:00 (9 years ago)
Author:
wiktorn
Message:

Add posibility to display HTTP headers in Show Tile Info dialog. Closes #josm11456

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java

    r31127 r31142  
    336336
    337337    public Map<String,String> getMetadata() {
     338        if (metadata == null) {
     339            metadata = new HashMap<>();
     340        }
    338341        return metadata;
    339342    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java

    r31122 r31142  
    7373    /**
    7474     * A unique id for this tile source.
    75      * 
     75     *
    7676     * Unlike the name it has to be unique and has to consist only of characters
    7777     * valid for filenames.
    78      * 
     78     *
    7979     * @return the id
    8080     */
     
    169169     */
    170170    public boolean isNoTileAtZoom(Map<String, List<String>> headers, int statusCode, byte[] content);
     171
     172    /**
     173     * Extracts metadata about the tile based on HTTP headers
     174     *
     175     * @param headers HTTP headers from Tile Source server
     176     * @return tile metadata
     177     */
     178    public Map<String, String> getMetadata(Map<String, List<String>> headers);
    171179}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java

    r31133 r31142  
    33
    44import java.io.IOException;
     5import java.util.HashMap;
    56import java.util.List;
    67import java.util.Map;
     
    1516    protected String id;
    1617    private Map<String, String> noTileHeaders;
     18    private Map<String, String> metadataHeaders;
    1719    protected int tileSize;
    1820    protected OsmMercator osmMercator;
     
    2628        this.id = info.getUrl();
    2729        this.noTileHeaders = info.getNoTileHeaders();
     30        this.metadataHeaders = info.getMetadataHeaders();
    2831        this.tileSize = info.getTileSize();
    2932        osmMercator = new OsmMercator(this.tileSize);
     
    149152        return super.isNoTileAtZoom(headers, statusCode, content);
    150153    }
     154
     155    @Override
     156    public Map<String, String> getMetadata(Map<String, List<String>> headers) {
     157        Map<String, String> ret = new HashMap<>();
     158        if (metadataHeaders != null && headers != null) {
     159            for (Entry<String, String> searchEntry: metadataHeaders.entrySet()) {
     160                List<String> headerVals = headers.get(searchEntry.getKey());
     161                if (headerVals != null) {
     162                    for (String headerValue: headerVals) {
     163                        ret.put(searchEntry.getValue(), headerValue);
     164                    }
     165                }
     166            }
     167        }
     168        return ret;
     169    }
    151170}
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TileSourceInfo.java

    r31125 r31142  
    1919
    2020    /** headers meaning, that there is no tile at this zoom level */
    21     protected Map<String, String> notileHeaders;
     21    protected Map<String, String> noTileHeaders;
    2222
    2323    /** minimum zoom level supported by the tile source */
     
    3232    /** tile size of the displayed tiles */
    3333    private int tileSize = OsmMercator.DEFAUL_TILE_SIZE;
     34
     35    /** mapping <header key, metadata key> */
     36    protected Map<String, String> metadataHeaders;
    3437
    3538    /**
     
    8285     */
    8386    public Map<String, String> getNoTileHeaders() {
    84         return notileHeaders;
     87        return noTileHeaders;
    8588    }
    8689
     
    127130        this.tileSize = tileSize;
    128131    }
     132
     133    public Map<String, String> getMetadataHeaders() {
     134        return metadataHeaders;
     135    }
    129136}
Note: See TracChangeset for help on using the changeset viewer.