Skip to content
Snippets Groups Projects
Commit bc35db7d authored by Julien Osman's avatar Julien Osman
Browse files

REFAC: Implemented otb::ImageMetadata::append

parent 0fff6994
No related branches found
No related tags found
No related merge requests found
......@@ -232,7 +232,8 @@ public:
/** Extract metadata from a subset of the bands */
ImageMetadata slice(int start, int end);
/** concatenate with an other ImageMetadata */
/** concatenate with an other ImageMetadata
* If a key exists in bot ImageMetadata, keeps the value of this ImageMetadata.*/
void append(const ImageMetadata& );
/** if all bands share the same value of a key, put it at top level */
......
......@@ -292,9 +292,18 @@ ImageMetadata ImageMetadata::slice(int start, int end)
}
/** concatenate with an other ImageMetadata */
void ImageMetadata::append(const ImageMetadata& )
void ImageMetadata::append(const ImageMetadata& imd)
{
// TODO
// Copy the keys
this->GeometryKeys.insert(imd.GeometryKeys.begin(), imd.GeometryKeys.end());
this->NumericKeys.insert(imd.NumericKeys.begin(), imd.NumericKeys.end());
this->StringKeys.insert(imd.StringKeys.begin(), imd.StringKeys.end());
this->LUT1DKeys.insert(imd.LUT1DKeys.begin(), imd.LUT1DKeys.end());
this->LUT2DKeys.insert(imd.LUT2DKeys.begin(), imd.LUT2DKeys.end());
this->TimeKeys.insert(imd.TimeKeys.begin(), imd.TimeKeys.end());
this->ExtraKeys.insert(imd.ExtraKeys.begin(), imd.ExtraKeys.end());
// Copy the bands
this->Bands.insert(this->Bands.end(), imd.Bands.begin(), imd.Bands.end());
}
/** if all bands share the same value of a key, put it at top level */
......
......@@ -191,6 +191,15 @@ int otbImageMetadataTest(int argc, char* argv[])
md3 = md2.slice(0, 1);
outfile << "md3: "<< md3 << "\n";
ImageMetadata md4;
md4.Add(MDStr::SensorID, "PHR");
md4.Add(MDStr::ProductType, "Official");
md4.Add(std::string("Comment"), std::string("Test append"));
bmd.Add(MDStr::BandName, "B4");
md4.Bands.push_back(bmd);
md3.append(md4);
outfile << "md3_append: "<< md3 << "\n";
outfile.close();
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment