Ignore:
Timestamp:
2008-12-23T15:07:05+01:00 (14 years ago)
Author:
stoecker
Message:

removed usage of tab stops

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

Legend:

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

    r1094 r1169  
    77/**
    88 * Base class of points of both coordinate systems.
    9  * 
    10  * The variables are default package protected to allow routines in the 
     9 *
     10 * The variables are default package protected to allow routines in the
    1111 * data package to access them directly.
    12  * 
    13  * As the class itself is package protected too, it is not visible 
    14  * outside of the data package. Routines there should only use LatLon or 
     12 *
     13 * As the class itself is package protected too, it is not visible
     14 * outside of the data package. Routines there should only use LatLon or
    1515 * EastNorth.
    1616 *
    1717 * @author imi
    18  */ 
     18 */
    1919abstract class Coordinate extends Point2D implements Serializable {
    2020
    2121    protected double x;
    2222    protected double y;
    23    
    24         /**
    25         * Construct the point with latitude / longitude values.
    26          *
    27         * @param x X coordinate of the point.
    28         * @param y Y coordinate of the point.
    29         */
    30         Coordinate(double x, double y) {
     23
     24    /**
     25    * Construct the point with latitude / longitude values.
     26     *
     27    * @param x X coordinate of the point.
     28    * @param y Y coordinate of the point.
     29    */
     30    Coordinate(double x, double y) {
    3131        this.x = x; this.y = y;
    32         }
    33    
     32    }
     33
    3434    public double getX() {
    3535        return x;
    3636    }
    37    
     37
    3838    public double getY() {
    39         return y; 
     39        return y;
    4040    }
    41    
     41
    4242    public void setLocation (double x, double y) {
    43         this.x = x; 
     43        this.x = x;
    4444        this.y = y;
    4545    }
  • trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java

    r1076 r1169  
    44/**
    55 * Northing, Easting of the projected coordinates.
    6  * 
     6 *
    77 * This class is immutable.
    8  * 
     8 *
    99 * @author Imi
    1010 */
    1111public class EastNorth extends Coordinate {
    1212
    13         public EastNorth(double east, double north) {
    14                 super(east,north);
    15         }
    16        
    17         public double east() {
    18                 return x;
    19         }
     13    public EastNorth(double east, double north) {
     14        super(east,north);
     15    }
    2016
    21         public double north() {
    22                 return y;
    23         }
     17    public double east() {
     18        return x;
     19    }
    2420
    25         public EastNorth add(double dx, double dy) {
    26                 return new EastNorth(x+dx, y+dy);
    27         }
    28        
    29         public EastNorth interpolate(EastNorth en2, double proportion) {
    30                 return new EastNorth(this.x + proportion * (en2.x - this.x),
     21    public double north() {
     22        return y;
     23    }
     24
     25    public EastNorth add(double dx, double dy) {
     26        return new EastNorth(x+dx, y+dy);
     27    }
     28
     29    public EastNorth interpolate(EastNorth en2, double proportion) {
     30        return new EastNorth(this.x + proportion * (en2.x - this.x),
    3131            this.y + proportion * (en2.y - this.y));
    32         }
    33    
     32    }
     33
    3434    /**
    35      * Returns the heading, in radians, that you have to use to get from 
     35     * Returns the heading, in radians, that you have to use to get from
    3636     * this EastNorth to another. Heading is mapped into [0, 2pi)
    37      * 
     37     *
    3838     * @param other the "destination" position
    39      * @return heading 
     39     * @return heading
    4040     */
    4141    public double heading(EastNorth other) {
    4242        double hd = Math.atan2(other.east() - east(), other.north() - north());
    4343        if(hd < 0) hd = 2 * Math.PI + hd;
    44         return hd;       
     44        return hd;
    4545    }
    46    
     46
    4747    public EastNorth sub(EastNorth en) {
    4848        return new EastNorth(en.east() - east(), en.north() - north());
    4949    }
    50  
     50
    5151    /**
    5252     * Returns an EastNorth representing the this EastNorth rotatedaround
     
    5454     * @param pivot the center of the rotation
    5555     * @param angle the angle of the rotation
    56      * @return EastNorth rotated object 
     56     * @return EastNorth rotated object
    5757     */
    5858    public EastNorth rotate(EastNorth pivot, double angle) {
     
    6565        return new EastNorth(nx, ny);
    6666    }
    67        
    68         @Override public String toString() {
    69                 return "EastNorth[e="+x+", n="+y+"]";
    70         }
     67
     68    @Override public String toString() {
     69        return "EastNorth[e="+x+", n="+y+"]";
     70    }
    7171
    7272    /**
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r1108 r1169  
    1313/**
    1414 * LatLon are unprojected latitude / longitude coordinates.
    15  * 
     15 *
    1616 * This class is immutable.
    17  * 
     17 *
    1818 * @author Imi
    1919 */
     
    2323    private static DecimalFormat cDmsSecondFormatter = new DecimalFormat("00.0");
    2424    private static DecimalFormat cDdFormatter = new DecimalFormat("###0.0000");
    25    
    26     /** 
    27      * Possible ways to display coordinates 
    28      */ 
    29     public enum CoordinateFormat { 
    30         DECIMAL_DEGREES {public String toString() {return tr("Decimal Degrees");}}, 
    31         DEGREES_MINUTES_SECONDS {public String toString() {return tr("Degrees Minutes Seconds");}}; 
    32     } 
    33    
    34     public static String dms(double pCoordinate) { 
     25
     26    /**
     27     * Possible ways to display coordinates
     28     */
     29    public enum CoordinateFormat {
     30        DECIMAL_DEGREES {public String toString() {return tr("Decimal Degrees");}},
     31        DEGREES_MINUTES_SECONDS {public String toString() {return tr("Degrees Minutes Seconds");}};
     32    }
     33
     34    public static String dms(double pCoordinate) {
    3535
    3636        double tAbsCoord = Math.abs(pCoordinate);
     
    4040        double tSeconds = (tTmpMinutes - tMinutes) * 60;
    4141
    42         return tDegree + "\u00B0" + cDmsMinuteFormatter.format(tMinutes) + "\'" 
     42        return tDegree + "\u00B0" + cDmsMinuteFormatter.format(tMinutes) + "\'"
    4343            + cDmsSecondFormatter.format(tSeconds) + "\"";
    44     } 
     44    }
    4545
    4646    public LatLon(double lat, double lon) {
     
    5151        return y;
    5252    }
    53    
     53
    5454    public String latToString(CoordinateFormat d) {
    5555        switch(d) {
     
    5959        }
    6060    }
    61    
     61
    6262    public double lon() {
    6363        return x;
    6464    }
    65    
     65
    6666    public String lonToString(CoordinateFormat d) {
    6767        switch(d) {
     
    7171        }
    7272    }
    73    
    74  
     73
     74
    7575
    7676    /**
     
    8686    /**
    8787     * @return <code>true</code>, if the coordinate is outside the world, compared
    88         * by using lat/lon.
    89         */
    90         public boolean isOutSideWorld() {
    91                 return lat() < -Projection.MAX_LAT || lat() > Projection.MAX_LAT ||
    92                         lon() < -Projection.MAX_LON || lon() > Projection.MAX_LON;
    93         }
     88    * by using lat/lon.
     89    */
     90    public boolean isOutSideWorld() {
     91        return lat() < -Projection.MAX_LAT || lat() > Projection.MAX_LAT ||
     92            lon() < -Projection.MAX_LON || lon() > Projection.MAX_LON;
     93    }
    9494
    95         /**
    96          * @return <code>true</code> if this is within the given bounding box.
    97          */
    98         public boolean isWithin(Bounds b) {
    99                 return lat() >= b.min.lat() && lat() <= b.max.lat() && lon() > b.min.lon() && lon() < b.max.lon();
    100         }
    101        
    102         /**
    103          * Computes the distance between this lat/lon and another point on the earth.
    104          * Uses spherical law of cosines formula, not Haversine.
    105          * @param other the other point.
    106          * @return distance in metres.
    107          */
    108         public double greatCircleDistance(LatLon other) {
    109                 return (Math.acos(
    110                         Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) +
    111                     Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) *
    112                                   Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135);
    113         }
    114        
    115         /**
    116          * Returns the heading, in radians, that you have to use to get from
    117          * this lat/lon to another.
    118          *
    119          * @param other the "destination" position
    120          * @return heading
    121          */
    122         public double heading(LatLon other) {
    123                 double rv;
    124                 if (other.lat() == lat()) {
    125                         rv = (other.lon()>lon() ? Math.PI / 2 : Math.PI * 3 / 2);
    126                 } else {
    127                         rv = Math.atan((other.lon()-lon())/(other.lat()-lat()));
    128                         if (rv < 0) rv += Math.PI;
    129                         if (other.lon() < lon()) rv += Math.PI;
    130                 }
    131                 return rv;
    132         }
     95    /**
     96     * @return <code>true</code> if this is within the given bounding box.
     97     */
     98    public boolean isWithin(Bounds b) {
     99        return lat() >= b.min.lat() && lat() <= b.max.lat() && lon() > b.min.lon() && lon() < b.max.lon();
     100    }
    133101
    134         /**
    135          * Returns this lat/lon pair in human-readable format.
    136          *
    137          * @return String in the format "lat=1.23456°, lon=2.34567°"
    138          */
    139         public String toDisplayString() {
    140                 NumberFormat nf = NumberFormat.getInstance();
    141                 nf.setMaximumFractionDigits(5);
    142                 return "lat=" + nf.format(lat()) + "°, lon=" + nf.format(lon()) + "°";
    143         }
    144        
    145         @Override public String toString() {
    146                 return "LatLon[lat="+lat()+",lon="+lon()+"]";
     102    /**
     103     * Computes the distance between this lat/lon and another point on the earth.
     104     * Uses spherical law of cosines formula, not Haversine.
     105     * @param other the other point.
     106     * @return distance in metres.
     107     */
     108    public double greatCircleDistance(LatLon other) {
     109        return (Math.acos(
     110            Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) +
     111            Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) *
     112                          Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135);
     113    }
     114
     115    /**
     116     * Returns the heading, in radians, that you have to use to get from
     117     * this lat/lon to another.
     118     *
     119     * @param other the "destination" position
     120     * @return heading
     121     */
     122    public double heading(LatLon other) {
     123        double rv;
     124        if (other.lat() == lat()) {
     125            rv = (other.lon()>lon() ? Math.PI / 2 : Math.PI * 3 / 2);
     126        } else {
     127            rv = Math.atan((other.lon()-lon())/(other.lat()-lat()));
     128            if (rv < 0) rv += Math.PI;
     129            if (other.lon() < lon()) rv += Math.PI;
     130        }
     131        return rv;
     132    }
     133
     134    /**
     135     * Returns this lat/lon pair in human-readable format.
     136     *
     137     * @return String in the format "lat=1.23456°, lon=2.34567°"
     138     */
     139    public String toDisplayString() {
     140        NumberFormat nf = NumberFormat.getInstance();
     141        nf.setMaximumFractionDigits(5);
     142        return "lat=" + nf.format(lat()) + "°, lon=" + nf.format(lon()) + "°";
     143    }
     144
     145    @Override public String toString() {
     146        return "LatLon[lat="+lat()+",lon="+lon()+"]";
    147147    }
    148148}
Note: See TracChangeset for help on using the changeset viewer.