Ignore:
Timestamp:
2008-04-17T03:03:28+02:00 (16 years ago)
Author:
framm
Message:
  • new extrude mode allows creation of rectangular shapes
  • new AlignInRectangle function
  • additional information in status bar about length, heading, and angle of segment being drawn
  • helper line from last node to mouse cursor (disable with edit.helper-line=false)
File:
1 edited

Legend:

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

    r589 r608  
    5858         * @return distance in metres.
    5959         */
    60         public int distance(LatLon other) {
    61                 return (int) (Math.acos(
     60        public double greatCircleDistance(LatLon other) {
     61                return (Math.acos(
    6262                        Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) +
    6363                    Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) *
    6464                                  Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135);
     65        }
     66       
     67        /**
     68         * Returns the heading, in radians, that you have to use to get from
     69         * this lat/lon to another.
     70         *
     71         * @param other the "destination" position
     72         * @return heading
     73         */
     74        public double heading(LatLon other) {
     75                double rv;
     76                if (other.lat() == lat()) {
     77                        rv = (other.lon()>lon() ? Math.PI / 2 : Math.PI * 3 / 2);
     78                } else {
     79                        rv = Math.atan((other.lon()-lon())/(other.lat()-lat()));
     80                        if (rv < 0) rv += Math.PI;
     81                        if (other.lon() < lon()) rv += Math.PI;
     82                }
     83                return rv;
    6584        }
    6685
Note: See TracChangeset for help on using the changeset viewer.