This file is indexed.

/usr/include/simgear/math/SGGeod.hxx is in libsimgear-dev 1:2018.1.1+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
// Copyright (C) 2006  Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//

#ifndef SGGeod_H
#define SGGeod_H

#include <simgear/constants.h>
#include <simgear/math/SGVec3.hxx>

// #define SG_GEOD_NATIVE_DEGREE

/// Class representing a geodetic location
class SGGeod {
public:
  /// Default constructor, initializes the instance to lat = lon = elev = 0
  SGGeod(void);

  /// Factory from angular values in radians and elevation is 0
  static SGGeod fromRad(double lon, double lat);
  /// Factory from angular values in degrees and elevation is 0
  static SGGeod fromDeg(double lon, double lat);
  /// Factory from angular values in radians and elevation in ft
  static SGGeod fromRadFt(double lon, double lat, double elevation);
  /// Factory from angular values in degrees and elevation in ft
  static SGGeod fromDegFt(double lon, double lat, double elevation);
  /// Factory from angular values in radians and elevation in m
  static SGGeod fromRadM(double lon, double lat, double elevation);
  /// Factory from angular values in degrees and elevation in m
  static SGGeod fromDegM(double lon, double lat, double elevation);
  /// Factory from an other SGGeod and a different elevation in m
  static SGGeod fromGeodM(const SGGeod& geod, double elevation);
  /// Factory from an other SGGeod and a different elevation in ft
  static SGGeod fromGeodFt(const SGGeod& geod, double elevation);
  /// Factory to convert position from a cartesian position assumed to be
  /// in wgs84 measured in meters
  /// Note that this conversion is relatively expensive to compute
  static SGGeod fromCart(const SGVec3<double>& cart);
  /// Factory to convert position from a geocentric position
  /// Note that this conversion is relatively expensive to compute
  static SGGeod fromGeoc(const SGGeoc& geoc);

  /// Return the geodetic longitude in radians
  double getLongitudeRad(void) const;
  /// Set the geodetic longitude from the argument given in radians
  void setLongitudeRad(double lon);

  /// Return the geodetic longitude in degrees
  double getLongitudeDeg(void) const;
  /// Set the geodetic longitude from the argument given in degrees
  void setLongitudeDeg(double lon);

  /// Return the geodetic latitude in radians
  double getLatitudeRad(void) const;
  /// Set the geodetic latitude from the argument given in radians
  void setLatitudeRad(double lat);

  /// Return the geodetic latitude in degrees
  double getLatitudeDeg(void) const;
  /// Set the geodetic latitude from the argument given in degrees
  void setLatitudeDeg(double lat);

  /// Return the geodetic elevation in meters
  double getElevationM(void) const;
  /// Set the geodetic elevation from the argument given in meters
  void setElevationM(double elevation);

  /// Return the geodetic elevation in feet
  double getElevationFt(void) const;
  /// Set the geodetic elevation from the argument given in feet
  void setElevationFt(double elevation);

  /// Compare two geodetic positions for equality
  bool operator == ( const SGGeod & other ) const;

  /// check the Geod contains sane values (finite, inside appropriate
  /// ranges for lat/lon)
  bool isValid() const;
private:
  /// This one is private since construction is not unique if you do
  /// not know the units of the arguments. Use the factory methods for
  /// that purpose
  SGGeod(double lon, double lat, double elevation);

  //// FIXME: wrong comment!
  /// The actual data, angles in degrees, elevation in meters
  /// The rationale for storing the values in degrees is that most code places
  /// in flightgear/terragear use degrees as a nativ input and output value.
  /// The places where it makes sense to use radians is when we convert
  /// to other representations or compute rotation matrices. But both tasks
  /// are computionally intensive anyway and that additional 'toRadian'
  /// conversion does not hurt too much
  double _lon;
  double _lat;
  double _elevation;
};

inline
SGGeod::SGGeod(void) :
  _lon(0), _lat(0), _elevation(0)
{
}

inline
SGGeod::SGGeod(double lon, double lat, double elevation) :
  _lon(lon), _lat(lat), _elevation(elevation)
{
}

inline
SGGeod
SGGeod::fromRad(double lon, double lat)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return SGGeod(lon*SGD_RADIANS_TO_DEGREES, lat*SGD_RADIANS_TO_DEGREES, 0);
#else
  return SGGeod(lon, lat, 0);
#endif
}

inline
SGGeod
SGGeod::fromDeg(double lon, double lat)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return SGGeod(lon, lat, 0);
#else
  return SGGeod(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0);
#endif
}

inline
SGGeod
SGGeod::fromRadFt(double lon, double lat, double elevation)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return SGGeod(lon*SGD_RADIANS_TO_DEGREES, lat*SGD_RADIANS_TO_DEGREES,
                elevation*SG_FEET_TO_METER);
