1 #include <boost/format.hpp>
2 #include <boost/lexical_cast.hpp>
4 #include <det/Detector.h>
6 #include <rdet/RDetector.h>
7 #include <rdet/RStationListManager.h>
9 #include <utl/UTCDateTime.h>
15 using namespace ::boost::multi_index;
24 const string& componentProperty,
28 const int id = GetStationId(componentIndex);
30 const StationIdIndex::const_iterator sIt = idIndex.find(
id);
32 if (sIt == idIndex.end())
33 return VManager::eNotFound;
35 if (componentProperty ==
"inGrid")
36 returnData = sIt->fInGrid;
37 else if (componentProperty ==
"zone")
38 returnData = sIt->fZone;
39 else if (componentProperty ==
"nChannels")
40 returnData = sIt->fNChannels;
41 else if (componentProperty ==
"firstChannelId")
42 returnData = sIt->fFirstChannelId;
43 else if (componentProperty ==
"lastChannelId")
44 returnData = sIt->fLastChannelId;
45 else if (componentProperty ==
"virtual")
46 returnData = sIt->fIsVirtual;
48 return VManager::eNotFound;
50 return VManager::eFound;
58 const string& componentProperty,
62 const int id = GetStationId(componentIndex);
64 const StationIdIndex::const_iterator sIt = idIndex.find(
id);
66 if (sIt == idIndex.end())
67 return VManager::eNotFound;
69 if (componentProperty ==
"northing")
70 returnData = sIt->fNorthing;
71 else if (componentProperty ==
"easting")
72 returnData = sIt->fEasting;
73 else if (componentProperty ==
"altitude")
74 returnData = sIt->fAltitude;
76 return VManager::eNotFound;
78 return VManager::eFound;
86 const string& componentProperty,
90 const int id = GetStationId(componentIndex);
92 const StationIdIndex::const_iterator sIt = idIndex.find(
id);
94 if (sIt == idIndex.end())
95 return VManager::eNotFound;
97 if (componentProperty ==
"name")
98 returnData = sIt->fName;
99 else if (componentProperty ==
"commission")
100 returnData = sIt->fCommissionTime;
101 else if (componentProperty ==
"decommission")
102 returnData = sIt->fDecommissionTime;
103 else if (componentProperty ==
"band")
104 returnData = sIt->fBand;
105 else if (componentProperty ==
"ellipsoid")
106 returnData = sIt->fEllipsoid;
107 else if (componentProperty ==
"source")
108 returnData = sIt->fSource;
110 return VManager::eNotFound;
112 return VManager::eFound;
120 const string& componentProperty,
128 if (fStations.empty() && !Detector::GetInstance().GetRDetector().AddStationListFromSManager())
129 return VManager::eNotFound;
131 if (componentProperty ==
"fullStationList")
132 GetFullStationList(returnData);
134 return VManager::eNotFound;
136 return VManager::eFound;
148 if (fStations.empty())
149 return VManager::eNotFound;
151 return VManager::eFound;
158 if (HasStationData(station.
fId))
166 fStations.insert(station);
180 if (HasStationData(station.
fId)) {
183 StationIdIndex::iterator station_to_be_replaced = station_by_id.find(station.
fId);
184 station_by_id.replace(station_to_be_replaced, station);
186 fStations.insert(station);
194 std::vector<int> remove_station_ids;
195 for (
auto& station : fStations) {
196 if (station.fSource == source_type)
197 remove_station_ids.push_back(station.fId);
200 for (
auto&
id : remove_station_ids)
209 if (HasStationData(station.
fId)) {
212 StationIdIndex::iterator station_to_be_removed = station_by_id.find(station.
fId);
213 station_by_id.erase(station_to_be_removed);
226 return idIndex.find(
id) != idIndex.end();
236 for (StationIdIndex::const_iterator sIt = idIndex.begin(); sIt != idIndex.end(); ++sIt)
237 returnList.push_back(sIt->fId);
247 for (string::const_iterator it = str.begin(); it != str.end(); ++it)
265 if (fStations.empty())
268 boost::format stationFmt(
269 "%1%<station id=\"%2%\">\n"
270 "%1% <northing unit=\"meter\"> %|3$.2f| </northing>\n"
271 "%1% <easting unit=\"meter\"> %|4$.2f| </easting>\n"
272 "%1% <altitude unit=\"meter\"> %|5$.2f| </altitude>\n"
273 "%1% <name> %6% </name>\n"
274 "%1% <commission> %7% </commission>\n"
275 "%1% <decommission> %8% </decommission>\n"
276 "%1% <inGrid> %9% </inGrid>\n"
277 "%1% <ellipsoid> %13% </ellipsoid>\n"
278 "%1% <zone> %14% </zone>\n"
279 "%1% <band> %15% </band>\n"
284 for (StationIdIndex::const_iterator sIt = sIndex.begin();
285 sIt != sIndex.end(); ++sIt)
294 % sIt->fCommissionTime
295 % sIt->fDecommissionTime
string StringToXMLString(const string &str)
bool ConditionalAddStationData(StationData &station)
adds station record only if it does not already exist
std::string fDecommissionTime
bool RemoveStationData(StationData &station)
Removes station data if manager has station.
Time interval defined by two TimeStamps.
A TimeStamp holds GPS second and nanosecond for some event.
det::VManager::Status GetData(T &returnData, const std::string &componentProperty, const det::VManager::IndexMap &componentIndex) const
bool DumpXML(std::ostream &output, const std::string &indent="") const
void GetFullStationList(std::vector< int > &returnList) const
bool HasStationData(const int id) const
index< StationContainer, ByStationId >::type StationIdIndex
std::map< std::string, std::string > IndexMap
void ClearStations(const std::string source_type)
Removes all stations from fStations with fSource == source_type.
utl::TimeRange fCommissionTimeRange
std::string fCommissionTime
void AddOrReplaceStationData(StationData &station)
adds station record and might overright old entry
Status
Specifies success or (eventually) various possible failure modes.