Changeset 14507 in josm


Ignore:
Timestamp:
2018-12-04T01:45:45+01:00 (6 years ago)
Author:
Don-vip
Message:

see #16073 - test tile source

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r14273 r14507  
    335335        if (this.layers.isEmpty())
    336336            throw new IllegalArgumentException(tr("No layers defined by getCapabilities document: {0}", info.getUrl()));
     337    }
     338
     339    /**
     340     * Creates a tile source based on imagery info and initializes it with given projection.
     341     * @param info imagery info
     342     * @param projection projection to be used by this TileSource
     343     * @throws IOException if any I/O error occurs
     344     * @throws WMTSGetCapabilitiesException when document didn't contain any layers
     345     * @throws IllegalArgumentException if any other error happens for the given imagery info
     346     * @since 14507
     347     */
     348    public WMTSTileSource(ImageryInfo info, Projection projection) throws IOException, WMTSGetCapabilitiesException {
     349        this(info);
     350        initProjection(projection);
    337351    }
    338352
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

    r14499 r14507  
    1616import org.junit.Rule;
    1717import org.junit.Test;
     18import org.openstreetmap.gui.jmapviewer.TileXY;
     19import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
    1820import org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource;
    1921import org.openstreetmap.gui.jmapviewer.tilesources.BingAerialTileSource;
    2022import org.openstreetmap.gui.jmapviewer.tilesources.ScanexTileSource;
    2123import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
     24import org.openstreetmap.josm.data.coor.LatLon;
     25import org.openstreetmap.josm.data.imagery.CoordinateConversion;
    2226import org.openstreetmap.josm.data.imagery.ImageryInfo;
     27import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds;
    2328import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
    2429import org.openstreetmap.josm.data.imagery.TemplatedWMSTileSource;
     
    7378    }
    7479
     80    private void checkTileUrl(ImageryInfo info, AbstractTileSource tileSource, ICoordinate center, int zoom)
     81            throws IOException {
     82        TileXY xy = tileSource.latLonToTileXY(center, zoom);
     83        checkUrl(info, tileSource.getTileUrl(zoom, xy.getXIndex(), xy.getYIndex()));
     84    }
     85
    7586    private void checkEntry(ImageryInfo info) {
    7687        Logging.info("Checking "+ info);
     
    90101
    91102        try {
    92             getTileSource(info);
     103            ImageryBounds bounds = info.getBounds();
     104            ICoordinate center = CoordinateConversion.llToCoor(bounds != null ? bounds.getCenter() : LatLon.ZERO);
     105            AbstractTileSource tileSource = getTileSource(info);
     106            checkTileUrl(info, tileSource, center, info.getMinZoom());
     107            checkTileUrl(info, tileSource, center, info.getMaxZoom());
    93108        } catch (IOException | WMTSGetCapabilitiesException | IllegalArgumentException e) {
    94109            addError(info, e.toString());
     
    113128                return new WMSEndpointTileSource(info, ProjectionRegistry.getProjection());
    114129            case WMTS:
    115                 return new WMTSTileSource(info);
     130                return new WMTSTileSource(info, ProjectionRegistry.getProjection());
    116131            default:
    117132                throw new UnsupportedOperationException(info.toString());
Note: See TracChangeset for help on using the changeset viewer.