/************************************************************************************ * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University * All rights reserved. * Refer to LICENSE for terms and conditions of use. ***********************************************************************************/ package vnsim.map.object; import vnsim.map.utils.GPSutil; import vnsim.vehicular.routePlan.selfRouted.AreaCode; /** * @author Victor-Radu */ public class Point implements java.io.Serializable { /** serialVersionUID */ private static final long serialVersionUID = -5883719321862303634L; protected double longitude; protected double latitude; protected double distance; // distance along the road (on which the // point is) to the first // point in the road's vector of points // Distances are computed in the Map constructor. protected int peanoKeyIdx; public AreaCode areaCode; public Point(double longitude, double latitude) { this.longitude = longitude; this.latitude = latitude; } public Point(double longitude, double latitude, double distance) { this.longitude = longitude; this.latitude = latitude; this.distance = distance; } public boolean equals(Object arg0) { try{ Point p = (Point)arg0; return (longitude == p.longitude && latitude == p.latitude); } catch (ClassCastException e){ return false; } } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("("); sb.append(this.longitude); sb.append(", "); sb.append(this.latitude); sb.append(")"); return (new String(sb)); } public double distanceTo(Point a) { double dAB = (latitude + a.latitude) / 2.0; return GPSutil.dist(this, a, GPSutil.getKmDegLong(dAB), GPSutil.getKmDegLat(dAB)); } public double getDistance() { return distance; } public void setDistance(double distance) { this.distance = distance; } public double getLatitude() { return latitude; } public void setLatitude(double latitude) { this.latitude = latitude; } public double getLongitude() { return longitude; } public void setLongitude(double longitude) { this.longitude = longitude; } public int getPeanoKeyIdx() { return peanoKeyIdx; } public void setPeanoKeyIdx(int peanoKeyIdx) { this.peanoKeyIdx = peanoKeyIdx; } }