1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.data.coor;
|
---|
3 |
|
---|
4 | import java.io.Serializable;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Base class of points of both coordinate systems.
|
---|
8 | *
|
---|
9 | * The variables are default package protected to allow routines in the
|
---|
10 | * data package to access them directly.
|
---|
11 | *
|
---|
12 | * As the class itself is package protected too, it is not visible
|
---|
13 | * outside of the data package. Routines there should only use LatLon or
|
---|
14 | * EastNorth.
|
---|
15 | *
|
---|
16 | * @author imi
|
---|
17 | */
|
---|
18 | abstract class Coordinate implements Serializable {
|
---|
19 |
|
---|
20 | protected final double x;
|
---|
21 | protected final double y;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Construct the point with latitude / longitude values.
|
---|
25 | *
|
---|
26 | * @param x X coordinate of the point.
|
---|
27 | * @param y Y coordinate of the point.
|
---|
28 | */
|
---|
29 | Coordinate(double x, double y) {
|
---|
30 | this.x = x; this.y = y;
|
---|
31 | }
|
---|
32 |
|
---|
33 | public double getX() {
|
---|
34 | return x;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public double getY() {
|
---|
38 | return y;
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public int hashCode() {
|
---|
43 | final int prime = 31;
|
---|
44 | int result = super.hashCode();
|
---|
45 | long temp;
|
---|
46 | temp = java.lang.Double.doubleToLongBits(x);
|
---|
47 | result = prime * result + (int) (temp ^ (temp >>> 32));
|
---|
48 | temp = java.lang.Double.doubleToLongBits(y);
|
---|
49 | result = prime * result + (int) (temp ^ (temp >>> 32));
|
---|
50 | return result;
|
---|
51 | }
|
---|
52 |
|
---|
53 | @Override
|
---|
54 | public boolean equals(Object obj) {
|
---|
55 | if (this == obj)
|
---|
56 | return true;
|
---|
57 | if (!super.equals(obj))
|
---|
58 | return false;
|
---|
59 | if (getClass() != obj.getClass())
|
---|
60 | return false;
|
---|
61 | Coordinate other = (Coordinate) obj;
|
---|
62 | if (java.lang.Double.doubleToLongBits(x) != java.lang.Double.doubleToLongBits(other.x))
|
---|
63 | return false;
|
---|
64 | if (java.lang.Double.doubleToLongBits(y) != java.lang.Double.doubleToLongBits(other.y))
|
---|
65 | return false;
|
---|
66 | return true;
|
---|
67 | }
|
---|
68 | }
|
---|