This file is indexed.

/usr/include/osgEarth/Units is in libosgearth-dev 2.5.0+dfsg-8build1.

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
/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2013 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef OSGEARTH_UNITS_H
#define OSGEARTH_UNITS_H 1

#include <osgEarth/Common>
#include <osgEarth/Config>

namespace osgEarth
{
    class Registry;

    class OSGEARTH_EXPORT Units
    {
    public:
        // linear
        static const Units CENTIMETERS;
        static const Units DATA_MILES;
        static const Units FATHOMS;
        static const Units FEET;
        static const Units FEET_US_SURVEY;  // http://www.wsdot.wa.gov/reference/metrics/foottometer.htm
        static const Units INCHES;
        static const Units KILOFEET;
        static const Units KILOMETERS;
        static const Units KILOYARDS;
        static const Units METERS;
        static const Units MILES;           // statute miles
        static const Units MILLIMETERS;
        static const Units NAUTICAL_MILES;
        static const Units YARDS;

        // angular
        static const Units BAM;
        static const Units DEGREES;
        static const Units NATO_MILS; // http://www.convertworld.com/en/angle/Mil+(NATO).html
        static const Units RADIANS;

        // temporal
        static const Units DAYS;
        static const Units HOURS;
        static const Units MICROSECONDS;
        static const Units MILLISECONDS;
        static const Units MINUTES;
        static const Units SECONDS;
        static const Units WEEKS;

        // speed
        static const Units FEET_PER_SECOND;
        static const Units YARDS_PER_SECOND;
        static const Units METERS_PER_SECOND;
        static const Units KILOMETERS_PER_SECOND;
        static const Units KILOMETERS_PER_HOUR;
        static const Units MILES_PER_HOUR;
        static const Units DATA_MILES_PER_HOUR;
        static const Units KNOTS;

        // screen
        static const Units PIXELS;

        // unit types.
        enum Type
        { 
            TYPE_LINEAR, 
            TYPE_ANGULAR, 
            TYPE_TEMPORAL, 
            TYPE_SPEED, 
            TYPE_SCREEN_SIZE,
            TYPE_INVALID
        };

    public:

        static bool parse( const std::string& input, Units& output );

        // parses a value+units string (like "15cm" or "24px")
        static bool parse( const std::string& input, double& out_value, Units& out_units, const Units& defaultUnits );
        static bool parse( const std::string& input, float& out_value, Units& out_units, const Units& defaultUnits );
        static bool parse( const std::string& input, int& out_value, Units& out_units, const Units& defaultUnits );

        static bool convert( const Units& from, const Units& to, double input, double& output ) {
            if ( canConvert(from, to) ) {
                if ( from._type == TYPE_LINEAR || from._type == TYPE_ANGULAR || from._type == TYPE_TEMPORAL )
                    convertSimple( from, to, input, output );
                else if ( from._type == TYPE_SPEED )
                    convertSpeed( from, to, input, output );
                return true;
            }
            return false;
        }

        static double convert( const Units& from, const Units& to, double input ) {
            double output = input;
            convert( from, to, input, output );
            return output;
        }

        static bool canConvert( const Units& from, const Units& to ) {
            return from._type == to._type;
        }

        bool canConvert( const Units& to ) const {
            return _type == to._type;
        }

        bool convertTo( const Units& to, double input, double& output )  const {
            return convert( *this, to, input, output );
        }

        double convertTo( const Units& to, double input ) const {
            return convert( *this, to, input );
        }
        
        const std::string& getName() const { return _name; }

        const std::string& getAbbr() const { return _abbr; }

        const Type& getType() const { return _type; }

        bool operator == ( const Units& rhs ) const {
            return _type == rhs._type && _toBase == rhs._toBase; }
        
        bool operator != ( const Units& rhs ) const {
            return _type != rhs._type || _toBase != rhs._toBase; }

        bool isLinear() const { return _type == TYPE_LINEAR; }

        bool isAngular() const { return _type == TYPE_ANGULAR; }

        bool isTemporal() const { return _type == TYPE_TEMPORAL; }

        bool isSpeed() const { return _type == TYPE_SPEED; }

        bool isScreenSize() const { return _type == TYPE_SCREEN_SIZE; }

    public:

        // Make a new unit definition (LINEAR, ANGULAR, TEMPORAL, SCREEN)
        Units( const std::string& name, const std::string& abbr, const Type& type, double toBase );

        // Maks a new unit definition (SPEED)
        Units( const std::string& name, const std::string& abbr, const Units& distance, const Units& time );

        Units() : _type(TYPE_INVALID) { }

    private:

        static void convertSimple( const Units& from, const Units& to, double input, double& output ) {
            output = input * from._toBase / to._toBase;
        }
        static void convertSpeed( const Units& from, const Units& to, double input, double& output ) {
            double t = from._distance->convertTo( *to._distance, input );
            output = to._time->convertTo( *from._time, t );
        }


