Ignore:
Timestamp:
2013-08-21T02:04:20+02:00 (7 years ago)
Author:
Don-vip
Message:

see #8987 - refactor/add missing distance() methods to fix broken plugins

Location:
trunk/src/org/openstreetmap/josm/data/coor
Files:
3 edited

Legend:

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

    r6165 r6166  
    4040
    4141    /**
     42     * Returns the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}.
     43     *
     44     * @param coor the specified coordinate to be measured against this {@code Coordinate}
     45     * @return the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}
     46     * @since 6166
     47     */
     48    protected final double distance(final Coordinate coor) {
     49        return distance(coor.x, coor.y);
     50    }
     51   
     52    /**
     53     * Returns the euclidean distance from this {@code Coordinate} to a specified coordinate.
     54     *
     55     * @param px the X coordinate of the specified point to be measured against this {@code Coordinate}
     56     * @param py the Y coordinate of the specified point to be measured against this {@code Coordinate}
     57     * @return the euclidean distance from this {@code Coordinate} to a specified coordinate
     58     * @since 6166
     59     */
     60    public final double distance(final double px, final double py) {
     61        final double dx = this.x-px;
     62        final double dy = this.y-py;
     63        return Math.sqrt(dx*dx + dy*dy);
     64    }
     65   
     66    /**
    4267     * Returns the square of the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}.
    4368     *
    4469     * @param coor the specified coordinate to be measured against this {@code Coordinate}
    4570     * @return the square of the euclidean distance from this {@code Coordinate} to a specified {@code Coordinate}
     71     * @since 6166
    4672     */
    47     public double distanceSq(final Coordinate coor) {
    48         final double dx = this.x-coor.x;
    49         final double dy = this.y-coor.y;
     73    protected final double distanceSq(final Coordinate coor) {
     74        return distanceSq(coor.x, coor.y);
     75    }
     76
     77    /**
     78     * Returns the square of euclidean distance from this {@code Coordinate} to a specified coordinate.
     79     *
     80     * @param px the X coordinate of the specified point to be measured against this {@code Coordinate}
     81     * @param py the Y coordinate of the specified point to be measured against this {@code Coordinate}
     82     * @return the square of the euclidean distance from this {@code Coordinate} to a specified coordinate
     83     * @since 6166
     84     */
     85    public final double distanceSq(final double px, final double py) {
     86        final double dx = this.x-px;
     87        final double dy = this.y-py;
    5088        return dx*dx + dy*dy;
    5189    }
  • trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java

    r6165 r6166  
    4545
    4646    /**
    47      * Counts euclidean distance between this and other EastNorth.
     47     * Returns the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}.
    4848     *
    49      * @param en2 other EastNorth
    50      * @return distance between this and other EastNorth
     49     * @param en the specified coordinate to be measured against this {@code EastNorth}
     50     * @return the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}
     51     * @since 6166
    5152     */
    52     public double distance(final EastNorth en2) {
    53         final double dx = this.x-en2.x;
    54         final double dy = this.y-en2.y;
    55         return Math.sqrt(dx*dx + dy*dy);
     53    public double distance(final EastNorth en) {
     54        return super.distance(en);
     55    }
     56   
     57    /**
     58     * Returns the square of the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}.
     59     *
     60     * @param en the specified coordinate to be measured against this {@code EastNorth}
     61     * @return the square of the euclidean distance from this {@code EastNorth} to a specified {@code EastNorth}
     62     * @since 6166
     63     */
     64    public double distanceSq(final EastNorth en) {
     65        return super.distanceSq(en);
    5666    }
    5767
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r6162 r6166  
    2727 */
    2828public class LatLon extends Coordinate {
    29 
    3029
    3130    /**
     
    298297
    299298    /**
    300      * Counts euclidean distance between this and other LatLon.
     299     * Returns the euclidean distance from this {@code LatLon} to a specified {@code LatLon}.
    301300     *
    302      * @param ll2 other LatLon
    303      * @return distance between this and other LatLon
    304      */
    305    public double distance(final LatLon ll2) {
    306         final double dx = this.x-ll2.x;
    307         final double dy = this.y-ll2.y;
    308         return Math.sqrt(dx*dx + dy*dy);
    309     }
    310 
     301     * @param ll the specified coordinate to be measured against this {@code LatLon}
     302     * @return the euclidean distance from this {@code LatLon} to a specified {@code LatLon}
     303     * @since 6166
     304     */
     305    public double distance(final LatLon ll) {
     306        return super.distance(ll);
     307    }
     308   
     309    /**
     310     * Returns the square of the euclidean distance from this {@code LatLon} to a specified {@code LatLon}.
     311     *
     312     * @param ll the specified coordinate to be measured against this {@code LatLon}
     313     * @return the square of the euclidean distance from this {@code LatLon} to a specified {@code LatLon}
     314     * @since 6166
     315     */
     316    public double distanceSq(final LatLon ll) {
     317        return super.distanceSq(ll);
     318    }
     319   
    311320    @Override public String toString() {
    312321        return "LatLon[lat="+lat()+",lon="+lon()+"]";
Note: See TracChangeset for help on using the changeset viewer.