Ignore:
Timestamp:
2017-09-05T18:22:22+02:00 (7 years ago)
Author:
bastiK
Message:

revert last commit - still used in many plugins

File:
1 edited

Legend:

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

    r12736 r12737  
    348348        }
    349349        return d;
     350    }
     351
     352    /**
     353     * Returns the heading that you have to use to get from this lat/lon to another.
     354     *
     355     * Angle starts from north and increases counterclockwise (!), PI/2 means west.
     356     * You can get usual clockwise angle from {@link #bearing(LatLon)} method.
     357     * This method is kept as deprecated because it is called from many plugins.
     358     *
     359     * (I don't know the original source of this formula, but see
     360     * <a href="https://math.stackexchange.com/questions/720/how-to-calculate-a-heading-on-the-earths-surface">this question</a>
     361     * for some hints how it is derived.)
     362     *
     363     * @deprecated see bearing method
     364     * @param other the "destination" position
     365     * @return heading in radians in the range 0 &lt;= hd &lt; 2*PI
     366     */
     367    @Deprecated
     368    public double heading(LatLon other) {
     369        double hd = atan2(sin(toRadians(this.lon() - other.lon())) * cos(toRadians(other.lat())),
     370                cos(toRadians(this.lat())) * sin(toRadians(other.lat())) -
     371                sin(toRadians(this.lat())) * cos(toRadians(other.lat())) * cos(toRadians(this.lon() - other.lon())));
     372        hd %= 2 * PI;
     373        if (hd < 0) {
     374            hd += 2 * PI;
     375        }
     376        return hd;
    350377    }
    351378
Note: See TracChangeset for help on using the changeset viewer.