source: proiecte/ptvs/src/vnsim/map/object/Point.java @ 31

Last change on this file since 31 was 31, checked in by (none), 14 years ago
File size: 2.4 KB
Line 
1/************************************************************************************
2 * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University
3 * All rights reserved.
4 * Refer to LICENSE for terms and conditions of use.
5 ***********************************************************************************/
6package vnsim.map.object;
7
8import vnsim.map.utils.GPSutil;
9import vnsim.vehicular.routePlan.selfRouted.AreaCode;
10/**
11 * @author Victor-Radu
12 */
13
14public class Point implements java.io.Serializable {
15       
16        /** <code>serialVersionUID</code> */
17        private static final long serialVersionUID = -5883719321862303634L;
18       
19        protected double longitude;
20        protected double latitude;
21        protected double distance;              // distance along the road (on which the
22                                                                        // point is) to the first
23                                                                        // point in the road's vector of points
24                                                                        // Distances are computed in the Map constructor.
25        protected int peanoKeyIdx;
26
27        public AreaCode areaCode;
28
29        public Point(double longitude, double latitude) {
30                this.longitude = longitude;
31                this.latitude = latitude;
32        }
33       
34        public Point(double longitude, double latitude, double distance) {
35                this.longitude = longitude;
36                this.latitude = latitude;
37                this.distance = distance;
38        }
39       
40        public boolean equals(Object arg0) {
41                try{
42                        Point p = (Point)arg0;
43                        return (longitude == p.longitude && latitude == p.latitude);
44                } catch (ClassCastException e){
45                        return false;
46                }
47        }
48       
49        public String toString() {
50                StringBuffer sb = new StringBuffer();
51                sb.append("(");
52                sb.append(this.longitude);
53                sb.append(", ");
54                sb.append(this.latitude);
55                sb.append(")");
56                return (new String(sb));
57        }
58       
59        public double distanceTo(Point a)
60        {
61          double dAB = (latitude + a.latitude) / 2.0;
62          return GPSutil.dist(this, a, GPSutil.getKmDegLong(dAB), GPSutil.getKmDegLat(dAB));
63        }
64       
65       
66        public double getDistance() {
67                return distance;
68        }
69        public void setDistance(double distance) {
70                this.distance = distance;
71        }
72        public double getLatitude() {
73                return latitude;
74        }
75        public void setLatitude(double latitude) {
76                this.latitude = latitude;
77        }
78        public double getLongitude() {
79                return longitude;
80        }
81        public void setLongitude(double longitude) {
82                this.longitude = longitude;
83        }
84
85        public int getPeanoKeyIdx() {
86                return peanoKeyIdx;
87        }
88
89        public void setPeanoKeyIdx(int peanoKeyIdx) {
90                this.peanoKeyIdx = peanoKeyIdx;
91        }
92       
93       
94}
Note: See TracBrowser for help on using the repository browser.