Changeset 1004 in josm for trunk/src/org/openstreetmap/josm/data/coor
 Timestamp:
 20080922T03:53:47+02:00 (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java
r655 r1004 2 2 package org.openstreetmap.josm.data.coor; 3 3 4 import java. io.Serializable;4 import java.awt.geom.Point2D; 5 5 6 6 /** … … 15 15 * @author imi 16 16 */ 17 abstract class Coordinate implements Serializable{17 abstract class Coordinate extends Point2D { 18 18 19 /** 20 * Either easting or latitude 21 */ 22 final double x; 23 /** 24 * Either northing or longitude 25 */ 26 final double y; 27 19 protected double x; 20 protected double y; 21 28 22 /** 29 23 * Construct the point with latitude / longitude values. 30 * The x/y values are left uninitialized.31 24 * 32 25 * @param x X coordinate of the point. … … 34 27 */ 35 28 Coordinate(double x, double y) { 36 this.x = x; 37 this.y = y; 29 this.x = x; this.y = y; 38 30 } 31 32 public double getX() { 33 return x; 34 } 35 36 public double getY() { 37 return y; 38 } 39 40 public void setLocation (double x, double y) { 41 this.x = x; 42 this.y = y; 43 } 39 44 40 /**41 * Return the squared distance of the northing/easting values between42 * this and the argument.43 *44 * This method does NOT compute a great circle distance between two45 * locations!46 *47 * @param other The other point to calculate the distance to.48 * @return The square of the distance between this and the other point,49 * regarding to the x/y values.50 */51 public double distanceSq(Coordinate other) {52 return (xother.x)*(xother.x)+(yother.y)*(yother.y);53 }54 55 /**56 * Return the distance of the northing/easting values between this and57 * the argument.58 *59 * This method does NOT compute a great circle distance between two60 * 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 */66 public double distance(Coordinate other) {67 return Math.sqrt(distanceSq(other));68 }69 70 @Override public boolean equals(Object obj) {71 return obj instanceof Coordinate ? x == ((Coordinate)obj).x && ((Coordinate)obj).y == y : false;72 }73 74 @Override public int hashCode() {75 return (int)(x*65536+y*4096);76 }77 45 }
Note: See TracChangeset
for help on using the changeset viewer.