本文整理汇总了C++中RasterElement::getMetadata方法的典型用法代码示例。如果您正苦于以下问题:C++ RasterElement::getMetadata方法的具体用法?C++ RasterElement::getMetadata怎么用?C++ RasterElement::getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RasterElement
的用法示例。
在下文中一共展示了RasterElement::getMetadata方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VERIFYRV
SpatialDataView* Nitf::NitfImporterShell::createView() const
{
SpatialDataView* pView = RasterElementImporterShell::createView();
VERIFYRV(pView != NULL, pView);
RasterElement* pRaster = getRasterElement();
VERIFYRV(pRaster != NULL, pView);
const DynamicObject* pMetadata = pRaster->getMetadata();
VERIFYRV(pMetadata != NULL, pView);
const string backgroundColorPath[] = { Nitf::NITF_METADATA, Nitf::FILE_HEADER,
Nitf::FileHeaderFieldNames::BACKGROUND_COLOR, END_METADATA_NAME };
const DataVariant& dvBackground = pMetadata->getAttributeByPath(backgroundColorPath);
if (dvBackground.isValid() == true)
{
ColorType ctBackground;
VERIFY(dvBackground.getValue(ctBackground) == true);
pView->setBackgroundColor(ctBackground);
pView->refresh();
}
return pView;
}
示例2: generateResampledLibrary
bool SpectralLibraryManager::generateResampledLibrary(const RasterElement* pRaster)
{
VERIFY(pRaster != NULL);
// check that lib sigs are in same units as the raster element
const RasterDataDescriptor* pDesc = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
VERIFY(pDesc != NULL);
const Units* pUnits = pDesc->getUnits();
if (pDesc->getUnits()->getUnitType() != mLibraryUnitType)
{
if (Service<DesktopServices>()->showMessageBox("Mismatched Units", "The data are not in the "
"same units as the spectral library.\n Do you want to continue anyway?", "Yes", "No") == 1)
{
return false;
}
}
FactoryResource<Wavelengths> pWavelengths;
pWavelengths->initializeFromDynamicObject(pRaster->getMetadata(), false);
// populate the library with the resampled signatures
PlugInResource pPlugIn("Resampler");
Resampler* pResampler = dynamic_cast<Resampler*>(pPlugIn.get());
VERIFY(pResampler != NULL);
if (pWavelengths->getNumWavelengths() != pDesc->getBandCount())
{
mpProgress->updateProgress("Wavelength information in metadata does not match the number of bands "
"in the raster element", 0, ERRORS);
return false;
}
// get resample suitable signatures - leave out signatures that don't cover the spectral range of the data
std::vector<std::vector<double> > resampledData;
resampledData.reserve(mSignatures.size());
std::vector<Signature*> resampledSignatures;
resampledSignatures.reserve(mSignatures.size());
std::vector<std::string> unsuitableSignatures;
std::vector<double> sigValues;
std::vector<double> sigWaves;
std::vector<double> rasterWaves = pWavelengths->getCenterValues();
std::vector<double> rasterFwhm = pWavelengths->getFwhm();
std::vector<double> resampledValues;
std::vector<int> bandIndex;
DataVariant data;
for (std::vector<Signature*>::const_iterator it = mSignatures.begin(); it != mSignatures.end(); ++it)
{
data = (*it)->getData(SpectralLibraryMatch::getNameSignatureWavelengthData());
VERIFY(data.isValid());
VERIFY(data.getValue(sigWaves));
resampledValues.clear();
data = (*it)->getData(SpectralLibraryMatch::getNameSignatureAmplitudeData());
VERIFY(data.isValid());
VERIFY(data.getValue(sigValues));
double scaleFactor = (*it)->getUnits(
SpectralLibraryMatch::getNameSignatureAmplitudeData())->getScaleFromStandard();
for (std::vector<double>::iterator sit = sigValues.begin(); sit != sigValues.end(); ++sit)
{
*sit *= scaleFactor;
}
std::string msg;
if (pResampler->execute(sigValues, resampledValues, sigWaves, rasterWaves, rasterFwhm, bandIndex, msg) == false
|| resampledValues.size() != rasterWaves.size())
{
unsuitableSignatures.push_back((*it)->getName());
continue;
}
resampledData.push_back(resampledValues);
resampledSignatures.push_back(*it);
}
if (resampledSignatures.empty())
{
std::string errMsg = "None of the signatures in the library cover the spectral range of the data.";
if (mpProgress != NULL)
{
mpProgress->updateProgress(errMsg, 0, ERRORS);
return false;
}
}
if (unsuitableSignatures.empty() == false)
{
std::string warningMsg = "The following library signatures do not cover the spectral range of the data:\n";
for (std::vector<std::string>::iterator it = unsuitableSignatures.begin();
it != unsuitableSignatures.end(); ++it)
{
warningMsg += *it + "\n";
}
warningMsg += "These signatures will not be searched for in the data.";
Service<DesktopServices>()->showMessageBox("SpectralLibraryManager", warningMsg);
StepResource pStep("Spectral LibraryManager", "spectral", "64B6C87A-A6C3-4378-9B6E-221D89D8707B");
pStep->finalize(Message::Unresolved, warningMsg);
}
std::string libName = "Resampled Spectral Library";
// Try to get the resampled lib element in case session was restored. If NULL, create a new raster element with
// num rows = num valid signatures, num cols = 1, num bands = pRaster num bands
//.........这里部分代码省略.........
示例3: processAll
bool AceAlgorithm::processAll()
{
auto_ptr<Wavelengths> pWavelengths;
ProgressTracker progress(getProgress(), "Starting Ace", "spectral", "C4320027-6359-4F5B-8820-8BC72BF1B8F0");
RasterElement* pElement = getRasterElement();
if (pElement == NULL)
{
progress.report(ACEERR012, 0, ERRORS, true);
return false;
}
const RasterDataDescriptor* pDescriptor = static_cast<RasterDataDescriptor*>(pElement->getDataDescriptor());
VERIFY(pDescriptor != NULL);
BitMaskIterator iter(getPixelsToProcess(), pElement);
unsigned int numRows = iter.getNumSelectedRows();
unsigned int numColumns = iter.getNumSelectedColumns();
unsigned int numBands = pDescriptor->getBandCount();
Opticks::PixelOffset layerOffset(iter.getColumnOffset(), iter.getRowOffset());
// get cube wavelengths
DynamicObject* pMetadata = pElement->getMetadata();
if (pMetadata != NULL)
{
pWavelengths.reset(new Wavelengths(pMetadata));
if (!pWavelengths->isEmpty() && (!pWavelengths->hasEndValues() || !pWavelengths->hasStartValues()))
{
pWavelengths->calculateFwhm();
}
}
VERIFY(pWavelengths.get() != NULL);
int sig_index = 0;
bool bSuccess = true;
if (mInputs.mSignatures.empty())
{
progress.report(ACEERR005, 0, ERRORS, true);
return false;
}
int iSignatureCount = mInputs.mSignatures.size();
// Create a vector for the signature names
vector<string> sigNames;
RasterElement* pResults = NULL;
bool resultsIsTemp = false;
Signature* pSignature = mInputs.mSignatures[sig_index];
sigNames.push_back(pSignature->getName());
std::string rname = mInputs.mResultsName;
if (iSignatureCount > 1 && !mInputs.mbCreatePseudocolor)
{
rname += " " + sigNames.back();
}
else if (iSignatureCount > 1)
{
rname += "AceTemp";
resultsIsTemp = true;
}
pResults = createResults(numRows, numColumns, rname);
if (pResults == NULL)
{
return false;
}
vector<double> spectrumValues;
vector<int> resampledBands;
bSuccess = resampleSpectrum(pSignature, spectrumValues, *pWavelengths.get(), resampledBands);
// Check for limited spectral coverage and warning log
if (bSuccess && pWavelengths->hasCenterValues() &&
resampledBands.size() != pWavelengths->getCenterValues().size())
{
QString buf = QString("Warning AceAlg014: The spectrum only provides spectral coverage for %1 of %2 bands.")
.arg(resampledBands.size()).arg(pWavelengths->getCenterValues().size());
progress.report(buf.toStdString(), 0, WARNING, true);
}
BitMaskIterator iterChecker(getPixelsToProcess(), pElement);
EncodingType type = pDescriptor->getDataType();
switchOnEncoding(type, aceAlg, NULL, pElement, pResults, spectrumValues, mpProgress);
/////////////////////////////////////////////////////
vector<ColorType> layerColors, excludeColors;
excludeColors.push_back(ColorType(0, 0, 0));
excludeColors.push_back(ColorType(255, 255, 255));
ColorType::getUniqueColors(iSignatureCount, layerColors, excludeColors);
ColorType color;
if (0 <= static_cast<int>(layerColors.size()))
{
color = layerColors[0];
}
//.........这里部分代码省略.........
示例4: processAll
bool SamAlgorithm::processAll()
{
auto_ptr<Wavelengths> pWavelengths;
ProgressTracker progress(getProgress(), "Starting SAM", "spectral", "C4320027-6359-4F5B-8820-8BC72BF1B8F0");
progress.getCurrentStep()->addProperty("Interactive", isInteractive());
RasterElement* pElement = getRasterElement();
if (pElement == NULL)
{
progress.report(SAMERR012, 0, ERRORS, true);
return false;
}
progress.getCurrentStep()->addProperty("Cube", pElement->getName());
const RasterDataDescriptor* pDescriptor = static_cast<RasterDataDescriptor*>(pElement->getDataDescriptor());
VERIFY(pDescriptor != NULL);
BitMaskIterator iter(getPixelsToProcess(), pElement);
unsigned int numRows = iter.getNumSelectedRows();
unsigned int numColumns = iter.getNumSelectedColumns();
unsigned int numBands = pDescriptor->getBandCount();
Opticks::PixelOffset layerOffset(iter.getColumnOffset(), iter.getRowOffset());
// get cube wavelengths
DynamicObject* pMetadata = pElement->getMetadata();
if (pMetadata != NULL)
{
pWavelengths.reset(new Wavelengths(pMetadata));
if (!pWavelengths->isEmpty() && (!pWavelengths->hasEndValues() || !pWavelengths->hasStartValues()))
{
pWavelengths->calculateFwhm();
}
}
VERIFY(pWavelengths.get() != NULL);
int sig_index = 0;
bool bSuccess = true;
if (mInputs.mSignatures.empty())
{
progress.report(SAMERR005, 0, ERRORS, true);
return false;
}
int iSignatureCount = mInputs.mSignatures.size();
// Get colors for all the signatures
vector<ColorType> layerColors, excludeColors;
excludeColors.push_back(ColorType(0, 0, 0));
excludeColors.push_back(ColorType(255, 255, 255));
ColorType::getUniqueColors(iSignatureCount, layerColors, excludeColors);
// Create a vector for the signature names
vector<string> sigNames;
// Create a pseudocolor results matrix if necessary
RasterElement* pPseudocolorMatrix = NULL;
RasterElement* pLowestSAMValueMatrix = NULL;
// Check for multiple Signatures and if the user has selected
// to combined multiple results in one pseudocolor output layer
if (iSignatureCount > 1 && mInputs.mbCreatePseudocolor)
{
pPseudocolorMatrix = createResults(numRows, numColumns, mInputs.mResultsName);
pLowestSAMValueMatrix = createResults(numRows, numColumns, "LowestSAMValue");
if (pPseudocolorMatrix == NULL || pLowestSAMValueMatrix == NULL )
{
progress.report(SAMERR007, 0, ERRORS, true);
return false;
}
FactoryResource<DataRequest> pseudoRequest;
pseudoRequest->setWritable(true);
string failedDataRequestErrorMessage =
SpectralUtilities::getFailedDataRequestErrorMessage(pseudoRequest.get(), pPseudocolorMatrix);
DataAccessor pseudoAccessor = pPseudocolorMatrix->getDataAccessor(pseudoRequest.release());
if (!pseudoAccessor.isValid())
{
string msg = "Unable to access results.";
if (!failedDataRequestErrorMessage.empty())
{
msg += "\n" + failedDataRequestErrorMessage;
}
progress.report(msg, 0, ERRORS, true);
return false;
}
FactoryResource<DataRequest> lsvRequest;
lsvRequest->setWritable(true);
failedDataRequestErrorMessage =
SpectralUtilities::getFailedDataRequestErrorMessage(lsvRequest.get(), pLowestSAMValueMatrix);
DataAccessor lowestSamValueAccessor = pLowestSAMValueMatrix->getDataAccessor(lsvRequest.release());
if (!lowestSamValueAccessor.isValid())
{
string msg = "Unable to access results.";
if (!failedDataRequestErrorMessage.empty())
{
msg += "\n" + failedDataRequestErrorMessage;
}
//.........这里部分代码省略.........