Ignore:
Timestamp:
2019-01-03T20:06:44+01:00 (5 years ago)
Author:
simon04
Message:

fix #16706 - Zoom to selection should not zoom out for zoom on a node

Simplify bound enlargements in org.openstreetmap.josm.actions.AutoScaleAction#modeSelectionOrConflict

File:
1 edited

Legend:

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

    r12818 r14628  
    192192        return !Utils.equalsEpsilon(minEast, maxEast) || !Utils.equalsEpsilon(minNorth, maxNorth);
    193193    }
     194
     195    /**
     196     * Computes the scale of this bounds with respect to the given width/height.
     197     * @param width the width
     198     * @param height the height
     199     * @return the computed scale
     200     */
     201    public double getScale(final int width, final int height) {
     202        // -20 to leave some border
     203        int w = width - 20;
     204        if (w < 20) {
     205            w = 20;
     206        }
     207        int h = height - 20;
     208        if (h < 20) {
     209            h = 20;
     210        }
     211
     212        double scaleX = getDeltaEast() / w;
     213        double scaleY = getDeltaNorth() / h;
     214        return Math.max(scaleX, scaleY);
     215    }
     216
     217    private double getDeltaNorth() {
     218        return maxNorth - minNorth;
     219    }
     220
     221    private double getDeltaEast() {
     222        return maxEast - minEast;
     223    }
    194224}
Note: See TracChangeset for help on using the changeset viewer.