VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtCDBTileCache.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
10 #pragma once
11 
12 #include <string>
13 
14 #include <osg/ref_ptr>
15 #include <osg/Image>
16 #include <osg/Shape>
17 #include <osgEarth/GeoData>
18 #include <vrvOsg/DtOsgLRUCache.h>
22 
23 #include <map>
24 #include <queue>
25 #include <vector>
26 
27 namespace makVrv { namespace oe { namespace CDB
28 {
34  class DT_DLL_OSGEARTH_CDB_UTILS CDBTileCache : public osg::Referenced
35  {
36  public:
37 
39  CDBTileCache(const std::string& CdbRootPath);
40 
42  virtual ~CDBTileCache();
43 
46  void createCdbGeoCellIndex(const DatasetInfo& datasetInfo, osgEarth::GeoExtent& CdbGeoExtent, bool readMaxLod);
47 
49  bool isCdbGeocellAvailable(const std::string& latitude, const std::string& longitude) const;
50 
52  bool isCdbGeocellAvailable(const int latitude, const int longitude) const;
53 
55  void unregister(const DatasetInfo& datasetInfo);
56 
58  osg::Image* getImage(const std::string& CdbTile);
59 
61  void addImage(const std::string& CdbTile, osg::ref_ptr< osg::Image > rbgImage);
62 
64  float imageHitPercentage();
65 
67  osg::HeightField* getHeightField(const std::string& CdbTile);
68 
70  void addHeightField(const std::string& CdbTile, osg::ref_ptr< osg::HeightField > elevation);
71 
73  float heightFieldHitPercentage();
74 
76  void setCacheSize(int cacheSize);
77 
79  int cacheSize();
80 
82  int maxElevationLod() const;
83 
85  int maxImageryLod() const;
86 
88  int maxRasterMaterialLod() const;
89 
91  int maxT2dGeometryLod() const;
92 
94  int minT2dGeometryLod() const;
95 
97  typedef std::map<std::string, bool> DtLogitudeGeocellMap;
98 
100  typedef std::map<int, bool> DtLogitudeGeocellIntMap;
101 
103  class CDBDatabaseGeocellMap : public osg::Referenced
104  {
105  public:
107 
109  std::map<std::string, DtLogitudeGeocellMap> myCdbGeoCellMap;
111  std::map<int, DtLogitudeGeocellIntMap> myCdbGeoCellIntMap;
113  std::vector<DatasetInfo> myDatasetList;
115  osgEarth::GeoExtent myCdbExtent;
116  };
117 
119  typedef std::map<std::string, osg::ref_ptr<CDBDatabaseGeocellMap> > DtDatabasesGeocellMap;
120 
121  // TODO The functions below for the elevation cache are under evaluation and may be removed,
122  // if we implement another cache system for indirect rendering
123 
125  static bool doesElevationCacheExist(const std::string& shpInstanceFile, const std::string& cachePath);
127  static bool getElevationFromCache(const std::string& shpInstanceFile, const std::string& cachePath, std::vector<osg::Vec3d>& modelPoints, const unsigned int expectedFeatureCount );
129  static bool saveElevationToCache(const std::string& shpInstanceFile, const std::string& cachePath, const std::vector<osg::Vec3d>& modelPoints);
130 
131  private:
132 
139 
143  //ElevationCDBsCache* myCdbElevationCache;
147 
150 
152  std::string myCdbRootPath;
153 
155  static int theMaxElevationLod;
156 
158  static int theMaxImageryLod;
159 
162 
164  static int theMinT2dLod;
165 
167  static int theMaxT2dLod;
168 
170  static int theMinLongitude;
171 
173  static int theMaxLongitude;
174 
176  static int theMinLatitude;
177 
179  static int theMaxLatitude;
180 
183  };
184 
185 } } } // namespace mak::osgEarth::CDB
186 
187 
static int theMinT2dLod
Minimum LOD of the t2d model geometry dataset.
Definition: DtCDBTileCache.h:164
Threading::Mutex myMutex
Mutex object to allow thread safety.
Definition: DtCDBTileCache.h:182
std::map< std::string, bool > DtLogitudeGeocellMap
type for the longitude map as a string representation
Definition: DtCDBTileCache.h:97
CDB Tile cache manager Used by CDBTileSource to try to avoid reading the the same CDB tile many time ...
Definition: DtCDBTileCache.h:34
Least-recently-used cache class.
Definition: DtOsgLRUCache.h:41
CDB Class that hold the Dataset informationNote: A DUPLICATED class also exist in the Openflight Plug...
ElevationCDBsCache myCdbElevationCache
LRU cache map for elevation.
Definition: DtCDBTileCache.h:144
std::map< int, bool > DtLogitudeGeocellIntMap
type for the longitude map as an integer representation
Definition: DtCDBTileCache.h:100
#define DT_DLL_OSGEARTH_CDB_UTILS
Definition: DtCDBExport.h:18
static int theMaxImageryLod
Maximum LOD of the imagery dataset.
Definition: DtCDBTileCache.h:158
makVrv::LRUCache< std::string, osg::ref_ptr< osg::HeightField > > ElevationCDBsCache
LRU cache map type for elevation.
Definition: DtCDBTileCache.h:141
static int theMaxLatitude
Max Latitude.
Definition: DtCDBTileCache.h:179
std::map< int, DtLogitudeGeocellIntMap > myCdbGeoCellIntMap
latitude and longitude map as an integer representation (its set once at the start and used by many) ...
Definition: DtCDBTileCache.h:111
for each CDB database keep track of the lat/lon geocell that exist
Definition: DtCDBTileCache.h:103
static int theMaxElevationLod
Maximum LOD of the elevation dataset.
Definition: DtCDBTileCache.h:155
osgEarth::GeoExtent myCdbExtent
database extent
Definition: DtCDBTileCache.h:115
static int theMaxLongitude
Max Longitude.
Definition: DtCDBTileCache.h:173
static int theMinLatitude
Min Latitude.
Definition: DtCDBTileCache.h:176
makVrv::LRUCache< std::string, osg::ref_ptr< osg::Image > > ImageCDBsCache
LRU cache map type for imagery.
Definition: DtCDBTileCache.h:134
std::vector< DatasetInfo > myDatasetList
List of datasets using this map.
Definition: DtCDBTileCache.h:113
size_t myNbCacheSize
Default number of cache file 20, but can be set via the config.
Definition: DtCDBTileCache.h:149
CDB Dataset information class.
Definition: DtCDBDatasetInfo.h:23
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
Threading::Mutex myCdbImageryCacheMutex
Image Mutex object to allow thread safety.
Definition: DtCDBTileCache.h:138
std::string myCdbRootPath
Current CDB Root path.
Definition: DtCDBTileCache.h:152
OpenThreads::Mutex Mutex
Definition: DtOsgThreadingUtils.h:12
ImageCDBsCache myCdbImageryCache
LRU cache map for imagery.
Definition: DtCDBTileCache.h:136
static int theMinLongitude
Min Longitude.
Definition: DtCDBTileCache.h:170
std::map< std::string, osg::ref_ptr< CDBDatabaseGeocellMap > > DtDatabasesGeocellMap
Type for the map of the existing geocell by CDB database.
Definition: DtCDBTileCache.h:119
static int theMaxRasterMaterialLod
Maximum LOD of the raster material dataset.
Definition: DtCDBTileCache.h:161
Threading::Mutex myCdbElevationCacheMutex
Elevation Mutex object to allow thread safety.
Definition: DtCDBTileCache.h:146
static int theMaxT2dLod
Maximum LOD of the t2d model geometry dataset.
Definition: DtCDBTileCache.h:167

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)