1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.bodies;
18
19 import java.io.Serializable;
20 import java.text.NumberFormat;
21
22 import org.hipparchus.geometry.euclidean.threed.Vector3D;
23 import org.hipparchus.util.CompositeFormat;
24 import org.hipparchus.util.FastMath;
25 import org.hipparchus.util.MathUtils;
26
27
28
29
30
31
32
33 public class GeodeticPoint implements Serializable {
34
35
36 private static final long serialVersionUID = 7862466825590075399L;
37
38
39 private final double latitude;
40
41
42 private final double longitude;
43
44
45 private final double altitude;
46
47
48 private transient Vector3D zenith;
49
50
51 private transient Vector3D nadir;
52
53
54 private transient Vector3D north;
55
56
57 private transient Vector3D south;
58
59
60 private transient Vector3D east;
61
62
63 private transient Vector3D west;
64
65
66
67
68
69
70
71
72
73 public GeodeticPoint(final double latitude, final double longitude,
74 final double altitude) {
75 double lat = MathUtils.normalizeAngle(latitude, FastMath.PI / 2);
76 double lon = MathUtils.normalizeAngle(longitude, 0);
77 if (lat > FastMath.PI / 2.0) {
78
79 lat = FastMath.PI - lat;
80 lon = MathUtils.normalizeAngle(longitude + FastMath.PI, 0);
81 }
82 this.latitude = lat;
83 this.longitude = lon;
84 this.altitude = altitude;
85 }
86
87
88
89
90 public double getLatitude() {
91 return latitude;
92 }
93
94
95
96
97 public double getLongitude() {
98 return longitude;
99 }
100
101
102
103
104 public double getAltitude() {
105 return altitude;
106 }
107
108
109
110
111
112
113 public Vector3D getZenith() {
114 if (zenith == null) {
115 final double cosLat = FastMath.cos(latitude);
116 final double sinLat = FastMath.sin(latitude);
117 final double cosLon = FastMath.cos(longitude);
118 final double sinLon = FastMath.sin(longitude);
119 zenith = new Vector3D(cosLon * cosLat, sinLon * cosLat, sinLat);
120 }
121 return zenith;
122 }
123
124
125
126
127
128
129 public Vector3D getNadir() {
130 if (nadir == null) {
131 nadir = getZenith().negate();
132 }
133 return nadir;
134 }
135
136
137
138
139
140
141
142 public Vector3D getNorth() {
143 if (north == null) {
144 final double cosLat = FastMath.cos(latitude);
145 final double sinLat = FastMath.sin(latitude);
146 final double cosLon = FastMath.cos(longitude);
147 final double sinLon = FastMath.sin(longitude);
148 north = new Vector3D(-cosLon * sinLat, -sinLon * sinLat, cosLat);
149 }
150 return north;
151 }
152
153
154
155
156
157
158 public Vector3D getSouth() {
159 if (south == null) {
160 south = getNorth().negate();
161 }
162 return south;
163 }
164
165
166
167
168
169
170
171 public Vector3D getEast() {
172 if (east == null) {
173 east = new Vector3D(-FastMath.sin(longitude), FastMath.cos(longitude), 0);
174 }
175 return east;
176 }
177
178
179
180
181
182
183 public Vector3D getWest() {
184 if (west == null) {
185 west = getEast().negate();
186 }
187 return west;
188 }
189
190 @Override
191 public boolean equals(final Object object) {
192 if (object instanceof GeodeticPoint) {
193 final GeodeticPoint../org/orekit/bodies/GeodeticPoint.html#GeodeticPoint">GeodeticPoint other = (GeodeticPoint) object;
194 return this.getLatitude() == other.getLatitude() &&
195 this.getLongitude() == other.getLongitude() &&
196 this.getAltitude() == other.getAltitude();
197 }
198 return false;
199 }
200
201 @Override
202 public int hashCode() {
203 return Double.valueOf(this.getLatitude()).hashCode() ^
204 Double.valueOf(this.getLongitude()).hashCode() ^
205 Double.valueOf(this.getAltitude()).hashCode();
206 }
207
208 @Override
209 public String toString() {
210 final NumberFormat format = CompositeFormat.getDefaultNumberFormat();
211 return "{lat: " +
212 format.format(FastMath.toDegrees(this.getLatitude())) +
213 " deg, lon: " +
214 format.format(FastMath.toDegrees(this.getLongitude())) +
215 " deg, alt: " +
216 format.format(this.getAltitude()) +
217 "}";
218 }
219 }