Changeset 13387 in josm for trunk


Ignore:
Timestamp:
2018-02-06T23:39:53+01:00 (6 years ago)
Author:
Don-vip
Message:

see #15880 - nicer exception

Location:
trunk/src/org/openstreetmap/josm
Files:
5 edited

Legend:

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

    r13119 r13387  
    720720    @Override
    721721    public int getTileSize() {
    722         // no support for non-square tiles (tileHeight != tileWidth)
    723         // and for different tile sizes at different zoom levels
    724         Collection<Layer> projLayers = getLayers(null, tileProjection.toCode());
    725         if (!projLayers.isEmpty()) {
    726             return projLayers.iterator().next().tileMatrixSet.tileMatrix.get(0).tileHeight;
     722        if (tileProjection != null) {
     723            // no support for non-square tiles (tileHeight != tileWidth)
     724            // and for different tile sizes at different zoom levels
     725            Collection<Layer> projLayers = getLayers(null, tileProjection.toCode());
     726            if (!projLayers.isEmpty()) {
     727                return projLayers.iterator().next().tileMatrixSet.tileMatrix.get(0).tileHeight;
     728            }
    727729        }
    728730        // if no layers is found, fallback to default mercator tile size. Maybe it will work
     
    10591061    @Override
    10601062    public String getServerCRS() {
    1061         return tileProjection.toCode();
     1063        return tileProjection != null ? tileProjection.toCode() : null;
    10621064    }
    10631065}
  • trunk/src/org/openstreetmap/josm/gui/MapViewState.java

    r13181 r13387  
    159159    }
    160160
     161    @Override
     162    public String toString() {
     163        return getClass().getName() + " [projecting=" + this.projecting
     164            + " viewWidth=" + this.viewWidth
     165            + " viewHeight=" + this.viewHeight
     166            + " scale=" + this.scale
     167            + " topLeft=" + this.topLeft + ']';
     168    }
     169
    161170    /**
    162171     * The scale in east/north units per pixel.
     
    762771            return null;
    763772        }
    764     }
    765 
     773
     774        @Override
     775        public String toString() {
     776            return "MapViewRectangle [p1=" + p1 + ", p2=" + p2 + ']';
     777        }
     778    }
    766779}
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r13386 r13387  
    14181418        if (coordinateConverter.requiresReprojection()) {
    14191419            Projection projServer = Projections.getProjectionByCode(tileSource.getServerCRS());
     1420            if (projServer == null) {
     1421                throw new IllegalStateException(tileSource.toString());
     1422            }
    14201423            ProjectionBounds projBounds = new ProjectionBounds(
    14211424                    CoordinateConversion.projToEn(topLeftUnshifted),
     
    18891892            try {
    18901893                drawInViewArea(graphics.getDefaultGraphics(), graphics.getMapView(), graphics.getClipBounds().getProjectionBounds());
    1891             } catch (IllegalArgumentException e) {
     1894            } catch (IllegalArgumentException | IllegalStateException e) {
    18921895                throw BugReport.intercept(e)
    18931896                               .put("graphics", graphics).put("tileSource", tileSource).put("currentZoomLevel", currentZoomLevel);
  • trunk/src/org/openstreetmap/josm/gui/layer/MapViewGraphics.java

    r10458 r13387  
    6060        return clipBounds;
    6161    }
     62
     63    @Override
     64    public String toString() {
     65        return "MapViewGraphics [graphics=" + graphics + ", mapView=" + mapView + ", clipBounds=" + clipBounds + ']';
     66    }
    6267}
  • trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileCoordinateConverter.java

    r12669 r13387  
    202202     */
    203203    public boolean requiresReprojection() {
    204         return !tileSource.getServerCRS().equals(Main.getProjection().toCode());
     204        return !Objects.equals(tileSource.getServerCRS(), Main.getProjection().toCode());
    205205    }
    206206}
Note: See TracChangeset for help on using the changeset viewer.