LidarDB.cc
Go to the documentation of this file.
1 #include <sstream>
2 #include <iostream>
3 #include <boost/lexical_cast.hpp>
4 
5 #include <det/Detector.h>
6 #include <utl/ErrorLogger.h>
7 #include <atm/Atmosphere.h>
8 #include <atm/LidarDB.h>
9 
10 #include <utl/AugerException.h>
11 
12 using namespace det;
13 using namespace std;
14 using namespace atm;
15 using namespace utl;
16 
17 
18 LidarDB::LidarDB()
19 {
20  // Find the id for this AerosolDB
21  // (this is just the primary key in the aerosol table for the given
22  // time, database version, etc.
23  VManager::IndexMap emptyIndexMap;
24 
25  const VManager& manager =
26  Detector::GetInstance().GetAManagerRegister().GetManager("ALidarSQLManager");
27 
28  const VManager::Status stat =
29  manager.GetData(fLidarIdString, "lidar", "lidar_id", emptyIndexMap);
30 
31  if (stat == VManager::eNotFound)
32  return; // return LidarDB with 0 zones
33 
34  CacheZones();
35 }
36 
37 
38 void
39 LidarDB::CacheZones()
40 {
41  // CacheZones should only be invoked when fZoneMap is 0
42  if (!fZoneMap.empty())
43  ERROR("Call to CacheZones with non-empty fZoneMap. This is a bug .. please report it");
44 
45  const VManager& manager =
46  Detector::GetInstance().GetAManagerRegister().GetManager("ALidarSQLManager");
47 
48  // Make an LidarZone object for each zone valid at the current
49  // detector time (and for specified software version, etc.)
50  vector<string> zoneIdStrings;
51  VManager::IndexMap indexMap;
52  indexMap["lidar_id"] = fLidarIdString;
53  const VManager::Status stat =
54  manager.GetData(zoneIdStrings, "zone", "zone_id", indexMap);
55 
56  if (stat == VManager::eNotFound)
57  throw DataNotFoundInDBException("zone", "zone_id", indexMap,
58  boost::lexical_cast<string>(Detector::GetInstance().GetTime()));
59 
60  for (vector<string>::iterator it = zoneIdStrings.begin();
61  it != zoneIdStrings.end(); ++it) {
62 
63  VManager::IndexMap zoneNameIndexMap;
64  zoneNameIndexMap["zone_id"] = *it;
65 
66  string zoneName;
67  manager.GetData(zoneName, "zone", "name", zoneNameIndexMap);
68 
69  double zoneNorthing;
70  manager.GetData(zoneNorthing, "zone", "northing", zoneNameIndexMap);
71 
72  double zoneEasting;
73  manager.GetData(zoneEasting, "zone", "easting", zoneNameIndexMap);
74 
75  const LidarZone* const aZone =
76  new LidarZone(*it, fLidarIdString, zoneName, zoneNorthing, zoneEasting);
77 
78  fZoneMap[zoneName] = aZone;
79  }
80 
81 }
82 
83 LidarDB::~LidarDB()
84 {
85  for (InternalZoneIterator it = fZoneMap.begin();
86  it != fZoneMap.end(); ++it)
87  delete it->second;
88 }
89 
InternalZoneMap::const_iterator InternalZoneIterator
Definition: LidarDB.h:32
Cloud data for a Lidar zone.
Definition: LidarZone.h:39
Interface for detector managers.
Definition: VManager.h:115
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
Exception to use in case requested data not found in the database with detailed printout.
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.