Ignore:
Timestamp:
2017-04-28T12:16:33+02:00 (3 years ago)
Author:
bastiK
Message:

see #11889 - backport improved version of Math.toDegrees and Math.toRadians from Java 9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r11893 r12013  
    9393    private static final String[] SIZE_UNITS = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
    9494
     95    private static final double TO_DEGREES = 180.0 / Math.PI;
     96    private static final double TO_RADIANS = Math.PI / 180.0;
     97
    9598    private Utils() {
    9699        // Hide default constructor for utils classes
     
    12851288     * Returns a new secure DOM builder, supporting XML namespaces.
    12861289     * @return a new secure DOM builder, supporting XML namespaces
    1287      * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
    12881290     * @throws ParserConfigurationException if a parser cannot be created which satisfies the requested configuration.
    12891291     * @since 10404
     
    15531555        }
    15541556    }
     1557
     1558    /**
     1559     * Convert angle from radians to degrees.
     1560     *
     1561     * Replacement for {@link Math#toDegrees(double)} to match the Java 9
     1562     * version of that method. (Can be removed when JOSM support for Java 8 ends.)
     1563     * Only relevant in relation to ProjectionRegressionTest.
     1564     * @see https://josm.openstreetmap.de/ticket/11889
     1565     * @param angleRad an angle in radians
     1566     * @return the same angle in degrees
     1567     */
     1568    public static double toDegrees(double angleRad) {
     1569        return angleRad * TO_DEGREES;
     1570    }
     1571
     1572    /**
     1573     * Convert angle from degrees to radians.
     1574     *
     1575     * Replacement for {@link Math#toRadians(double)} to match the Java 9
     1576     * version of that method. (Can be removed when JOSM support for Java 8 ends.)
     1577     * Only relevant in relation to ProjectionRegressionTest.
     1578     * @see https://josm.openstreetmap.de/ticket/11889
     1579     * @param angleDeg an angle in degrees
     1580     * @return the same angle in radians
     1581     */
     1582    public static double toRadians(double angleDeg) {
     1583        return angleDeg * TO_RADIANS;
     1584    }
    15551585}
Note: See TracChangeset for help on using the changeset viewer.