Changeset 24544 in osm for applications


Ignore:
Timestamp:
2010-12-03T04:37:35+01:00 (14 years ago)
Author:
yellowbkpk
Message:

Adding per-layer max zoom for TMS layers.

Location:
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryInfo.java

    r24501 r24544  
    3131    ImageryType imageryType = ImageryType.WMS;
    3232    double pixelPerDegree = 0.0;
     33    int maxZoom = 0;
    3334
    3435    public ImageryInfo(String name) {
     
    6667        if(url != null && !url.isEmpty()) e2 = getFullURL();
    6768        if(cookies != null && !cookies.isEmpty()) e3 = cookies;
    68         if(pixelPerDegree != 0.0) e4 = String.valueOf(pixelPerDegree);
     69        if(imageryType == ImageryType.WMS) {
     70            if(pixelPerDegree != 0.0) e4 = String.valueOf(pixelPerDegree);
     71        } else {
     72            if(maxZoom != 0) e4 = String.valueOf(maxZoom);
     73        }
    6974        if(e4 != null && e3 == null) e3 = "";
    7075        if(e3 != null && e2 == null) e2 = "";
     
    8388        if(array.size() >= 2) setURL(array.get(1));
    8489        if(array.size() >= 3) this.cookies=array.get(2);
    85         if(array.size() >= 4) this.pixelPerDegree=Double.valueOf(array.get(3));
     90        if(imageryType == ImageryType.WMS && array.size() >= 4) this.pixelPerDegree=Double.valueOf(array.get(3));
     91        if(imageryType == ImageryType.TMS && array.size() >= 4) this.maxZoom=Integer.valueOf(array.get(3));
    8692    }
    8793
     
    148154    }
    149155
     156    public int getMaxZoom() {
     157        return this.maxZoom;
     158    }
     159
    150160    public String getFullURL() {
    151161        return imageryType.getUrlString() + ":" + url;
     
    165175        if(pixelPerDegree != 0.0)
    166176            res += " ("+pixelPerDegree+")";
     177        else if(maxZoom != 0)
     178            res += " (z"+maxZoom+")";
    167179        return res;
    168180    }
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferenceEditor.java

    r24521 r24544  
    4040import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    4141import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     42import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType;
    4243import org.openstreetmap.josm.plugins.imagery.tms.TMSPreferences;
    4344import org.openstreetmap.josm.plugins.imagery.wms.AddWMSLayerPanel;
     
    7374            public String getToolTipText(MouseEvent e) {
    7475                java.awt.Point p = e.getPoint();
    75                 return (String) model.getValueAt(rowAtPoint(p), columnAtPoint(p));
     76                return model.getValueAt(rowAtPoint(p), columnAtPoint(p)).toString();
    7677            }
    7778        };
     
    397398                return info.getFullURL();
    398399            case 2:
    399                 return info.pixelPerDegree == 0.0 ? "" : info.pixelPerDegree;
     400                return (info.imageryType == ImageryType.WMS) ? (info.pixelPerDegree == 0.0 ? "" : info.pixelPerDegree)
     401                                                             : (info.maxZoom == 0 ? "" : info.maxZoom);
    400402            }
    401403            return null;
     
    410412            case 1:
    411413                info.setURL((String)o);
     414            case 2:
     415                if(info.imageryType == ImageryType.WMS)
     416                    info.pixelPerDegree = Double.parseDouble((String) o);
     417                else
     418                    info.maxZoom = Integer.parseInt((String) o);
    412419            }
    413420        }
     
    415422        @Override
    416423        public boolean isCellEditable(int row, int column) {
    417             return (column != 2);
     424            return true;
    418425        }
    419426    }
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSLayer.java

    r24541 r24544  
    183183
    184184        if (info.getImageryType() == ImageryType.TMS) {
    185             initTileSource(new TMSTileSource(info.getName(),info.getURL()));
     185            if(isUrlWithPatterns(info.getURL())) {
     186                initTileSource(new TemplatedTMSTileSource(info.getName(), info.getURL(), info.getMaxZoom()));
     187            } else {
     188                initTileSource(new TMSTileSource(info.getName(),info.getURL(), info.getMaxZoom()));
     189            }
    186190        } else if (info.getImageryType() == ImageryType.BING) {
    187191            initTileSource(new BingAerialTileSource());
     
    358362            }
    359363        });
     364    }
     365
     366    public static boolean isUrlWithPatterns(String url) {
     367        return url != null && url.contains("{") && url.contains("}");
    360368    }
    361369
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSPreferences.java

    r24536 r24544  
    5959            maxZoomLvl = PROP_MIN_ZOOM_LVL.get();
    6060        }
    61         if (ts != null && ts.getMaxZoom() < maxZoomLvl) {
    62             System.err.println("decreasing maxZoomLvl to match tile source");
     61        if (ts != null && ts.getMaxZoom() != 0) {
    6362            maxZoomLvl = ts.getMaxZoom();
    6463        }
  • applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSTileSource.java

    r24536 r24544  
    44
    55public class TMSTileSource extends OsmTileSource.AbstractOsmTileSource {
    6     public TMSTileSource(String name, String url) {
     6    private int maxZoom;
     7
     8    public TMSTileSource(String name, String url, int maxZoom) {
    79        super(name, url);
     10        this.maxZoom = maxZoom;
    811    }
     12
     13    @Override
     14    public int getMaxZoom() {
     15        return (maxZoom == 0) ? super.getMaxZoom() : maxZoom;
     16    }
     17
    918    @Override
    1019    public TileUpdate getTileUpdate() {
Note: See TracChangeset for help on using the changeset viewer.