#else
  return SGGeod(lon, lat, elevation*SG_FEET_TO_METER);
#endif
}

inline
SGGeod
SGGeod::fromDegFt(double lon, double lat, double elevation)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return SGGeod(lon, lat, elevation*SG_FEET_TO_METER);
#else
  return SGGeod(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS,
                elevation*SG_FEET_TO_METER);
#endif
}

inline
SGGeod
SGGeod::fromRadM(double lon, double lat, double elevation)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return SGGeod(lon*SGD_RADIANS_TO_DEGREES, lat*SGD_RADIANS_TO_DEGREES,
                elevation);
#else
  return SGGeod(lon, lat, elevation);
#endif
}

inline
SGGeod
SGGeod::fromDegM(double lon, double lat, double elevation)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return SGGeod(lon, lat, elevation);
#else
  return SGGeod(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS,
                elevation);
#endif
}

inline
SGGeod
SGGeod::fromGeodM(const SGGeod& geod, double elevation)
{
  return SGGeod(geod._lon, geod._lat, elevation);
}

inline
SGGeod
SGGeod::fromGeodFt(const SGGeod& geod, double elevation)
{
  return SGGeod(geod._lon, geod._lat, elevation*SG_FEET_TO_METER);
}

inline
SGGeod
SGGeod::fromCart(const SGVec3<double>& cart)
{
  SGGeod geod;
  SGGeodesy::SGCartToGeod(cart, geod);
  return geod;
}

inline
SGGeod
SGGeod::fromGeoc(const SGGeoc& geoc)
{
  SGVec3<double> cart;
  SGGeodesy::SGGeocToCart(geoc, cart);
  SGGeod geod;
  SGGeodesy::SGCartToGeod(cart, geod);
  return geod;
}

inline
double
SGGeod::getLongitudeRad(void) const
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return _lon*SGD_DEGREES_TO_RADIANS;
#else
  return _lon;
#endif
}

inline
void
SGGeod::setLongitudeRad(double lon)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  _lon = lon*SGD_RADIANS_TO_DEGREES;
#else
  _lon = lon;
#endif
}

inline
double
SGGeod::getLongitudeDeg(void) const
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return _lon;
#else
  return _lon*SGD_RADIANS_TO_DEGREES;
#endif
}

inline
void
SGGeod::setLongitudeDeg(double lon)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  _lon = lon;
#else
  _lon = lon*SGD_DEGREES_TO_RADIANS;
#endif
}

inline
double
SGGeod::getLatitudeRad(void) const
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return _lat*SGD_DEGREES_TO_RADIANS;
#else
  return _lat;
#endif
}

inline
void
SGGeod::setLatitudeRad(double lat)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  _lat = lat*SGD_RADIANS_TO_DEGREES;
#else
  _lat = lat;
#endif
}

inline
double
SGGeod::getLatitudeDeg(void) const
{
#ifdef SG_GEOD_NATIVE_DEGREE
  return _lat;
#else
  return _lat*SGD_RADIANS_TO_DEGREES;
#endif
}

inline
void
SGGeod::setLatitudeDeg(double lat)
{
#ifdef SG_GEOD_NATIVE_DEGREE
  _lat = lat;
#else
  _lat = lat*SGD_DEGREES_TO_RADIANS;
#endif
}

inline
double
SGGeod::getElevationM(void) const
{
  return _elevation;
}

inline
void
SGGeod::setElevationM(double elevation)
{
  _elevation = elevation;
}

inline
double
SGGeod::getElevationFt(void) const
{
  return _elevation*SG_METER_TO_FEET;
}

inline
void
SGGeod::setElevationFt(double elevation)
{
  _elevation = elevation*SG_FEET_TO_METER;
}

inline
bool
SGGeod::operator == ( const SGGeod & other ) const
{
  return _lon == other._lon &&
         _lat == other._lat &&
         _elevation == other._elevation;
}

inline
bool
SGGeod::isValid() const
{
  if (SGMiscd::isNaN(_lon))
      return false;
  if (SGMiscd::isNaN(_lat))
      return false;
#ifdef SG_GEOD_NATIVE_DEGREE
  return (_lon >= -180.0) && (_lon <= 180.0) &&
  (_lat >= -90.0) && (_lat <= 90.0);
#else
  return (_lon >= -SGD_PI) && (_lon <= SGD_PI) &&
  (_lat >= -SGD_PI_2) && (_lat <= SGD_PI_2);
#endif
}

/// Output to an ostream
template<typename char_type, typename traits_type>
inline
std::basic_ostream<char_type, traits_type>&
operator<<(std::basic_ostream<char_type, traits_type>& s, const SGGeod& g)
{
  return s << "lon = " << g.getLongitudeDeg()
           << "deg, lat = " << g.getLatitudeDeg()
           << "deg, elev = " << g.getElevationM()
           << "m";
}

#endif