Changeset 18762 in osm for applications


Ignore:
Timestamp:
2009-11-23T17:07:50+01:00 (15 years ago)
Author:
stoecker
Message:

fix josm bug 3294

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java

    r18761 r18762  
    8787        WMSGrabber.getProjection(baseURL, true);
    8888        mv = Main.map.mapView;
     89
     90        // quick hack to predefine the PixelDensity to reuse the cache
     91        int codeIndex = getName().indexOf("#PPD=");
     92        if (codeIndex != -1) {
     93            pixelPerDegree = Double.valueOf(getName().substring(codeIndex+5));
     94        } else {
     95            pixelPerDegree = getPPD();
     96        }
    8997        resolution = mv.getDist100PixelText();
    9098        pixelPerDegree = getPPD();
     
    117125        try {
    118126            executor.shutdownNow();
    119             // Might not be initalized, so catch NullPointer as well
     127            // Might not be initialized, so catch NullPointer as well
    120128        } catch(Exception x) {
    121129            x.printStackTrace();
     
    269277                new JMenuItem(new LoadWmsAction()),
    270278                new JMenuItem(new SaveWmsAction()),
     279                new JMenuItem(new BookmarkWmsAction()),
    271280                new JSeparator(),
    272281                startstop,
     
    318327            // Delete small files, because they're probably blank tiles.
    319328            // See https://josm.openstreetmap.de/ticket/2307
    320             WMSPlugin.cache.customCleanUp(CacheFiles.CLEAN_SMALL_FILES, 2048);
     329            WMSPlugin.cache.customCleanUp(CacheFiles.CLEAN_SMALL_FILES, 4096);
    321330
    322331            for (int x = 0; x < dax; ++x) {
     
    428437        }
    429438    }
     439    /**
     440     * This action will add a WMS layer menu entry with the current WMS layer URL and name extended by the current resolution.
     441     * When using the menu entry again, the WMS cache will be used properly.
     442     */
     443    public class BookmarkWmsAction extends AbstractAction {
     444        public BookmarkWmsAction() {
     445            super(tr("Set WMS Bookmark"));
     446        }
     447        public void actionPerformed(ActionEvent ev) {
     448            int i = 0;
     449            while (Main.pref.hasKey("wmsplugin.url."+i+".url")) {
     450                i++;
     451            }
     452            String baseName;
     453            // cut old parameter
     454            int parameterIndex = getName().indexOf("#PPD=");
     455            if (parameterIndex != -1) {
     456                baseName = getName().substring(0,parameterIndex);
     457            }
     458            else {
     459                baseName = getName();
     460            }
     461            Main.pref.put("wmsplugin.url."+ i +".url",baseURL );
     462            Main.pref.put("wmsplugin.url."+String.valueOf(i)+".name", baseName + "#" + getPPD() );
     463            WMSPlugin.refreshMenu();
     464        }
     465    }
    430466}
Note: See TracChangeset for help on using the changeset viewer.