Changeset 16734 in josm


Ignore:
Timestamp:
2020-07-06T17:44:17+02:00 (4 weeks ago)
Author:
simon04
Message:

fix #19483 - Remote control /imagery: parse extended URL (parse imagery type from URL)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java

    r16589 r16734  
    5353
    5454    protected ImageryInfo buildImageryInfo() {
    55         args.computeIfAbsent("type", ignore -> ImageryType.WMS.getDefault().getTypeString());
     55        ImageryInfo fromExtendedUrl = new ImageryInfo("", args.get("url"));
     56        args.put("url", fromExtendedUrl.getUrl());
     57        args.computeIfAbsent("min_zoom", ignore -> String.valueOf(fromExtendedUrl.getMinZoom()));
     58        args.computeIfAbsent("max_zoom", ignore -> String.valueOf(fromExtendedUrl.getMaxZoom()));
     59        args.computeIfAbsent("type", ignore -> fromExtendedUrl.getSourceType().getTypeString());
    5660        args.computeIfAbsent("name", ignore -> args.getOrDefault("title", tr("Remote imagery")));
    5761        ImageryPreferenceEntry imageryPreferenceEntry = StructUtils.deserializeStruct(args, ImageryPreferenceEntry.class);
     
    101105        return new String[] {
    102106            "/imagery?title=osm&type=tms&url=https://a.tile.openstreetmap.org/%7Bzoom%7D/%7Bx%7D/%7By%7D.png",
     107            "/imagery?url=[0-19]https://a.tile.openstreetmap.org/%7Bzoom%7D/%7Bx%7D/%7By%7D.png",
    103108            "/imagery?title=landsat&type=wms&url=http://irs.gis-lab.info/?" +
    104109                    "layers=landsat&SRS=%7Bproj%7D&WIDTH=%7Bwidth%7D&HEIGHT=%7Bheight%7D&BBOX=%7Bbbox%7D",
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandlerTest.java

    r16618 r16734  
    104104        assertEquals("XA", imageryInfo.getCountryCode());
    105105    }
     106
     107    /**
     108     * Non-regression test for bug #19483.
     109     * @throws Exception if any error occurs
     110     */
     111    @Test
     112    public void testTicket19483() throws Exception {
     113        String url = "https://localhost/imagery?url=" +
     114                "tms[3-7]%3Ahttps%3A%2F%2Fservices.digitalglobe.com%2Fearthservice%2Ftmsaccess%2F" +
     115                "tms%2F1.0.0%2FDigitalGlobe%3AImageryTileService%40EPSG%3A3857%40jpg%2F%7Bz%7D%2F%7Bx%7D%2F%7B-y%7D.jpg%3F" +
     116                "connectId%3D0123456789";
     117        ImageryInfo imageryInfo = newHandler(url).buildImageryInfo();
     118        assertEquals(ImageryInfo.ImageryType.TMS, imageryInfo.getImageryType());
     119        assertEquals("https://services.digitalglobe.com/earthservice/tmsaccess/tms/1.0.0/DigitalGlobe:ImageryTileService" +
     120                "@EPSG:3857@jpg/{z}/{x}/{-y}.jpg?connectId=0123456789", imageryInfo.getUrl());
     121        assertEquals("tms[3,7]:https://services.digitalglobe.com/earthservice/tmsaccess/tms/1.0.0/DigitalGlobe:ImageryTileService" +
     122                "@EPSG:3857@jpg/{z}/{x}/{-y}.jpg?connectId=0123456789", imageryInfo.getExtendedUrl());
     123        assertEquals(3, imageryInfo.getMinZoom());
     124        assertEquals(7, imageryInfo.getMaxZoom());
     125    }
    106126}
Note: See TracChangeset for help on using the changeset viewer.