Changeset 16636 in josm


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

Update TemplatedWMSTileSourceTest, WMSEndpointTileSourceTest for increased precision of AbstractWMSTileSource.SCALE_DENOMINATOR_ZOOM_LEVEL_1

Location:
trunk/test/unit/org/openstreetmap/josm/data/imagery
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java

    r16635 r16636  
    132132
    133133        verifyTileSquareness(source, 0, 1, 4);
    134         verifyLocation(source, new LatLon(60, 18.1), 3);
    135         verifyLocation(source, new LatLon(60, 18.1));
     134        verifyLocation(source, new LatLon(60, 18.05008), 3);
     135        verifyLocation(source, new LatLon(60, 18.05008));
    136136    }
    137137
     
    171171        TemplatedWMSTileSource ts = new TemplatedWMSTileSource(testImageryWMS, projection);
    172172        assertEquals("https://maps.six.nsw.gov.au/arcgis/services/public/NSW_Imagery_Dates/MapServer/WMSServer?SERVICE=WMS&"
    173                 + "VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&BBOX=-1349.9999381,539.9999691,-989.9999536,899.9999536&WIDTH=512&"
     173                + "VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&BBOX=-1350.0000000,540.0000000,-990.0000000,900.0000000&WIDTH=512&"
    174174                + "HEIGHT=512&LAYERS=0&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE",
    175175                ts.getTileUrl(1, 2, 3));
    176176        assertEquals("https://maps.six.nsw.gov.au/arcgis/services/public/NSW_Imagery_Dates/MapServer/WMSServer?SERVICE=WMS&"
    177                 + "VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&BBOX=-89.9999923,-0.0000077,0.0000039,89.9999884&WIDTH=512&HEIGHT=512&"
     177                + "VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&BBOX=-90.0000000,0.0000000,-0.0000000,90.0000000&WIDTH=512&HEIGHT=512&"
    178178                + "LAYERS=0&STYLES=&FORMAT=image/png32&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE",
    179179                ts.getTileUrl(3, 2, 1));
     
    188188        assertEquals("https://services.slip.wa.gov.au/public/services/SLIP_Public_Services/Transport/MapServer/WMSServer?LAYERS=8&"
    189189                + "TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG:4326&"
    190                 + "BBOX=539.9999691,-1349.9999381,899.9999536,-989.9999536&WIDTH=512&HEIGHT=512",
     190                + "BBOX=540.0000000,-1350.0000000,900.0000000,-990.0000000&WIDTH=512&HEIGHT=512",
    191191                ts.getTileUrl(1, 2, 3));
    192192        assertEquals("https://services.slip.wa.gov.au/public/services/SLIP_Public_Services/Transport/MapServer/WMSServer?LAYERS=8&"
    193193                + "TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&FORMAT=image%2Fpng&SRS=EPSG:4326&"
    194                 + "BBOX=-0.0000077,-89.9999923,89.9999884,0.0000039&WIDTH=512&HEIGHT=512", ts.getTileUrl(3, 2, 1));
     194                + "BBOX=0.0000000,-90.0000000,90.0000000,-0.0000000&WIDTH=512&HEIGHT=512", ts.getTileUrl(3, 2, 1));
    195195    }
    196196
     
    231231                tileIndex.getYIndex() <= source.getTileYMax(z));
    232232
    233         EastNorth locationEN = projection.latlon2eastNorth(location);
    234         EastNorth x1 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex, z));
    235         EastNorth x2 = projection.latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z));
     233        ICoordinate x1 = source.tileXYToLatLon(tileIndex.getXIndex(), tileIndex.getYIndex(), z);
     234        ICoordinate x2 = source.tileXYToLatLon(tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z);
     235        if (x1.getLon() > x2.getLon()) {
     236            x2.setLon(180);
     237        }
     238        Bounds bounds = new Bounds(x1.getLat(), x1.getLon(), true);
     239        bounds.extend(x2.getLat(), x2.getLon());
    236240        // test that location is within tile bounds
    237         assertTrue(locationEN.toString() + " not within " + bboxStr(x1, x2) +
    238                 " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex(),
    239                 isWithin(locationEN, x1, x2));
     241        assertTrue(location + " not within " + bounds + " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex(),
     242                bounds.contains(location));
    240243        verifyTileSquareness(source, tileIndex.getXIndex(), tileIndex.getYIndex(), z);
    241     }
    242 
    243     private static boolean isWithin(EastNorth point, EastNorth topLeft, EastNorth bottomRight) {
    244         return Math.min(topLeft.east(), bottomRight.east()) <= point.east() &&
    245                 point.east() <= Math.max(topLeft.east(), bottomRight.east()) &&
    246                 Math.min(topLeft.north(), bottomRight.north()) <= point.north() &&
    247                 point.north() <= Math.max(topLeft.north(), bottomRight.north());
    248     }
    249 
    250     private static String bboxStr(EastNorth x1, EastNorth x2) {
    251         return "[" + x1.east() +", " + x1.north() + ", " + x2.east() + ", " + x2.north() +"]";
    252     }
    253 
    254     private LatLon getTileLatLon(TemplatedWMSTileSource source, TileXY tileIndex, int z) {
    255         return getTileLatLon(source, tileIndex.getXIndex(), tileIndex.getYIndex(), z);
    256244    }
    257245
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java

    r16424 r16636  
    8383                + "REQUEST=GetMap&LAYERS=single_node_in_way&STYLES=default&"
    8484                + "CRS=EPSG:3857&WIDTH=512&HEIGHT=512&"
    85                 + "BBOX=20037506.6204108,-60112521.5836107,60112521.5836107,-20037506.6204108", tileSource.getTileUrl(1, 1, 1));
     85                + "BBOX=20037508.3427893,-60112525.0283678,60112525.0283678,-20037508.3427893", tileSource.getTileUrl(1, 1, 1));
    8686    }
    8787
     
    141141                + "WIDTH=512&"
    142142                + "HEIGHT=512&"
    143                 + "BBOX=20037506.6204108,-60112521.5836107,60112521.5836107,-20037506.6204108",
     143                + "BBOX=20037508.3427893,-60112525.0283678,60112525.0283678,-20037508.3427893",
    144144                tileSource.getTileUrl(1, 1, 1));
    145145    }
Note: See TracChangeset for help on using the changeset viewer.