If you think the Android project WhatsUp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package nu.placebo.whatsup.model;
/*www.java2s.com*/import org.json.JSONException;
import org.json.JSONObject;
import com.google.android.maps.GeoPoint;
/**
* This class represents a "compressed" version of an Annotation. It holds basic data like
* where on the map the annotation is, its title and who wrote it. Basically, everything
* needed for simply showing annotations on the map view.
*/publicclass GeoLocation {
private GeoPoint gp;
private String title;
privateint id;
public GeoLocation(int id, int microLat, int microLong, String title) {
this.gp = new GeoPoint(microLat, microLong);
this.title = title;
this.id = id;
}
public GeoLocation(GeoLocation gl) {
this.gp = gl.gp;
this.title = gl.title;
this.id = gl.id;
}
public GeoLocation(int id, double latitude, double longitude, String title) {
this(id, (int) (latitude * 1000000 + 0.5),
(int) (longitude * 1000000 + 0.5), title);
}
public GeoLocation(JSONObject j) throws JSONException {
this(j.getInt("nid"), j.getDouble("latitude"),
j.getDouble("longitude"), j.getString("title"));
}
/**
* @return the id
*/publicint getId() {
return id;
}
/**
* @return the location
*/public GeoPoint getLocation() {
return gp;
}
/**
* @param gp
* the gp to set
*/publicvoid setLocation(GeoPoint gp) {
this.gp = gp;
}
/**
* @return the title
*/public String getTitle() {
return title;
}
/**
* @param title
* the title to set
*/publicvoid setTitle(String title) {
this.title = title;
}
@Override
publicboolean equals(Object o) {
if(o != null && o instanceof GeoLocation) {
GeoLocation other = (GeoLocation) o;
return this.getId() == other.getId() &&
this.getTitle().equals(other.getTitle()) &&
this.getLocation().equals(other.getLocation());
}
return false;
}
@Override
publicint hashCode() {
int result = 0;
result += gp.hashCode();
result += id;
result += title.hashCode();
return result;
}
}