This file is indexed.

/usr/include/ossim/elevation/ossimDtedHandler.h is in libossim-dev 1.7.21-4.

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
//*****************************************************************************
// FILE: ossimDtedHandler.h
//
// License:  See top level LICENSE.txt file.
//
// DESCRIPTION:
//   Contains declaration of class ossimDtedHandler. This class derives from
//   ossimElevHandler. It is responsible for loading an individual DTED cell
//   from disk. This elevation files are memory mapped.
//
// SOFTWARE HISTORY:
//>
//   05Feb2001  Ken Melero
//              Initial coding of ossimDted.h
//   19Apr2001  Oscar Kramer
//              Derived from ossimElevCellHandler.
//<
//*****************************************************************************
// $Id: ossimDtedHandler.h 14296 2009-04-14 17:25:00Z gpotts $

#ifndef ossimDtedHandler_HEADER
#define ossimDtedHandler_HEADER

#include <fstream>

#include <ossim/base/ossimConstants.h>
#include <ossim/base/ossimString.h>
#include <ossim/elevation/ossimElevCellHandler.h>
#include <OpenThreads/ReadWriteMutex>
#include <OpenThreads/ReadWriteMutex>

class OSSIM_DLL ossimDtedHandler : public ossimElevCellHandler
{
public:
   ossimDtedHandler(const ossimFilename& dted_file, bool memoryMapFlag=false);
   
   virtual ~ossimDtedHandler();

   enum
   {
      DATA_RECORD_OFFSET_TO_POST = 8,     // bytes
      DATA_RECORD_CHECKSUM_SIZE  = 4,     // bytes
      POST_SIZE                  = 2,     // bytes
      NULL_POST                  = -32767 // Fixed by DTED specification.
   };

   /*!
    * METHOD: getHeightAboveMSL
    * Height access methods.
    */
   virtual double getHeightAboveMSL(const ossimGpt&);

   /*!
    *  METHOD:  getSizeOfElevCell
    *  Returns the number of post in the cell.  Satisfies pure virtual.
    *  Note:  x = longitude, y = latitude
    */
   virtual ossimIpt getSizeOfElevCell() const;
      
   /*!
    *  METHOD:  getPostValue
    *  Returns the value at a given grid point as a double.
    *  Satisfies pure virtual.
    */
   virtual double getPostValue(const ossimIpt& gridPt) const;

   ossimString  edition()         const;
   ossimString  productLevel()    const;
   ossimString  compilationDate() const;

   virtual bool isOpen()const;
   /**
    * Opens a stream to the dted cell.
    *
    * @return Returns true on success, false on error.
    */
   virtual bool open();

   /**
    * Closes the stream to the file.
    */
   virtual void close();

   virtual void setMemoryMapFlag(bool flag);
   
private:
   // Disallow operator= and copy constrution...
   const ossimDtedHandler& operator=(const ossimDtedHandler& rhs);
   ossimDtedHandler(const ossimDtedHandler&);

   /*!
    *  If statistics file exist, stats will be initialized from that; else,
    *  this scans the dted cell and gets stats, then, writes new stats file.
    *  The statistics file will be named accordingly:
    *  If dted cell = n27.dt1 then the stats file = n27.statistics.
    *  Currently method only grabs the min and max posts value.
    */
   void gatherStatistics();

   ossim_sint16 convertSignedMagnitude(ossim_uint16& s) const;
   virtual double getHeightAboveMSLFile(const ossimGpt&);
   virtual double getHeightAboveMSLMemory(const ossimGpt&);
   void mapToMemory();
   
   mutable OpenThreads::Mutex theFileStrMutex;
   mutable std::ifstream theFileStr;
   
   ossim_int32      theNumLonLines;  // east-west dir
   ossim_int32      theNumLatPoints; // north-south
   ossim_int32      theDtedRecordSizeInBytes;
   ossimString      theEdition;
   ossimString      theProductLevel;
   ossimString      theCompilationDate;
   ossim_int32      theOffsetToFirstDataRecord;
   double           theLatSpacing;   // degrees
   double           theLonSpacing;   // degrees
   ossimDpt         theSwCornerPost; // cell origin;

   // Indicates whether byte swapping is needed.
   bool theSwapBytesFlag;

   mutable OpenThreads::ReadWriteMutex theMemoryMapMutex;
   mutable bool theMemoryMapFlag;
   mutable std::vector<ossim_uint8> theMemoryMap;
   
   TYPE_DATA
};

inline ossim_sint16 ossimDtedHandler::convertSignedMagnitude(ossim_uint16& s) const
{
   // DATA_VALUE_MASK 0x7fff = 0111 1111 1111 1111
   // DATA_SIGN_MASK  0x8000 = 1000 0000 0000 0000
   
   // First check to see if the bytes need swapped.
   s = (theSwapBytesFlag ? ( ((s & 0x00ff) << 8) | ((s & 0xff00) >> 8) ) : s);
   
   // If the sign bit is set, mask it out then multiply by negative one.
   if (s & 0x8000)
   {
      return (static_cast<ossim_sint16>(s & 0x7fff) * -1);
   }
   
   return static_cast<ossim_sint16>(s);
}

inline bool ossimDtedHandler::isOpen()const
{
   if(theMemoryMapFlag)
   {
      OpenThreads::ScopedReadLock lock(theMemoryMapMutex);
      return theMemoryMap.size()>0;
   }
   {
      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theFileStrMutex);
      return theFileStr.is_open();
   }
}

inline bool ossimDtedHandler::open()
{
   if(theMemoryMapFlag)
   {
      theMemoryMapMutex.readLock();
      if(theMemoryMap.size())
      {
         theMemoryMapMutex.readUnlock();
         return true;
      }
      else
      {
         theMemoryMapMutex.readUnlock();
         mapToMemory();
         return (theMemoryMap.size()>0);
      }
   }
   else
   {
      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theFileStrMutex);
      if (theFileStr.is_open())
      {
         return true;
      }
      
      theFileStr.open(theFilename.c_str(), std::ios::in | std::ios::binary);
      
      return theFileStr.is_open();
   }
   
   return false;
}

inline void ossimDtedHandler::close()
{
   {  
      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theFileStrMutex);
      if (theFileStr.is_open())
      {
         theFileStr.close();
      }
   }
   {
      OpenThreads::ScopedWriteLock lock(theMemoryMapMutex);
      theMemoryMap.clear();
   }
}

#endif