Ignore:
Timestamp:
2008-04-17T03:03:28+02:00 (15 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)
Location:
trunk/src/org/openstreetmap/josm/data/coor
Files:
2 edited

Legend:

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

    r486 r608  
    4141         * Return the squared distance of the northing/easting values between
    4242         * this and the argument.
     43         *
     44         * This method does NOT compute a great circle distance between two
     45         * locations!
    4346         *
    4447         * @param other The other point to calculate the distance to.
     
    4649         *              regarding to the x/y values.
    4750         */
     51        public double distanceSq(Coordinate other) {
     52                return (x-other.x)*(x-other.x)+(y-other.y)*(y-other.y);
     53        }
     54       
     55        /**
     56         * Return the distance of the northing/easting values between this and
     57         * the argument.
     58         *
     59         * This method does NOT compute a great circle distance between two
     60         * locations!
     61         *
     62         * @param other The other point to calculate the distance to.
     63         * @return The square of the distance between this and the other point,
     64         *              regarding to the x/y values.
     65         */
    4866        public double distance(Coordinate other) {
    49                 return (x-other.x)*(x-other.x)+(y-other.y)*(y-other.y);
     67                return Math.sqrt(distanceSq(other));
    5068        }
    5169
  • 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.