        std::string _name, _abbr;
        Type _type;
        double _toBase;
        const Units* _distance;
        const Units* _time;
        

        // called by Registry to register system units
        static void registerAll(class Registry* registry);
        friend class Registry;
    };

    struct Linear;

    template<typename T>
    class qualified_double
    {
    public:
        qualified_double<T>( double value, const Units& units ) : _value(value), _units(units) { }

        qualified_double<T>( const T& rhs ) : _value(rhs._value), _units(rhs._units) { }

        qualified_double<T>( const Config& conf, const Units& defaultUnits ) {
            _value = conf.value<double>("value", 0.0);
            if ( !Units::parse( conf.value("units"), _units ) )
                _units = defaultUnits;
        }

        void set( double value, const Units& units ) {
            _value = value;
            _units = units;
        }

        T& operator = ( const T& rhs ) {
            set( rhs._value, rhs._units );
            return static_cast<T&>(*this);
        }

        T operator + ( const T& rhs ) const {
            return _units.canConvert(rhs._units) ?
                T(_value + rhs.as(_units), _units) :
                T(0, Units());
        }

        T operator - ( const T& rhs ) const {
            return _units.canConvert(rhs._units) ? 
                T(_value - rhs.as(_units), _units) :
                T(0, Units());
        }

        T operator * ( double rhs ) const { 
            return T(_value * rhs, _units);
        }

        T operator / ( double rhs ) const { 
            return T(_value / rhs, _units);
        }

        bool operator == ( const T& rhs ) const {
            return _units.canConvert( rhs._units ) && rhs.as(_units) == _value;
        }

        bool operator != ( const T& rhs ) const {
            return !_units.canConvert(rhs._units) || rhs.as(_units) != _value;
        }

        bool operator < ( const T& rhs ) const {
            return _units.canConvert(rhs._units) && _value < rhs.as(_units);
        }

        bool operator <= ( const T& rhs ) const {
            return _units.canConvert(rhs._units) && _value <= rhs.as(_units);
        }

        bool operator > ( const T& rhs ) const {
            return _units.canConvert(rhs._units) && _value > rhs.as(_units);
        }

        bool operator >= ( const T& rhs ) const {
            return _units.canConvert(rhs._units) && _value >= rhs.as(_units);
        }

        double as( const Units& convertTo ) const {
            return _units.convertTo( convertTo, _value );
        }

        const Units& getUnits() const { return _units; }

        Config getConfig() const {
            Config conf;
            conf.set("value", _value);
            conf.set("units", _units.getAbbr());
            return conf;
        }

    private:
        double _value;
        Units  _units;
    };

    struct Linear : public qualified_double<Linear> {
        Linear() : qualified_double<Linear>(0, Units::METERS) { }
        Linear(double value ) : qualified_double<Linear>(value, Units::METERS) { }
        Linear(double value, const Units& units) : qualified_double<Linear>(value, units) { }
        Linear(const Config& conf) : qualified_double<Linear>(conf, Units::METERS) { }
    };
    typedef Linear Distance;

    struct Angular : public qualified_double<Angular> {
        Angular() : qualified_double<Angular>(0, Units::DEGREES) { }
        Angular(double value) : qualified_double<Angular>(value, Units::DEGREES) { }
        Angular(double value, const Units& units) : qualified_double<Angular>(value, units) { }
        Angular(const Config& conf) : qualified_double<Angular>(conf, Units::DEGREES) { }
    };
    typedef Angular Angle;

    struct Temporal : public qualified_double<Temporal> {
        Temporal() : qualified_double<Temporal>(0, Units::SECONDS) { }
        Temporal(double value) : qualified_double<Temporal>(value, Units::SECONDS) { }
        Temporal(double value, const Units& units) : qualified_double<Temporal>(value, units) { }
        Temporal(const Config& conf) : qualified_double<Temporal>(conf, Units::SECONDS) { }
    };
    typedef Temporal Duration;

    struct Speed : public qualified_double<Speed> {
        Speed() : qualified_double<Speed>(0, Units::METERS_PER_SECOND) { }
        Speed(double value) : qualified_double<Speed>(value, Units::METERS_PER_SECOND) { }
        Speed(double value, const Units& units) : qualified_double<Speed>(value, units) { }
        Speed(const Config& conf) : qualified_double<Speed>(conf, Units::METERS_PER_SECOND) { }
    };

    struct ScreenSize : public qualified_double<ScreenSize> {
        ScreenSize() : qualified_double<ScreenSize>(0, Units::PIXELS) { }
        ScreenSize(double value) : qualified_double<ScreenSize>(value, Units::PIXELS) { }
        ScreenSize(double value, const Units& units) : qualified_double<ScreenSize>(value, units) { }
        ScreenSize(const Config& conf) : qualified_double<ScreenSize>(conf, Units::PIXELS) { }
    };

}

#endif // OSGEARTH_UNITS_H