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

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

Location:
trunk/src/org/openstreetmap/josm/data/imagery
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r8404 r8418  
    198198    /** icon used in menu */
    199199    private String icon;
    200     // when adding a field, also adapt the ImageryInfo(ImageryInfo) constructor
    201     private Map<String, String> noTileHeaders;
     200    // when adding a field, also adapt the ImageryInfo(ImageryInfo) constructor, equals method, and ImageryPreferenceEntry
    202201
    203202    /**
     
    228227        @pref Map<String, String> noTileHeaders;
    229228        @pref int tileSize = OsmMercator.DEFAUL_TILE_SIZE;
     229        @pref Map<String, String> metadataHeaders;
    230230
    231231        /**
     
    285285            }
    286286
     287            if (i.metadataHeaders != null && !i.metadataHeaders.isEmpty()) {
     288                metadataHeaders = i.metadataHeaders;
     289            }
     290
    287291            tileSize = i.getTileSize();
    288292        }
     
    408412        }
    409413        setTileSize(e.tileSize);
     414        metadataHeaders = e.metadataHeaders;
    410415    }
    411416
     
    436441        this.icon = i.icon;
    437442        this.description = i.description;
     443        this.noTileHeaders = i.noTileHeaders;
     444        this.metadataHeaders = i.metadataHeaders;
    438445    }
    439446
     
    465472            return false;
    466473        }
    467         if (!Objects.equals(this.name, other.name)) {
    468             return false;
    469         }
    470         if (!Objects.equals(this.id, other.id)) {
    471             return false;
    472         }
    473         if (!Objects.equals(this.url, other.url)) {
    474             return false;
    475         }
    476         if (!Objects.equals(this.cookies, other.cookies)) {
    477             return false;
    478         }
    479         if (!Objects.equals(this.eulaAcceptanceRequired, other.eulaAcceptanceRequired)) {
    480             return false;
    481         }
    482         if (this.imageryType != other.imageryType) {
    483             return false;
    484         }
    485         if (this.defaultMaxZoom != other.defaultMaxZoom) {
    486             return false;
    487         }
    488         if (this.defaultMinZoom != other.defaultMinZoom) {
    489             return false;
    490         }
    491         if (!Objects.equals(this.bounds, other.bounds)) {
    492             return false;
    493         }
    494         if (!Objects.equals(this.serverProjections, other.serverProjections)) {
    495             return false;
    496         }
    497         if (!Objects.equals(this.attributionText, other.attributionText)) {
    498             return false;
    499         }
    500         if (!Objects.equals(this.attributionLinkURL, other.attributionLinkURL)) {
    501             return false;
    502         }
    503         if (!Objects.equals(this.attributionImage, other.attributionImage)) {
    504             return false;
    505         }
    506         if (!Objects.equals(this.attributionImageURL, other.attributionImageURL)) {
    507             return false;
    508         }
    509         if (!Objects.equals(this.termsOfUseText, other.termsOfUseText)) {
    510             return false;
    511         }
    512         if (!Objects.equals(this.termsOfUseURL, other.termsOfUseURL)) {
    513             return false;
    514         }
    515         if (!Objects.equals(this.countryCode, other.countryCode)) {
    516             return false;
    517         }
    518         if (!Objects.equals(this.icon, other.icon)) {
    519             return false;
    520         }
    521         if (!Objects.equals(this.description, other.description)) {
    522             return false;
    523         }
    524         return true;
     474
     475        return
     476                Objects.equals(this.name, other.name) &&
     477                Objects.equals(this.id, other.id) &&
     478                Objects.equals(this.url, other.url) &&
     479                Objects.equals(this.cookies, other.cookies) &&
     480                Objects.equals(this.eulaAcceptanceRequired, other.eulaAcceptanceRequired) &&
     481                Objects.equals(this.imageryType, other.imageryType) &&
     482                Objects.equals(this.defaultMaxZoom, other.defaultMaxZoom) &&
     483                Objects.equals(this.defaultMinZoom, other.defaultMinZoom) &&
     484                Objects.equals(this.bounds, other.bounds) &&
     485                Objects.equals(this.serverProjections, other.serverProjections) &&
     486                Objects.equals(this.attributionText, other.attributionText) &&
     487                Objects.equals(this.attributionLinkURL, other.attributionLinkURL) &&
     488                Objects.equals(this.attributionImageURL, other.attributionImageURL) &&
     489                Objects.equals(this.attributionImage, other.attributionImage) &&
     490                Objects.equals(this.termsOfUseText, other.termsOfUseText) &&
     491                Objects.equals(this.termsOfUseURL, other.termsOfUseURL) &&
     492                Objects.equals(this.countryCode, other.countryCode) &&
     493                Objects.equals(this.icon, other.icon) &&
     494                Objects.equals(this.description, other.description) &&
     495                Objects.equals(this.noTileHeaders, other.noTileHeaders) &&
     496                Objects.equals(this.metadataHeaders, other.metadataHeaders);
    525497    }
    526498
     
    10581030        return noTileHeaders;
    10591031    }
     1032
     1033    public void setMetadataHeaders(Map<String, String> metadataHeaders) {
     1034        this.metadataHeaders = metadataHeaders;
     1035    }
    10601036}
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java

    r8349 r8418  
    150150        for (ImageryInfo def : defaultLayers) {
    151151            // temporary migration code, so all user preferences will get updated with new settings from JOSM site (can be removed ~Dez. 2015)
    152             if (def.getNoTileHeaders() != null || def.getTileSize() > 0) {
     152            if (def.getNoTileHeaders() != null || def.getTileSize() > 0 || def.getMetadataHeaders() != null ) {
    153153                for (ImageryInfo i: layers) {
    154154                    if (isSimilar(def,  i)) {
     
    158158                        if (def.getTileSize() > 0) {
    159159                            i.setTileSize(def.getTileSize());
     160                        }
     161                        if (def.getMetadataHeaders() != null && def.getMetadataHeaders().size() > 0) {
     162                            i.setMetadataHeaders(def.getMetadataHeaders());
    160163                        }
    161164                        changed = true;
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r8403 r8418  
    1010import java.util.List;
    1111import java.util.Map;
     12import java.util.Map.Entry;
    1213import java.util.Set;
    1314import java.util.concurrent.ConcurrentHashMap;
     
    133134    @Override
    134135    protected boolean cacheAsEmpty(Map<String, List<String>> headers, int statusCode, byte[] content) {
     136        // cacheAsEmpty is called for every successful download, so we can put
     137        // metadata handling here
     138        attributes.setMetadata(tile.getTileSource().getMetadata(headers));
    135139        if (tile.getTileSource().isNoTileAtZoom(headers, statusCode, content)) {
    136140            attributes.setNoTileAtZoom(true);
     
    166170            if(!tile.isLoaded()) { //if someone else already loaded tile, skip all the handling
    167171                tile.finishLoading(); // whatever happened set that loading has finished
     172                // set tile metadata
     173                if (this.attributes != null) {
     174                    for (Entry<String, String> e: this.attributes.getMetadata().entrySet()) {
     175                        tile.putValue(e.getKey(), e.getValue());
     176                    }
     177                }
     178
    168179                switch(result){
    169180                case SUCCESS:
     
    214225        if (isObjectLoadable()) {
    215226            try {
     227                // set tile metadata
     228                if (this.attributes != null) {
     229                    for (Entry<String, String> e: this.attributes.getMetadata().entrySet()) {
     230                        tile.putValue(e.getKey(), e.getValue());
     231                    }
     232                }
     233
    216234                if (data != null && data.getImage() != null) {
    217235                    tile.setImage(data.getImage());
Note: See TracChangeset for help on using the changeset viewer.