本文整理汇总了C++中DataDescriptor::getFileDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C++ DataDescriptor::getFileDescriptor方法的具体用法?C++ DataDescriptor::getFileDescriptor怎么用?C++ DataDescriptor::getFileDescriptor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataDescriptor
的用法示例。
在下文中一共展示了DataDescriptor::getFileDescriptor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize
bool PropertiesFileDescriptor::initialize(SessionItem* pSessionItem)
{
FileDescriptorWidget* pDescriptorPage = dynamic_cast<FileDescriptorWidget*>(getWidget());
if (pDescriptorPage == NULL)
{
return false;
}
DataElement* pElement = dynamic_cast<DataElement*>(pSessionItem);
if (pElement != NULL)
{
DataDescriptor* pDescriptor = pElement->getDataDescriptor();
if (pDescriptor != NULL)
{
const FileDescriptor* pFileDescriptor = pDescriptor->getFileDescriptor();
if (pFileDescriptor != NULL)
{
pDescriptorPage->setFileDescriptor(pFileDescriptor);
return true;
}
}
}
return false;
}
示例2: createRasterPager
bool DiHdfImporter::createRasterPager(RasterElement *pRaster) const
{
VERIFY(pRaster != NULL);
DataDescriptor *pDescriptor = pRaster->getDataDescriptor();
VERIFY(pDescriptor != NULL);
FileDescriptor *pFileDescriptor = pDescriptor->getFileDescriptor();
VERIFY(pFileDescriptor != NULL);
std::string filename = pRaster->getFilename();
Progress *pProgress = getProgress();
FactoryResource<Filename> pFilename;
pFilename->setFullPathAndName(filename);
ExecutableResource pagerPlugIn("DiHdfRasterPager", std::string(), pProgress);
pagerPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedElementArg(), pRaster);
pagerPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedFilenameArg(), pFilename.get());
bool success = pagerPlugIn->execute();
RasterPager *pPager = dynamic_cast<RasterPager*>(pagerPlugIn->getPlugIn());
if(!success || pPager == NULL)
{
std::string message = "Execution of DiHdfRasterPager failed!";
if (pProgress != NULL) pProgress->updateProgress(message, 0, ERRORS);
return false;
}
pRaster->setPager(pPager);
pagerPlugIn->releasePlugIn();
return true;
}
示例3: execute
bool SignatureSetImporter::execute(PlugInArgList* pInArgList, PlugInArgList* OutArgList)
{
VERIFY(pInArgList != NULL);
Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
ProgressTracker progress(pProgress, "Loading spectral signature library", "spectral", "7B21EE8A-D2E1-4325-BB9F-F4E521BFD5ED");
SignatureSet* pSignatureSet = pInArgList->getPlugInArgValue<SignatureSet>(Importer::ImportElementArg());
VERIFY(pSignatureSet != NULL);
DataDescriptor* pDataDescriptor = pSignatureSet->getDataDescriptor();
VERIFY(pDataDescriptor != NULL);
FileDescriptor* pFileDescriptor = pDataDescriptor->getFileDescriptor();
VERIFY(pFileDescriptor != NULL);
const string& filename = pFileDescriptor->getFilename().getFullPathAndName();
progress.getCurrentStep()->addProperty("signature set", pSignatureSet->getName());
progress.getCurrentStep()->addProperty("dataset location", pFileDescriptor->getDatasetLocation());
// locate the spot in the tree for this dataset
try
{
string expr;
vector<string> parts = StringUtilities::split(pFileDescriptor->getDatasetLocation(), '/');
for (vector<string>::iterator part = parts.begin(); part != parts.end(); ++part)
{
if (!part->empty())
{
expr += "/signature_set[metadata/@name='Name' and metadata/@value='" + *part + "']";
}
}
expr += "/signature";
loadDoc(filename);
DOMXPathResult* pResult = mXml[filename]->query(expr, DOMXPathResult::SNAPSHOT_RESULT_TYPE);
VERIFY(pResult != NULL);
int nodeTotal = pResult->getSnapshotLength();
for (int nodeNum = 0; nodeNum < nodeTotal; ++nodeNum)
{
if (isAborted())
{
progress.report("Aborted file " + pFileDescriptor->getFilename().getFullPathAndName(), 0, WARNING, true);
progress.report("User aborted the operation.", 0, ABORT, true);
return false;
}
int percent = static_cast<int>(100.0 * nodeNum / nodeTotal);
progress.report("Importing signature library", percent, NORMAL);
if (!pResult->snapshotItem(nodeNum) || !pResult->isNode())
{
continue;
}
const DOMElement* pElmnt = static_cast<const DOMElement*>(pResult->getNodeValue());
string filename = A(pElmnt->getAttribute(X("filename")));
if (filename.empty() == false)
{
string path = pFileDescriptor->getFilename().getPath();
QString tempFilename = QString::fromStdString(filename);
if (tempFilename.startsWith("./") == true)
{
tempFilename.replace(0, 1, QString::fromStdString(path));
filename = tempFilename.toStdString();
}
else
{
QFileInfo fileInfo(tempFilename);
if (fileInfo.isRelative() == true)
{
filename = path + SLASH + filename;
}
}
}
// don't pass progress to importer - the individual signature imports are rapid and passing progress will
// cause isAborted() to not function properly.
ImporterResource importer("Auto Importer", filename, NULL);
if (importer->getPlugIn() == NULL)
{
progress.report("The \"Auto Importer\" is not available and is required to import signature sets.", 0, ERRORS, true);
return false;
}
if (importer->execute())
{
vector<DataElement*> elements = importer->getImportedElements();
vector<Signature*> sigs(elements.size(), NULL);
for (vector<DataElement*>::iterator element = elements.begin(); element != elements.end(); ++element)
{
Signature* pSig = dynamic_cast<Signature*>(*element);
if (pSig != NULL)
{
pSignatureSet->insertSignature(pSig);
// reparent the signature
Service<ModelServices>()->setElementParent(pSig, pSignatureSet);
}
}
}
else
{
progress.report("Unable to import signature " + filename, percent, WARNING, true);
}
}
}
catch(DOMException &exc)
//.........这里部分代码省略.........
示例4: VERIFY
bool Nitf::NitfImporterShell::createRasterPager(RasterElement* pRaster) const
{
if (pRaster == NULL)
{
return false;
}
// Get the filename
string filename = pRaster->getFilename();
FactoryResource<Filename> pFilename;
pFilename->setFullPathAndName(filename);
// Get the image segment corresponding to this raster element
DataDescriptor* pDescriptor = pRaster->getDataDescriptor();
VERIFY(pDescriptor != NULL);
FileDescriptor* pFileDescriptor = pDescriptor->getFileDescriptor();
VERIFY(pFileDescriptor != NULL);
const string& datasetLocation = pFileDescriptor->getDatasetLocation();
if (datasetLocation.empty() == true)
{
return false;
}
string imageSegmentText = datasetLocation.substr(1);
unsigned int imageSegment = StringUtilities::fromDisplayString<unsigned int>(imageSegmentText) - 1;
// Create the resource to execute the pager
ExecutableResource pPlugIn;
// Check for J2K compression in the metadata of the raster element being imported and not the given raster
// element, because the given raster element may be a temporary raster element used by RasterElementImporterShell
// when the processing location is IN_MEMORY, which does not contain the metadata or the parent information
// (see RasterUtilities::generateUnchippedRasterDataDescriptor())
string imageCompression;
const RasterElement* pElement = getRasterElement();
if (pElement != NULL)
{
const DynamicObject* pMetadata = pElement->getMetadata();
VERIFYRV(pMetadata, NULL);
const string attributePath[] =
{
Nitf::NITF_METADATA,
Nitf::IMAGE_SUBHEADER,
Nitf::ImageSubheaderFieldNames::COMPRESSION,
END_METADATA_NAME
};
imageCompression = pMetadata->getAttributeByPath(attributePath).toDisplayString();
}
if ((imageCompression == Nitf::ImageSubheaderFieldValues::IC_C8) ||
(imageCompression == Nitf::ImageSubheaderFieldValues::IC_M8))
{
// Get the offset and size of the image segment in the file
uint64_t offset = getImageOffset(filename, imageSegment);
uint64_t size = getImageSize(filename, imageSegment);
// Use the JPEG2000 pager
pPlugIn->setPlugIn("JPEG2000 Pager");
pPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedElementArg(), pRaster);
pPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedFilenameArg(), pFilename.get());
pPlugIn->getInArgList().setPlugInArgValue("Offset", &offset);
pPlugIn->getInArgList().setPlugInArgValue("Size", &size);
}
else
{
// Use the NITF Pager
pPlugIn->setPlugIn("NitfPager");
pPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedElementArg(), pRaster);
pPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedFilenameArg(), pFilename.get());
pPlugIn->getInArgList().setPlugInArgValue("Segment Number", &imageSegment);
}
if (pPlugIn->execute() == true)
{
RasterPager* pPager = dynamic_cast<RasterPager*>(pPlugIn->getPlugIn());
if (pPager != NULL)
{
pRaster->setPager(pPager);
pPlugIn->releasePlugIn();
return true;
}
}
return false;
}
示例5: execute
bool SignatureImporter::execute(PlugInArgList* pInArgList, PlugInArgList* OutArgList)
{
VERIFY(pInArgList != NULL);
ProgressTracker progress(pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()),
"Loading spectral signature", "spectral", "5A9F8379-7D7D-4575-B78B-305AE0DFC66D");
Signature* pSignature = pInArgList->getPlugInArgValue<Signature>(Importer::ImportElementArg());
VERIFY(pSignature != NULL);
DataDescriptor* pDataDescriptor = pSignature->getDataDescriptor();
VERIFY(pDataDescriptor != NULL);
FileDescriptor* pFileDescriptor = pDataDescriptor->getFileDescriptor();
VERIFY(pFileDescriptor != NULL);
progress.getCurrentStep()->addProperty("filename", pFileDescriptor->getFilename().getFullPathAndName());
DynamicObject* pMetadata = pSignature->getMetadata();
VERIFY(pMetadata != NULL);
string warningMsg;
LargeFileResource pSigFile;
VERIFY(pSigFile.open(pFileDescriptor->getFilename().getFullPathAndName(), O_RDONLY | O_BINARY, S_IREAD));
const Units* pUnits = pSignature->getUnits("Reflectance");
VERIFY(pUnits != NULL);
// Read the signature data
vector<double> wavelengthData, reflectanceData;
int64_t fileSize = pSigFile.fileLength();
bool readError = false;
size_t largeValueCount(0);
for (string line = pSigFile.readLine(&readError); readError == false; line = pSigFile.readLine(&readError))
{
if (isAborted())
{
progress.report("Importer aborted", 0, ABORT, true);
return false;
}
int64_t fileLocation = pSigFile.tell();
progress.report("Loading signature data", static_cast<int>(fileLocation * 100.0 / fileSize), NORMAL);
trim(line);
if (line.empty())
{
continue;
}
if (line.find('=') == string::npos)
{
double wavelength = 0.0, reflectance = 0.0;
vector<string> dataEntry;
split(dataEntry, line, is_space());
bool error = true;
if (dataEntry.size() >= 1)
{
wavelength = StringUtilities::fromXmlString<double>(dataEntry[0], &error);
if (wavelength > 50.0)
{
// Assume wavelength values are in nanometers and convert to microns
wavelength = Wavelengths::convertValue(wavelength, NANOMETERS, MICRONS);
}
}
if (!error && dataEntry.size() == 2)
{
reflectance = StringUtilities::fromXmlString<double>(dataEntry[1], &error);
// Since the signature file may not have contained info on units and unitScale (defaults to values of
// "REFLECTANCE" and "1.0"), we need to check that the reflectance value is properly scaled.
// In theory, a valid reflectance value should be between 0 and 1, but real data may extend beyond these
// limits due to errors that occurred in collection, calibration, conversion, etc. We're assuming that a
// value greater than 2.0 indicates that the value was scaled by a factor other than 1.0 - a common data
// collection practice is to store a data value as an integer value equal to the actual value multiplied
// by a scaling factor. This saves storage space while preserving precision. 10000 is a very common
// scaling factor and the one we will assume was used. Right now we'll just count the number of large values.
// If more than half the values are large, we will assume they were scaled and divide all the values by 10000.
if (pUnits->getUnitType() == REFLECTANCE && pUnits->getScaleFromStandard() == 1.0
&& fabs(reflectance) > 2.0)
{
++largeValueCount;
}
}
if (error)
{
progress.report("Error parsing signature data", 0, ERRORS, true);
}
wavelengthData.push_back(wavelength);
reflectanceData.push_back(reflectance);
}
}
if ((readError == true) && (pSigFile.eof() != 1))
{
progress.report("Unable to read signature file", 0, ERRORS, true);
return false;
}
// check for need to scale the values, i.e., at least half the values are large
if (reflectanceData.empty() == false && largeValueCount > 0 && largeValueCount >= (reflectanceData.size() / 2))
{
//.........这里部分代码省略.........