Changeset 587 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2008-03-21T01:24:05+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r318 r587 2 2 package org.openstreetmap.josm.data.coor; 3 3 4 import org.openstreetmap.josm.Main; 4 5 import org.openstreetmap.josm.data.Bounds; 5 6 import org.openstreetmap.josm.data.projection.Projection; … … 51 52 return lat() >= b.min.lat() && lat() <= b.max.lat() && lon() > b.min.lon() && lon() < b.max.lon(); 52 53 } 54 55 /** 56 * Computes the distance between this lat/lon and another point on the earth. 57 * Uses spherical law of cosines formula, not Haversine. 58 * @param other the other point. 59 * @return distance in metres. 60 */ 61 public int distance(LatLon other) { 62 return (int) (Math.acos( 63 Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) + 64 Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) * 65 Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135); 66 } 53 67 54 68 /**
Note:
See TracChangeset
for help on using the changeset viewer.