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) 2026 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  int maxBathymetryLod() const;
84 
86  int maxImageryLod() const;
87  int maxLightMapLod() const;
88 
90  int maxRasterMaterialLod() const;
91 
93  int maxGsManMadePointFeatureLod() const;
94  int maxGsManMadeLinealFeatureLod() const;
95  int maxGsManMadeArealFeatureLod() const;
96  int maxGsNaturalPointFeatureLod() const;
97  int maxGsNaturalLinealFeatureLod() const;
98  int maxGsNaturalArealFeatureLod() const;
99  int maxGsTreePointFeatureLod() const;
100  int maxGsAirportPointFeatureLod() const;
101  int maxGsAirportLinealFeatureLod() const;
102  int maxGsAirportArealFeatureLod() const;
103  int maxGsEnvironmentPointFeatureLod() const;
104 
106  int maxGtManMadePointFeatureLod() const;
107  int maxGtManMadeLinealFeatureLod() const;
108  int maxGtManMadeArealFeatureLod() const;
109  int maxGtTreePointFeatureLod() const;
110  int maxGtTreeLinealFeatureLod() const;
111  int maxGtTreeArealFeatureLod() const;
112 
114  int maxGeoPoliticalBoundaryPointLod() const;
115  int maxGeoPoliticalBoundaryLinealLod() const;
116  int maxGeoPoliticalBoundaryArealLod() const;
117  int maxGeoPoliticalLocationPointLod() const;
118  int maxGeoPoliticalLocationLinealLod() const;
119  int maxGeoPoliticalLocationArealLod() const;
120  int maxGeoPoliticalConstraintPointLod() const;
121  int maxGeoPoliticalConstraintLinealLod() const;
122  int maxGeoPoliticalConstraintArealLod() const;
123 
125  int maxRoadNetworkLinealLod() const;
126  int maxRoadNetworkAirportLinealLod() const;
127  int maxRoadNetworkAirportArealLod() const;
128 
130  int maxRailRoadNetworkLod() const;
131 
133  int maxPowerLineNetworkLod() const;
134 
136  int maxHydrographyNetworkLinealLod() const;
137  int maxHydrographyNetworkArealLod() const;
138 
140  int maxT2dGeometryLod() const;
141 
143  int minT2dGeometryLod() const;
144 
146  typedef std::map<std::string, bool> DtLogitudeGeocellMap;
147 
149  typedef std::map<int, bool> DtLogitudeGeocellIntMap;
150 
152  class CDBDatabaseGeocellMap : public osg::Referenced
153  {
154  public:
156 
158  std::map<std::string, DtLogitudeGeocellMap> myCdbGeoCellMap;
160  std::map<int, DtLogitudeGeocellIntMap> myCdbGeoCellIntMap;
162  std::vector<DatasetInfo> myDatasetList;
164  osgEarth::GeoExtent myCdbExtent;
165  };
166 
168  typedef std::map<std::string, osg::ref_ptr<CDBDatabaseGeocellMap> > DtDatabasesGeocellMap;
169 
170  // The functions below for the elevation cache are under evaluation and may be removed,
171  // if we implement another cache system for indirect rendering
172 
174  static bool doesElevationCacheExist(const std::string& shpInstanceFile, const std::string& cachePath);
176  static bool getElevationFromCache(const std::string& shpInstanceFile, const std::string& cachePath, std::vector<osg::Vec3d>& modelPoints, const unsigned int expectedFeatureCount );
178  static bool saveElevationToCache(const std::string& shpInstanceFile, const std::string& cachePath, const std::vector<osg::Vec3d>& modelPoints);
179 
181  static void reInit();
182 
183  protected:
184 
187  static void getMaxLodFromDatasetInfo(const DatasetInfo& datasetInfo, const std::string& datasetPath, int& datasetLod);
188 
191  static void getMaxLodFromDatasetFromFolderName(const std::string& datasetPath, int& datasetLod);
192 
193  private:
194 
201 
205  //ElevationCDBsCache* myCdbElevationCache;
209 
212 
214  std::string myCdbRootPath;
215 
217  static int theMaxElevationLod;
219 
221  static int theMaxImageryLod;
222  static int theMaxLightMapLod;
223 
226 
239 
247 
258 
263 
266 
269 
273 
275  static int theMinT2dLod;
276 
278  static int theMaxT2dLod;
279 
281  static int theMinLongitude;
282 
284  static int theMaxLongitude;
285 
287  static int theMinLatitude;
288 
290  static int theMaxLatitude;
291 
294  };
295 
296 } } } // namespace mak::osgEarth::CDB
297 
298 
static int theMaxGsNaturalPointFeatureLod
Definition: DtCDBTileCache.h:229
static int theMinT2dLod
Minimum LOD of the t2d model geometry dataset.
Definition: DtCDBTileCache.h:275
static int theMaxGeoPoliticalLocationLinealLod
Definition: DtCDBTileCache.h:253
Threading::Mutex myMutex
Mutex object to allow thread safety.
Definition: DtCDBTileCache.h:293
std::map< std::string, bool > DtLogitudeGeocellMap
type for the longitude map as a string representation
Definition: DtCDBTileCache.h:146
static int theMaxGeoPoliticalConstraintPointLod
Definition: DtCDBTileCache.h:255
CDB Tile cache manager Used by CDBTileSource to try to avoid reading the the same CDB tile many time ...
Definition: DtCDBTileCache.h:34
static int theMaxGsAirportArealFeatureLod
Definition: DtCDBTileCache.h:237
static int theMaxGeoPoliticalBoundaryPointLod
Maximum LOD of the GeoPolitical dataset.
Definition: DtCDBTileCache.h:249
Least-recently-used cache class.
Definition: DtOsgLRUCache.h:41
static int theMaxGsNaturalLinealFeatureLod
Definition: DtCDBTileCache.h:233
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:206
std::map< int, bool > DtLogitudeGeocellIntMap
type for the longitude map as an integer representation
Definition: DtCDBTileCache.h:149
#define DT_DLL_OSGEARTH_CDB_UTILS
Definition: DtCDBExport.h:18
static int theMaxGeoPoliticalConstraintArealLod
Definition: DtCDBTileCache.h:257
static int theMaxGsAirportPointFeatureLod
Definition: DtCDBTileCache.h:231
static int theMaxGtManMadeArealFeatureLod
Definition: DtCDBTileCache.h:243
static int theMaxGtManMadeLinealFeatureLod
Definition: DtCDBTileCache.h:242
static int theMaxImageryLod
Maximum LOD of the imagery dataset.
Definition: DtCDBTileCache.h:221
makVrv::LRUCache< std::string, osg::ref_ptr< osg::HeightField > > ElevationCDBsCache
LRU cache map type for elevation.
Definition: DtCDBTileCache.h:203
static int theMaxLatitude
Max Latitude.
Definition: DtCDBTileCache.h:290
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:160
static int theMaxGsNaturalArealFeatureLod
Definition: DtCDBTileCache.h:236
static int theMaxRoadNetworkAirportArealLod
Definition: DtCDBTileCache.h:262
for each CDB database keep track of the lat/lon geocell that exist
Definition: DtCDBTileCache.h:152
static int theMaxElevationLod
Maximum LOD of the elevation dataset.
Definition: DtCDBTileCache.h:217
static int theMaxGtTreePointFeatureLod
Definition: DtCDBTileCache.h:244
static int theMaxPowerLineNetworkLod
Maximum LOD of the PowerLineNetwork dataset.
Definition: DtCDBTileCache.h:268
static int theMaxGeoPoliticalLocationArealLod
Definition: DtCDBTileCache.h:254
static int theMaxGeoPoliticalBoundaryArealLod
Definition: DtCDBTileCache.h:251
static int theMaxGeoPoliticalLocationPointLod
Definition: DtCDBTileCache.h:252
osgEarth::GeoExtent myCdbExtent
database extent
Definition: DtCDBTileCache.h:164
static int theMaxLongitude
Max Longitude.
Definition: DtCDBTileCache.h:284
static int theMinLatitude
Min Latitude.
Definition: DtCDBTileCache.h:287
static int theMaxBathymetryLod
Definition: DtCDBTileCache.h:218
static int theMaxGeoPoliticalConstraintLinealLod
Definition: DtCDBTileCache.h:256
static int theMaxHydrographyNetworkArealLod
Definition: DtCDBTileCache.h:272
makVrv::LRUCache< std::string, osg::ref_ptr< osg::Image > > ImageCDBsCache
LRU cache map type for imagery.
Definition: DtCDBTileCache.h:196
std::vector< DatasetInfo > myDatasetList
List of datasets using this map.
Definition: DtCDBTileCache.h:162
size_t myNbCacheSize
Default number of cache file 20, but can be set via the config.
Definition: DtCDBTileCache.h:211
CDB Dataset information class.
Definition: DtCDBDatasetInfo.h:24
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))
static int theMaxGtTreeLinealFeatureLod
Definition: DtCDBTileCache.h:245
Threading::Mutex myCdbImageryCacheMutex
Image Mutex object to allow thread safety.
Definition: DtCDBTileCache.h:200
static int theMaxGsManMadeLinealFeatureLod
Definition: DtCDBTileCache.h:232
std::string myCdbRootPath
Current CDB Root path.
Definition: DtCDBTileCache.h:214
OpenThreads::Mutex Mutex
Definition: DtOsgThreadingUtils.h:12
static int theMaxGsEnvironmentPointFeatureLod
Definition: DtCDBTileCache.h:238
ImageCDBsCache myCdbImageryCache
LRU cache map for imagery.
Definition: DtCDBTileCache.h:198
static int theMaxGtTreeArealFeatureLod
Definition: DtCDBTileCache.h:246
static int theMaxGeoPoliticalBoundaryLinealLod
Definition: DtCDBTileCache.h:250
static int theMinLongitude
Min Longitude.
Definition: DtCDBTileCache.h:281
static int theMaxHydrographyNetworkLinealLod
Maximum LOD of the HydrographyNetwork dataset.
Definition: DtCDBTileCache.h:271
std::map< std::string, osg::ref_ptr< CDBDatabaseGeocellMap > > DtDatabasesGeocellMap
Type for the map of the existing geocell by CDB database.
Definition: DtCDBTileCache.h:168
static int theMaxGsManMadePointFeatureLod
Maximum LOD of the GS Feature dataset.
Definition: DtCDBTileCache.h:228
static int theMaxGtManMadePointFeatureLod
Maximum LOD of the GT Feature dataset.
Definition: DtCDBTileCache.h:241
static int theMaxRoadNetworkAirportLinealLod
Definition: DtCDBTileCache.h:261
static int theMaxRasterMaterialLod
Maximum LOD of the raster material dataset.
Definition: DtCDBTileCache.h:225
Threading::Mutex myCdbElevationCacheMutex
Elevation Mutex object to allow thread safety.
Definition: DtCDBTileCache.h:208
static int theMaxRailRoadNetworkLod
Maximum LOD of the RailRoadNetwork dataset.
Definition: DtCDBTileCache.h:265
static int theMaxGsTreePointFeatureLod
Definition: DtCDBTileCache.h:230
static int theMaxT2dLod
Maximum LOD of the t2d model geometry dataset.
Definition: DtCDBTileCache.h:278
static int theMaxGsManMadeArealFeatureLod
Definition: DtCDBTileCache.h:235
static int theMaxRoadNetworkLinealLod
Maximum LOD of the RoadNetwork dataset.
Definition: DtCDBTileCache.h:260
static int theMaxLightMapLod
Definition: DtCDBTileCache.h:222
static int theMaxGsAirportLinealFeatureLod
Definition: DtCDBTileCache.h:234

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)