MCPcopy Create free account
hub / github.com/OSGeo/gdal / DefaultCopyMetadata

Method DefaultCopyMetadata

gcore/gdaldriver.cpp:913–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

911/************************************************************************/
912
913void GDALDriver::DefaultCopyMetadata(GDALDataset *poSrcDS, GDALDataset *poDstDS,
914 CSLConstList papszOptions,
915 CSLConstList papszExcludedDomains)
916{
917 const char *pszCopySrcMDD =
918 CSLFetchNameValueDef(papszOptions, "COPY_SRC_MDD", "AUTO");
919 char **papszSrcMDD = CSLFetchNameValueMultiple(papszOptions, "SRC_MDD");
920 if (EQUAL(pszCopySrcMDD, "AUTO") || CPLTestBool(pszCopySrcMDD) ||
921 papszSrcMDD)
922 {
923 if ((!papszSrcMDD || CSLFindString(papszSrcMDD, "") >= 0 ||
924 CSLFindString(papszSrcMDD, "_DEFAULT_") >= 0) &&
925 CSLFindString(papszExcludedDomains, "") < 0 &&
926 CSLFindString(papszExcludedDomains, "_DEFAULT_") < 0)
927 {
928 if (poSrcDS->GetMetadata() != nullptr)
929 poDstDS->SetMetadata(poSrcDS->GetMetadata());
930 }
931
932 /* -------------------------------------------------------------------- */
933 /* Copy transportable special domain metadata. */
934 /* It would be nice to copy geolocation, but it is pretty fragile. */
935 /* -------------------------------------------------------------------- */
936 constexpr const char *apszDefaultDomains[] = {
937 "RPC", "xml:XMP", "json:ISIS3", "json:VICAR"};
938 for (const char *pszDomain : apszDefaultDomains)
939 {
940 if ((!papszSrcMDD || CSLFindString(papszSrcMDD, pszDomain) >= 0) &&
941 CSLFindString(papszExcludedDomains, pszDomain) < 0)
942 {
943 CSLConstList papszMD = poSrcDS->GetMetadata(pszDomain);
944 if (papszMD)
945 poDstDS->SetMetadata(papszMD, pszDomain);
946 }
947 }
948
949 if ((!EQUAL(pszCopySrcMDD, "AUTO") && CPLTestBool(pszCopySrcMDD)) ||
950 papszSrcMDD)
951 {
952 for (const char *pszDomain :
953 CPLStringList(poSrcDS->GetMetadataDomainList()))
954 {
955 if (pszDomain[0] != 0 &&
956 (!papszSrcMDD ||
957 CSLFindString(papszSrcMDD, pszDomain) >= 0))
958 {
959 bool bCanCopy = true;
960 if (CSLFindString(papszExcludedDomains, pszDomain) >= 0)
961 {
962 bCanCopy = false;
963 }
964 else
965 {
966 for (const char *pszOtherDomain : apszDefaultDomains)
967 {
968 if (EQUAL(pszDomain, pszOtherDomain))
969 {
970 bCanCopy = false;

Callers

nothing calls this directly

Calls 8

CSLFetchNameValueDefFunction · 0.85
CPLTestBoolFunction · 0.85
CSLFindStringFunction · 0.85
EQUALFunction · 0.50
GetMetadataMethod · 0.45
SetMetadataMethod · 0.45
GetMetadataDomainListMethod · 0.45

Tested by

no test coverage detected