Rev 29 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* Copyright (C) 2006 Steve Ratcliffe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* Author: Steve Ratcliffe
* Create date: 11-Dec-2006
*/
package uk.me.parabola.splitter;
/**
* A point coordinate in unshifted map-units.
* A map unit is 360/2^24 degrees. In some places <i>shifted</i> coordinates
* are used, which means that they are divided by some power of two to save
* space in the file.
*
* You can create one of these with lat/long by calling the constructor with
* double args.
*
* This is an immutable class.
*
* @author Steve Ratcliffe
*/
public class Coord
{
private final int latitude
;
private final int longitude
;
/**
* Construct from regular latitude and longitude.
* @param latitude The latitude in degrees.
* @param longitude The longitude in degrees.
*/
public Coord
(double latitude,
double longitude
) {
this.
latitude = Utils.
toMapUnit(latitude
);
this.
longitude = Utils.
toMapUnit(longitude
);
}
public int getLatitude
() {
return latitude
;
}
public int getLongitude
() {
return longitude
;
}
public int hashCode
() {
return latitude+longitude
;
}
public boolean equals
(Object obj
) {
if (obj ==
null)
return false;
if (obj.
getClass() != getClass
())
return false;
Coord other =
(Coord
) obj
;
return latitude == other.
latitude && longitude == other.
longitude;
}
/**
* Returns a string representation of the object.
*
* @return a string representation of the object.
*/
public String toString
() {
return (latitude
) +
"/" +
(longitude
);
}
}