At a high level, the steps are this:
1. Get a pointer to a particular input data item that you know has the metadata
2. Get the input item's metadata collection
3. Get the metadata collection's metadata item for BeginningOrbitNumber
4. Get the value of that metadata item.
I added the below code to the top of ProSdrViirsCal::doProcessing() and it printed the BeginningOrbitNumber value.
Code: Select all
1 // Get a data item pointer
2 ProCmnDataItem* itemPtr = getInputItem(VIIRS_RDR_VERIFIED);
3
4 if(itemPtr != 0)
5 {
6 UInt32 beginningOrbitvalue = 0;
7
8 DmCoreItemAbs* mdItemPtr = 0;
9 DmCoreMetadataCollection* mdCollectionPtr = 0;
10
11 // Get the data item's metadata pointer
12 mdCollectionPtr = itemPtr->getMetadata();
13
14 if(mdCollectionPtr != 0)
15 {
16 // Get the beginning orbit number metadata item from the collection
17 mdItemPtr = mdCollectionPtr->findMetadata(
18 DmCoreItemAbs::UINTEGER,
19 BEGINNINGORBITNUMBER.c_str());
20
21 if(mdItemPtr != 0)
22 {
23 // Get the value from the metadata item
24 beginningOrbitvalue =
25 static_cast<DmCoreItemUInteger*>(mdItemPtr)->getValue();
26
27 std::cout << "beginningOrbitvalue is "
28 << beginningOrbitvalue
29 << std::endl;
30 }
31 }
32 }
33 else
34 {
35 std::cout << "Unable to get input item" << std::endl;
36 }
Line 2 gets a pointer to an input data item that is already an input to this algorithm. VIIRS_RDR_VERIFIED is a string constant for the group name (not CollectionShortName) of the item. So in this example from ProSdrViirsVerifiedRdr_CFG.xml
Code: Select all
<group name="VIIRS-SCIENCE-RDR-Verified">
<config>
<name>DataEndianType</name>
<configValue>Both</configValue>
</config>
<config>
<name>OfficialShortName</name>
<configValue>VIIRS-SCIENCE-RDR-Verified</configValue>
</config>
<config>
<name>OutputType</name>
<!-- -->
<!-- Note changing this from heap will output -->
<!-- it with a dataset type tag which is not -->
<!-- supported in the DPIS -->
<!-- -->
<configValue>HEAP</configValue>
</config>
</group>
It's the value from <group name="VIIRS-SCIENCE-RDR-Verified"> that should be used. (Though in this case it's the same as the collection short name). That string constant is from $ADL_HOME/CMN/PROStrings/src/ProCmnShortNames.cpp. ProCmnShortNames.cpp is a poorly named file because it actually contains group name values, not short name values.
Each ProCmDataItem contains a metadata collection of type DmCoreMetadataCollection*. So on line 12 we get that collection.
Each DmCoreMetadataCollection contains one or more items with a base class of DmCoreItemAbs ("Abs" is for Abstract). On line 17-19, we try to find a metadata item of type DmCoreItemAbs::UINTEGER (defined $ADL_HOME/CMN/Utilities/DMS/include/DmCoreItemAbs.h) and a name of BEGINNINGORBITNUMBER (defined in $ADL_HOME/CMN/PROStrings/src/ProCmnMetadata.cpp). The easiest way to determine the type and name is to look at a .asc file:
Code: Select all
("BeginningOrbitNumber" UINTEGER EQ 14)
Once we have the individual metadata item, (from line 17), we need to cast it from its base type of DmCoreItemAbs* to a DmCoreItemUInteger* so that getValue() can return the proper type.