/usr/include/ossim/elevation/ossimElevationCellDatabase.h is in libossim-dev 2.2.2-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 | #ifndef ossimElevationCellDatabase_HEADER
#define ossimElevationCellDatabase_HEADER 1
#include <ossim/elevation/ossimElevationDatabase.h>
#include <mutex>
class OSSIM_DLL ossimElevationCellDatabase : public ossimElevationDatabase
{
public:
struct CellInfo : ossimReferenced
{
CellInfo(ossim_uint64 id, ossimElevCellHandler* handler = 0)
:ossimReferenced(),
m_id(id),
m_handler(handler),
m_timestamp(0)
{
m_timestamp = ossimTimer::instance()->tick();
}
CellInfo(const CellInfo& src)
:ossimReferenced(src),
m_id(src.m_id),
m_handler(src.m_handler),
m_timestamp(src.m_timestamp)
{
}
CellInfo()
:ossimReferenced(),
m_id(0),
m_handler(0),
m_timestamp(0)
{
}
const CellInfo& operator =(const CellInfo& src)
{
if (this != &src)
{
m_id = src.m_id;
m_handler = src.m_handler;
m_timestamp = src.m_timestamp;
}
return *this;
}
void updateTimestamp()
{
m_timestamp = ossimTimer::instance()->tick();
}
ossim_uint64 id()const
{
return m_id;
}
ossim_uint64 m_id;
ossimRefPtr<ossimElevCellHandler> m_handler;
ossimTimer::Timer_t m_timestamp;
};
typedef std::map<ossim_uint64, ossimRefPtr<CellInfo> > CellMap;
ossimElevationCellDatabase()
:ossimElevationDatabase(),
m_minOpenCells(5),
m_maxOpenCells(10),
m_memoryMapCellsFlag(false)
{
}
ossimElevationCellDatabase(const ossimElevationCellDatabase& src)
:ossimElevationDatabase(src),
m_minOpenCells(src.m_minOpenCells),
m_maxOpenCells(src.m_maxOpenCells),
m_cacheMap(src.m_cacheMap),
m_memoryMapCellsFlag(src.m_memoryMapCellsFlag)
{
}
virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const;
virtual ossim_uint32 getMinOpenCells()const
{
return m_minOpenCells;
}
virtual ossim_uint32 getMaxOpenCells()const
{
return m_maxOpenCells;
}
virtual void setMinMaxOpenCells(ossim_uint64 minCellCount,
ossim_uint64 maxCellCount)
{
m_minOpenCells = minCellCount;
m_maxOpenCells = maxCellCount;
}
virtual bool getMemoryMapCellsFlag()const
{
return m_memoryMapCellsFlag;
}
virtual void setMemoryMapCellsFlag(bool flag)
{
m_memoryMapCellsFlag = flag;
}
virtual void getOpenCellList(std::vector<ossimFilename>& list) const;
/**
* @brief Gets a list of elevation cells needed to cover bounding box.
* @param connectionString Typically elevation repository, e.g.:
* "/data1/elevation/srtm/1arc"
* @param minLat Minimum latitude of bounding box.
* @param minLon Minimum longitude of bounding box.
* @param maxLat Maximum latitude of bounding box.
* @param maxLon Maximum longitude of bounding box.
* @param cells Initialized by this.
* @param maxNumberOfCells Value of 0 indicates return as many as you can. Any positive
* number will only return that number of cells.
*/
void getCellsForBounds( const ossim_float64& minLat,
const ossim_float64& minLon,
const ossim_float64& maxLat,
const ossim_float64& maxLon,
std::vector<ossimFilename>& cells,
ossim_uint32 maxNumberOfCells=0 );
virtual ossim_uint64 createId(const ossimGpt& /* pt */)const
{
return 0;
}
virtual ossimRefPtr<ossimElevCellHandler> getOrCreateCellHandler(const ossimGpt& gpt);
virtual std::ostream& print(std::ostream& out) const;
protected:
virtual ossimRefPtr<ossimElevCellHandler> createCell(const ossimGpt& /* gpt */)
{
return 0;
}
virtual void remove(ossim_uint64 id)
{
CellMap::iterator iter = m_cacheMap.find(id);
if(iter != m_cacheMap.end())
{
m_cacheMap.erase(iter);
}
}
void flushCacheToMinOpenCells()
{
// lets flush the cache from least recently used to recent.
//
CellMap sortedMap;
CellMap::iterator iter = m_cacheMap.begin();
while(iter != m_cacheMap.end())
{
sortedMap.insert(std::make_pair(iter->second->m_timestamp, iter->second));
++iter;
}
iter = sortedMap.begin();
while((iter!=sortedMap.end())&&(m_cacheMap.size() > m_minOpenCells))
{
remove(iter->second->id());
++iter;
}
}
ossim_uint32 m_minOpenCells;
ossim_uint32 m_maxOpenCells;
mutable std::mutex m_cacheMapMutex;
CellMap m_cacheMap;
ossim_uint32 m_memoryMapCellsFlag;
TYPE_DATA;
};
#endif /* #ifndef ossimElevationCellDatabase_HEADER */
|