Changeset 9946 in josm


Ignore:
Timestamp:
2016-03-07T19:10:03+01:00 (8 years ago)
Author:
wiktorn
Message:

Fix NPE's when unsupported projection used with WMTS

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r9914 r9946  
    203203        if (nativeScaleLayer != null) {
    204204            ScaleList scaleList = nativeScaleLayer.getNativeScales();
    205             if (PROP_ZOOM_INTERMEDIATE_STEPS.get()) {
    206                 scaleList = scaleList.withIntermediateSteps(PROP_ZOOM_RATIO.get());
    207             }
    208             Scale s = scaleList.scaleZoomTimes(getScale(), PROP_ZOOM_RATIO.get(), times);
    209             return s != null ? s.getScale() : 0;
    210         } else {
    211             return getScale() * Math.pow(PROP_ZOOM_RATIO.get(), times);
    212         }
     205            if (scaleList != null) {
     206                if ( PROP_ZOOM_INTERMEDIATE_STEPS.get()) {
     207                    scaleList = scaleList.withIntermediateSteps(PROP_ZOOM_RATIO.get());
     208                }
     209                Scale s = scaleList.scaleZoomTimes(getScale(), PROP_ZOOM_RATIO.get(), times);
     210                return s != null ? s.getScale() : 0;
     211            }
     212        }
     213        return getScale() * Math.pow(PROP_ZOOM_RATIO.get(), times);
    213214    }
    214215
     
    244245        if (nativeScaleLayer != null) {
    245246            ScaleList scaleList = nativeScaleLayer.getNativeScales();
    246             Scale snapscale = scaleList.getSnapScale(scale, PROP_ZOOM_RATIO.get(), floor);
    247             return snapscale != null ? snapscale.getScale() : scale;
    248         } else {
    249             return scale;
    250         }
     247            if (scaleList != null) {
     248                Scale snapscale = scaleList.getSnapScale(scale, PROP_ZOOM_RATIO.get(), floor);
     249                return snapscale != null ? snapscale.getScale() : scale;
     250            }
     251        }
     252        return scale;
    251253    }
    252254
  • trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java

    r9914 r9946  
    6262        if (!Main.isDisplayingMapView())
    6363            return 0;
    64         Scale snap = getNativeScales().getSnapScale(Main.map.mapView.getScale(), false);
     64        ScaleList scaleList = getNativeScales();
     65        Scale snap = null;
     66        if (scaleList == null) {
     67            return getMaxZoomLvl();
     68        }
     69        snap = scaleList.getSnapScale(Main.map.mapView.getScale(), false);
    6570        return Math.max(
    6671                getMinZoomLvl(),
Note: See TracChangeset for help on using the changeset viewer.