Changeset 9123 in josm for trunk/src/org


Ignore:
Timestamp:
2015-12-14T23:11:44+01:00 (4 years ago)
Author:
bastiK
Message:

make sure the scale ("circum") is never 0 (but positive) (see #12186)

File:
1 edited

Legend:

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

    r9122 r9123  
    206206    }
    207207
     208    /**
     209     * Get the distance in meter that correspond to 100 px on screen.
     210     *
     211     * @return the distance in meter that correspond to 100 px on screen
     212     */
    208213    public double getDist100Pixel() {
     214        return getDist100Pixel(true);
     215    }
     216
     217    /**
     218     * Get the distance in meter that correspond to 100 px on screen.
     219     *
     220     * @param alwaysPositive if true, makes sure the return value is always
     221     * > 0. (Two points 100 px apart can appear to be identical if the user
     222     * has zoomed out a lot and the projection code does something funny.)
     223     * @return the distance in meter that correspond to 100 px on screen
     224     */
     225    public double getDist100Pixel(boolean alwaysPositive) {
    209226        int w = getWidth()/2;
    210227        int h = getHeight()/2;
    211228        LatLon ll1 = getLatLon(w-50, h);
    212229        LatLon ll2 = getLatLon(w+50, h);
    213         return ll1.greatCircleDistance(ll2);
     230        double gcd = ll1.greatCircleDistance(ll2);
     231        if (alwaysPositive && gcd <= 0)
     232            return 0.1;
     233        return gcd;
    214234    }
    215235
Note: See TracChangeset for help on using the changeset viewer.