Changeset 16308 in osm for applications


Ignore:
Timestamp:
2009-07-04T20:28:12+02:00 (15 years ago)
Author:
stoecker
Message:

modernized WMS plugin, many settings of older WMS will need some adjustment

Location:
applications/editors/josm/plugins/wmsplugin
Files:
1 deleted
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/build.xml

    r16290 r16308  
    1616    </target>
    1717    <target name="dist" depends="compile,revision">
    18         <copy todir="${plugin.build.dir}/resources">
    19             <fileset dir="resources"/>
    20         </copy>
    2118        <copy todir="${plugin.build.dir}/images">
    2219            <fileset dir="images"/>
  • applications/editors/josm/plugins/wmsplugin/sources.cfg

    r15725 r16308  
    33# NOTE: default items should be common and worldwide
    44#
    5 true;Landsat;http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&format=image/jpeg
    6 true;Open Aerial Map;http://openaerialmap.org/wms/?VERSION=1.0&request=GetMap&layers=world&styles=&format=image/jpeg
     5true;Landsat;http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&format=image/jpeg&
     6true;Open Aerial Map;http://openaerialmap.org/wms/?VERSION=1.0&request=GetMap&layers=world&styles=&format=image/jpeg&
    77# fails with division by zero error
    8 false;NPE Maps;http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe
     8false;NPE Maps;http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe&
    99false;NPE Maps (Tim);http://dev.openstreetmap.org/~timsc/wms2/map.php?
    10 # different forms for Yahoo
    11 # must be yahoo://<commandline>
    12 # The {0} in the commandline is for the URL
    13 # output must be on stdout
    14 false;YAHOO (GNOME);yahoo://gnome-web-photo --mode=photo --format=png {0} /dev/stdout
    15 false;YAHOO (GNOME Fix);yahoo://gnome-web-photo-fixed {0}
    16 true;YAHOO (WebKit);yahoo://webkit-image {0}
    17 false;YAHOO (WebKit GTK);yahoo://webkit-image-gtk {0}
     10#
     11# different forms for web access
     12# must be html:<url>
     13true;Yahoo Sat;html:http://josm.openstreetmap.org/wmsplugin/Yahoo.html?
     14false;OpenStreetMap;html:http://josm.openstreetmap.org/wmsplugin/OpenStreetMap.html?
     15false;OpenCycleMap;html:http://josm.openstreetmap.org/wmsplugin/OpenCycleMap.html?
     16false;TilesAtHome;html:http://josm.openstreetmap.org/wmsplugin/TilesAtHome.html?
     17#
     18#
    1819# only for Germany
    19 false;Oberpfalz Geofabrik.de;http://oberpfalz.geofabrik.de/wms4josm?
    20 false;Streets NRW Geofabrik.de;http://tools.geofabrik.de/osmi/view/strassennrw/josmwms
    21 # Terraserver USCG- High resolution maps
    22 false;Terraserver Topo;http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=drg&styles=&format=image/jpeg
    23 true;Terraserver Urban;http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=urbanarea&styles=&format=image/jpeg
     20false;Streets NRW Geofabrik.de;http://tools.geofabrik.de/osmi/view/strassennrw/josmwms?
     21# Terraserver USCG - High resolution maps
     22false;Terraserver Topo;http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=drg&styles=&format=image/jpeg&
     23false;Terraserver Urban;http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=urbanarea&styles=&format=image/jpeg&
     24#
     25#
     26# URLS must be designed to append arguments directly behind. So the URLS should either end with '?' or '&'
     27# Following arguments are added: width, height, bbox, srs (projection method)
     28# srs is only added when no srs is given already (In this case the projection is checked
     29# and an error is issued when they mismatch).
     30#
     31# If more specific URL design is needed, then patterns are supported as well. If
     32# patterns are found no other arguments are added:
     33# {srs} is replaced by projection
     34# {bbox} is replaced by bounding box using projected coordinates
     35# {width} is requested display width
     36# {height} is requested display height
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/HTMLGrabber.java

    r16302 r16308  
    1010import javax.imageio.ImageIO;
    1111
     12import org.openstreetmap.josm.Main;
    1213import org.openstreetmap.josm.data.ProjectionBounds;
    1314import org.openstreetmap.josm.gui.MapView;
    1415import org.openstreetmap.josm.io.CacheFiles;
    1516
    16 
    17 public class YAHOOGrabber extends WMSGrabber {
    18     protected String browserCmd;
    19 
    20     YAHOOGrabber(ProjectionBounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
     17public class HTMLGrabber extends WMSGrabber {
     18    HTMLGrabber(ProjectionBounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
    2119        super(b, image, mv, layer, cache);
    22         this.baseURL = "file:///" + WMSPlugin.getPrefsPath() + "ymap.html?";
    23         this.browserCmd = layer.baseURL.replaceFirst("yahoo://", "");
     20        this.baseURL = layer.baseURL.replaceFirst("html:", "");
    2421    }
    2522
     
    2724    protected BufferedImage grab(URL url) throws IOException {
    2825        String urlstring = url.toExternalForm();
    29         // work around a problem in URL removing 2 slashes
    30         if(!urlstring.startsWith("file:///"))
    31             urlstring = urlstring.replaceFirst("file:", "file://");
    3226
    3327        BufferedImage cached = cache.getImg(urlstring);
     
    3529
    3630        ArrayList<String> cmdParams = new ArrayList<String>();
    37         StringTokenizer st = new StringTokenizer(MessageFormat.format(browserCmd, urlstring));
     31        StringTokenizer st = new StringTokenizer(MessageFormat.format(
     32        Main.pref.get("wmsplugin.browser", "webkit-image {0}"), urlstring));
    3833        while( st.hasMoreTokens() )
    3934            cmdParams.add(st.nextToken());
    4035
    41         System.out.println("WMS::Browsing YAHOO: " + cmdParams);
    4236        ProcessBuilder builder = new ProcessBuilder( cmdParams);
    4337
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java

    r15858 r16308  
    1919
    2020    public void actionPerformed(ActionEvent e) {
    21         System.out.println(info.url);
     21        //System.out.println(info.url);
    2222
    2323        WMSLayer wmsLayer = new WMSLayer(info.name, info.url, info.cookies);
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java

    r16290 r16308  
    4343        this.baseURL = layer.baseURL;
    4444        /* URL containing placeholders? */
    45         urlWithPatterns = baseURL != null && baseURL.contains("{1}");
     45        urlWithPatterns = baseURL != null && baseURL.contains("{") && baseURL.contains("}");
    4646    }
    4747
     
    6262            image.max = b.max;
    6363
    64 System.out.println(url + " " + b + " " + image.min + " " + image.max);
    6564            if(image.isVisible(mv)) { //don't download, if the image isn't visible already
    6665                image.image = grab(url);
     
    8180        if(Main.proj instanceof Mercator) // don't use mercator code directly
    8281        {
    83             LatLon sw = Main.proj.eastNorth2latlon(new EastNorth(s, w));
    84             LatLon ne = Main.proj.eastNorth2latlon(new EastNorth(n, e));
     82            LatLon sw = Main.proj.eastNorth2latlon(new EastNorth(w, s));
     83            LatLon ne = Main.proj.eastNorth2latlon(new EastNorth(e, n));
    8584            proj = "EPSG:4326";
    8685            s = sw.lat();
     
    8988            e = ne.lon();
    9089        }
    91 /*        else if(!(Main.proj instanceof Epsg4326))
    92         {
    93             EastNorth sw = Main.proj.latlon2eastNorth(new LatLon(s, w));
    94             EastNorth ne = Main.proj.latlon2eastNorth(new LatLon(n, e));
    95             s = sw.north();
    96             w = sw.east();
    97             n = ne.north();
    98             e = ne.east();
    99         }
    100 */
     90
    10191        String str = baseURL;
    10292        String bbox = latLonFormat.format(w) + ","
     
    10696
    10797        if (urlWithPatterns) {
    108             str = MessageFormat.format(str, proj, bbox, wi, ht);
     98            str = str.replaceAll("{proj}", proj)
     99            .replaceAll("{bbox}", bbox)
     100            .replaceAll("{width}", String.valueOf(wi))
     101            .replaceAll("{height}", String.valueOf(ht));
    109102        } else {
    110             if(!str.endsWith("?"))
     103            if(!str.contains("?"))
     104                str += "?";
     105            else if(!str.endsWith("?"))
    111106                str += "&";
    112107            str += "bbox="
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java

    r16290 r16308  
    4848
    4949    public WMSPlugin() {
    50         try
    51         {
    52             copy("/resources/ymap.html", "ymap.html");
    53         }
    54         catch(IOException e) {
    55             e.printStackTrace();
    56         }
    5750        refreshMenu();
    5851        cache.setExpire(cache.EXPIRE_MONTHLY, false);
     
    190183
    191184    public static Grabber getGrabber(ProjectionBounds bounds, GeorefImage img, MapView mv, WMSLayer layer){
    192         if(layer.baseURL.startsWith("yahoo://"))
    193             return new YAHOOGrabber(bounds, img, mv, layer, cache);
     185        if(layer.baseURL.startsWith("html:"))
     186            return new HTMLGrabber(bounds, img, mv, layer, cache);
    194187        else
    195188            return new WMSGrabber(bounds, img, mv, layer, cache);
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java

    r16290 r16308  
    1717import javax.swing.Box;
    1818import javax.swing.JButton;
     19import javax.swing.JComboBox;
    1920import javax.swing.JLabel;
    2021import javax.swing.JOptionPane;
     
    3233    private Map<String,String> orig;
    3334    private DefaultTableModel model;
     35    private JComboBox browser;
    3436    private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>();
    3537
     
    6971                JPanel p = new JPanel(new GridBagLayout());
    7072                p.add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0));
    71                 JTextField key = new JTextField(10);
    72                 JTextField value = new JTextField(10);
     73                JTextField key = new JTextField(40);
     74                JTextField value = new JTextField(40);
    7375                p.add(key, GBC.eop().insets(5,0,0,0).fill(GBC.HORIZONTAL));
    7476                p.add(new JLabel(tr("WMS URL")), GBC.std().insets(0,0,5,0));
     
    113115        p.add(buttonPanel);
    114116        p.add(Box.createHorizontalGlue(), GBC.eol().fill(GBC.HORIZONTAL));
     117        browser = new JComboBox(new String[]{
     118        "webkit-image {0}",
     119        "gnome-web-photo --mode=photo --format=png {0} /dev/stdout",
     120        "gnome-web-photo-fixed {0}",
     121        "webkit-image-gtk {0}"});
     122        browser.setEditable(true);
     123        browser.setSelectedItem(Main.pref.get("wmsplugin.browser", "webkit-image {0}"));
     124        p.add(new JLabel(tr("Downloader:")), GBC.eol().fill(GBC.HORIZONTAL));
     125        p.add(browser, GBC.eol().fill(GBC.HORIZONTAL));
    115126    }
    116127
     
    152163        if (change) WMSPlugin.refreshMenu();
    153164
     165        Main.pref.put("wmsplugin.browser", browser.getEditor().getItem().toString());
    154166        return false;
    155167    }
Note: See TracChangeset for help on using the changeset viewer.