本文整理汇总了C++中DimensionDescriptor类的典型用法代码示例。如果您正苦于以下问题:C++ DimensionDescriptor类的具体用法?C++ DimensionDescriptor怎么用?C++ DimensionDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DimensionDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
DimensionDescriptor operator()(const DimensionDescriptor& val)
{
DimensionDescriptor temp = val;
temp.setActiveNumber(0);
temp.setActiveNumberValid(false);
return temp;
}
示例2: getBandNames
QStringList ReplaceBandInputWizard::getBandNames(const RasterDataDescriptor* pDesc) const
{
const DynamicObject* pMetadata = pDesc->getMetadata();
const std::vector<DimensionDescriptor>& bands = pDesc->getBands();
std::vector<std::string> bandNames;
std::string pNamesPath[] = { SPECIAL_METADATA_NAME, BAND_METADATA_NAME, NAMES_METADATA_NAME, END_METADATA_NAME };
const std::vector<std::string>* pBandNames = dv_cast<std::vector<std::string> >(&pMetadata->getAttributeByPath(pNamesPath));
if ((pBandNames != NULL) && (pBandNames->size() == bands.size()))
{
bandNames = *pBandNames;
}
else
{
std::string pPrefixPath[] = { SPECIAL_METADATA_NAME, BAND_NAME_PREFIX_METADATA_NAME, END_METADATA_NAME };
const std::string* pBandPrefix = dv_cast<std::string>(&pMetadata->getAttributeByPath(pPrefixPath));
if (pBandPrefix != NULL)
{
std::string bandNamePrefix = *pBandPrefix;
for (std::vector<DimensionDescriptor>::const_iterator band = bands.begin(); band != bands.end(); ++band)
{
bandNames.push_back(bandNamePrefix + " " + StringUtilities::toDisplayString(band->getOriginalNumber() + 1));
}
}
}
QStringList qBandNames;
for (unsigned int i = 0; i < bands.size(); i++)
{
DimensionDescriptor bandDim = bands[i];
QString name;
if ((i < bandNames.size()) && (bands.size() == bandNames.size()))
{
name = QString::fromStdString(bandNames[i]);
}
else
{
name = "Band ";
if (bandDim.isOriginalNumberValid())
{
unsigned int originalNumber = bandDim.getOriginalNumber() + 1;
name.append(QString::number(originalNumber));
}
}
qBandNames.append(name);
}
return qBandNames;
}
示例3: setDisplayBands
void PropertiesRasterLayer::setDisplayBands(QAction* pAction)
{
if (mpRasterLayer == NULL)
{
return;
}
RasterElement* pRasterElement = dynamic_cast<RasterElement*>(mpRasterLayer->getDataElement());
if (pRasterElement == NULL)
{
return;
}
const RasterDataDescriptor* pDescriptor =
dynamic_cast<const RasterDataDescriptor*>(pRasterElement->getDataDescriptor());
if (pDescriptor == NULL)
{
return;
}
const std::string name = pAction->text().toStdString();
DimensionDescriptor redBand;
DimensionDescriptor greenBand;
DimensionDescriptor blueBand;
if (RasterUtilities::findColorCompositeDimensionDescriptors(
pDescriptor, name, redBand, greenBand, blueBand) == false)
{
Service<DesktopServices>()->showSuppressibleMsgDlg("Error",
"Unable to display " + name + ": required wavelengths do not exist for all bands. "
"Broaden the wavelength region or specify band numbers in the Raster Layers section of the Options dialog.",
MESSAGE_ERROR, PropertiesRasterLayer::getDisplayAsWarningDialogId());
}
// If at least one of red, green, or blue is valid set display mode to RGB and update the combo boxes appropriately
if (redBand.isActiveNumberValid() || greenBand.isActiveNumberValid() || blueBand.isActiveNumberValid())
{
mpDisplayModeCombo->setCurrentIndex(1);
mpRedBandCombo->setCurrentIndex(redBand.isActiveNumberValid() ? redBand.getActiveNumber() : -1);
mpGreenBandCombo->setCurrentIndex(greenBand.isActiveNumberValid() ? greenBand.getActiveNumber() : -1);
mpBlueBandCombo->setCurrentIndex(blueBand.isActiveNumberValid() ? blueBand.getActiveNumber() : -1);
}
}
示例4: VERIFYRV
CachedPage::UnitPtr Jpeg2000Pager::populateImageData(const DimensionDescriptor& startRow,
const DimensionDescriptor& startColumn,
unsigned int concurrentRows, unsigned int concurrentColumns) const
{
VERIFYRV(startRow.isOnDiskNumberValid() == true, CachedPage::UnitPtr());
VERIFYRV(startColumn.isOnDiskNumberValid() == true, CachedPage::UnitPtr());
VERIFYRV(concurrentRows > 0, CachedPage::UnitPtr());
VERIFYRV(concurrentColumns > 0, CachedPage::UnitPtr());
// Get the rows, colums, and bands to load
unsigned int onDiskStartRow = startRow.getOnDiskNumber();
unsigned int onDiskStopRow = onDiskStartRow + concurrentRows;
unsigned int onDiskStartColumn = startColumn.getOnDiskNumber();
unsigned int onDiskStopColumn = onDiskStartColumn + concurrentColumns;
const RasterElement* pRaster = getRasterElement();
VERIFYRV(pRaster != NULL, CachedPage::UnitPtr());
const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
VERIFYRV(pDescriptor != NULL, CachedPage::UnitPtr());
const RasterFileDescriptor* pFileDescriptor =
dynamic_cast<const RasterFileDescriptor*>(pDescriptor->getFileDescriptor());
VERIFYRV(pFileDescriptor != NULL, CachedPage::UnitPtr());
const std::vector<DimensionDescriptor>& allBands = pFileDescriptor->getBands();
if (allBands.empty() == true)
{
return CachedPage::UnitPtr();
}
// Create the output data
unsigned int numPixels = concurrentRows * concurrentColumns * allBands.size();
unsigned int numBytes = numPixels * getBytesPerBand();
if (numPixels > static_cast<unsigned int>(std::numeric_limits<int>::max())) // ArrayResource only allocates up
// to INT_MAX number of values
{
return CachedPage::UnitPtr();
}
ArrayResource<Out> pDestination(numPixels, true);
char* pDest = reinterpret_cast<char*>(pDestination.get());
if (pDest == NULL)
{
return CachedPage::UnitPtr();
}
memset(pDest, 0, numPixels);
// Decode the image from the file, first trying the codestream format then the file format
opj_image_t* pImage = decodeImage(onDiskStartRow, onDiskStartColumn, onDiskStopRow, onDiskStopColumn,
Jpeg2000Utilities::J2K_CFMT);
if (pImage == NULL)
{
pImage = decodeImage(onDiskStartRow, onDiskStartColumn, onDiskStopRow, onDiskStopColumn,
Jpeg2000Utilities::JP2_CFMT);
}
if (pImage == NULL)
{
return CachedPage::UnitPtr();
}
// Populate the output image data
int bandFactor = 1;
std::string filename = pRaster->getFilename();
if (filename.empty() == false)
{
QStringList parts = QString::fromStdString(filename).split('.');
foreach (QString part, parts)
{
bool error;
EncodingType dataType = StringUtilities::fromXmlString<EncodingType>(part.toStdString(), &error);
if (dataType.isValid() == true && error == false)
{
int currentBandFactor = Jpeg2000Utilities::get_num_bands(dataType);
if (currentBandFactor > 0)
{
bandFactor = currentBandFactor;
break;
}
}
}
示例5: getRasterElement
CachedPage::UnitPtr Jpeg2000Pager::fetchUnit(DataRequest* pOriginalRequest)
{
if (pOriginalRequest == NULL)
{
return CachedPage::UnitPtr();
}
// Check for interleave conversions, which are not supported by this pager
const RasterElement* pRaster = getRasterElement();
VERIFYRV(pRaster != NULL, CachedPage::UnitPtr());
const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor());
VERIFYRV(pDescriptor != NULL, CachedPage::UnitPtr());
const RasterFileDescriptor* pFileDescriptor =
dynamic_cast<const RasterFileDescriptor*>(pDescriptor->getFileDescriptor());
VERIFYRV(pFileDescriptor != NULL, CachedPage::UnitPtr());
if (pFileDescriptor->getBandCount() > 1)
{
InterleaveFormatType requestedInterleave = pOriginalRequest->getInterleaveFormat();
InterleaveFormatType fileInterleave = pFileDescriptor->getInterleaveFormat();
if (requestedInterleave != fileInterleave)
{
return CachedPage::UnitPtr();
}
VERIFYRV(requestedInterleave == BIP, CachedPage::UnitPtr()); // The JPEG2000 data is stored BIP
}
// Get and validate the extents of the data to be loaded
DimensionDescriptor startRow = pOriginalRequest->getStartRow();
DimensionDescriptor stopRow = pOriginalRequest->getStopRow();
unsigned int concurrentRows = pOriginalRequest->getConcurrentRows();
DimensionDescriptor startColumn = pOriginalRequest->getStartColumn();
DimensionDescriptor stopColumn = pOriginalRequest->getStopColumn();
unsigned int concurrentColumns = pOriginalRequest->getConcurrentColumns();
DimensionDescriptor startBand = pOriginalRequest->getStartBand();
DimensionDescriptor stopBand = pOriginalRequest->getStopBand();
if ((startRow.isOnDiskNumberValid() == false) || (stopRow.isOnDiskNumberValid() == false) ||
(startColumn.isOnDiskNumberValid() == false) || (stopColumn.isOnDiskNumberValid() == false) ||
(startBand.isOnDiskNumberValid() == false) || (stopBand.isOnDiskNumberValid() == false))
{
return CachedPage::UnitPtr();
}
if ((startRow.getOnDiskNumber() > stopRow.getOnDiskNumber()) ||
(startColumn.getOnDiskNumber() > stopColumn.getOnDiskNumber()) ||
(startBand.getOnDiskNumber() > stopBand.getOnDiskNumber()))
{
return CachedPage::UnitPtr();
}
if ((startRow.getActiveNumber() + concurrentRows - 1) > stopRow.getActiveNumber())
{
concurrentRows = stopRow.getActiveNumber() - startRow.getActiveNumber() + 1;
}
if ((startColumn.getActiveNumber() + concurrentColumns - 1) > stopColumn.getActiveNumber())
{
concurrentColumns = stopColumn.getActiveNumber() - startColumn.getActiveNumber() + 1;
}
// Populate the image data based on the output data type
EncodingType outputDataType = pDescriptor->getDataType();
switch (outputDataType)
{
case INT1UBYTE:
return populateImageData<unsigned char>(startRow, startColumn, concurrentRows, concurrentColumns);
case INT1SBYTE:
return populateImageData<signed char>(startRow, startColumn, concurrentRows, concurrentColumns);
case INT2UBYTES:
return populateImageData<unsigned short>(startRow, startColumn, concurrentRows, concurrentColumns);
case INT2SBYTES:
return populateImageData<signed short>(startRow, startColumn, concurrentRows, concurrentColumns);
case INT4UBYTES:
return populateImageData<unsigned int>(startRow, startColumn, concurrentRows, concurrentColumns);
case INT4SBYTES:
return populateImageData<signed int>(startRow, startColumn, concurrentRows, concurrentColumns);
case FLT4BYTES:
return populateImageData<float>(startRow, startColumn, concurrentRows, concurrentColumns);
case FLT8BYTES:
return populateImageData<double>(startRow, startColumn, concurrentRows, concurrentColumns);
default:
break;
}
return CachedPage::UnitPtr();
}
示例6: pStep
bool EditDataDescriptor::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
StepResource pStep("Execute Wizard Item", "app", "055486F4-A9DB-4FDA-9AA7-75D1917E2C87");
pStep->addProperty("Item", getName());
mpStep = pStep.get();
if (extractInputArgs(pInArgList) == false)
{
return false;
}
// Set the values in the data descriptor
VERIFY(mpDescriptor != NULL);
// File descriptor
if (mpFileDescriptor != NULL)
{
mpDescriptor->setFileDescriptor(mpFileDescriptor);
}
// Processing location
if (mpProcessingLocation != NULL)
{
mpDescriptor->setProcessingLocation(*mpProcessingLocation);
}
RasterDataDescriptor* pRasterDescriptor = dynamic_cast<RasterDataDescriptor*>(mpDescriptor);
RasterFileDescriptor* pRasterFileDescriptor = dynamic_cast<RasterFileDescriptor*>(mpFileDescriptor);
SignatureDataDescriptor* pSignatureDescriptor = dynamic_cast<SignatureDataDescriptor*>(mpDescriptor);
SignatureFileDescriptor* pSignatureFileDescriptor = dynamic_cast<SignatureFileDescriptor*>(mpFileDescriptor);
if (pRasterDescriptor != NULL)
{
if (pRasterFileDescriptor != NULL)
{
// Set the rows and columns to match the rows and columns in the file descriptor before creating the subset
const vector<DimensionDescriptor>& rows = pRasterFileDescriptor->getRows();
pRasterDescriptor->setRows(rows);
const vector<DimensionDescriptor>& columns = pRasterFileDescriptor->getColumns();
pRasterDescriptor->setColumns(columns);
const vector<DimensionDescriptor>& bands = pRasterFileDescriptor->getBands();
pRasterDescriptor->setBands(bands);
}
// Data type
if (mpDataType != NULL)
{
pRasterDescriptor->setDataType(*mpDataType);
}
// InterleaveFormat
if (mpInterleave != NULL)
{
pRasterDescriptor->setInterleaveFormat(*mpInterleave);
}
// Bad values
if (mpBadValues != NULL)
{
pRasterDescriptor->setBadValues(*mpBadValues);
}
// Rows
if ((mpStartRow != NULL) || (mpEndRow != NULL) || (mpRowSkipFactor != NULL))
{
// We need to obtain this origRows from the FileDescriptor if present since an importer
// may generate a subset by default in which case the DataDescriptor will not contain all
// the rows and subsetting will not work correctly. We
// can't just set mpFileDescriptor = pRasterDescriptor->getFileDescriptor() since we only
// want to replace the DataDescriptor's row list if one of the subset options is specified
const RasterFileDescriptor* pFileDesc(pRasterFileDescriptor);
if (pFileDesc == NULL)
{
pFileDesc = dynamic_cast<const RasterFileDescriptor*>(pRasterDescriptor->getFileDescriptor());
}
const vector<DimensionDescriptor>& origRows = (pFileDesc != NULL) ?
pFileDesc->getRows() : pRasterDescriptor->getRows();
unsigned int startRow = 0;
if (mpStartRow != NULL)
{
startRow = *mpStartRow;
}
else if (origRows.empty() == false)
{
startRow = origRows.front().getOriginalNumber() + 1;
}
unsigned int endRow = 0;
if (mpEndRow != NULL)
{
endRow = *mpEndRow;
}
else if (origRows.empty() == false)
{
endRow = origRows.back().getOriginalNumber() + 1;
}
unsigned int rowSkip = 0;
//.........这里部分代码省略.........
示例7: VERIFY
bool ThresholdData::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
VERIFY(pInArgList != NULL);
StepResource pStep("Execute Wizard Item", "app", "{2501975d-7cd5-49b0-a3e7-49f7106793c0}");
pStep->addProperty("Item", getName());
mpStep = pStep.get();
if (!extractInputArgs(pInArgList))
{
return false;
}
const RasterDataDescriptor* pDesc = static_cast<const RasterDataDescriptor*>(mpInputElement->getDataDescriptor());
VERIFY(pDesc);
DimensionDescriptor band;
if (mDisplayBandNumber > 0)
{
band = pDesc->getOriginalBand(mDisplayBandNumber - 1);
if (band.isValid() == false)
{
reportError("The specified band is invalid.", "{a529538b-5b82-425d-af10-385a2581beec}");
return false;
}
}
else
{
band = pDesc->getActiveBand(mDisplayBandNumber);
}
FactoryResource<DataRequest> pReq;
pReq->setInterleaveFormat(BSQ);
pReq->setBands(band, band, 1);
DataAccessor acc = mpInputElement->getDataAccessor(pReq.release());
if (!acc.isValid())
{
reportError("Unable to access data element.", "{b5f1b7dd-7cf7-4cd5-b5bc-7b747d3561b9}");
return false;
}
// If necessary, convert region units
if (mRegionUnits != RAW_VALUE)
{
Statistics* pStatistics = mpInputElement->getStatistics(band);
if (pStatistics == NULL)
{
reportError("Unable to calculate data statistics.", "{61a44ced-a4aa-4423-b379-5783137eb980}");
return false;
}
mFirstThreshold = convertToRawUnits(pStatistics, mRegionUnits, mFirstThreshold);
mSecondThreshold = convertToRawUnits(pStatistics, mRegionUnits, mSecondThreshold);
}
FactoryResource<BitMask> pBitmask;
for (unsigned int row = 0; row < pDesc->getRowCount(); ++row)
{
reportProgress("Thresholding data", 100 * row / pDesc->getRowCount(),
"{2fc3dbea-1307-471c-bba2-bf86032be518}");
for (unsigned int col = 0; col < pDesc->getColumnCount(); ++col)
{
VERIFY(acc.isValid());
double val = ModelServices::getDataValue(pDesc->getDataType(), acc->getColumn(), 0);
switch (mPassArea)
{
case UPPER:
if (val >= mFirstThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
case LOWER:
if (val <= mFirstThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
case MIDDLE:
if (val >= mFirstThreshold && val <= mSecondThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
case OUTSIDE:
if (val <= mFirstThreshold || val >= mSecondThreshold)
{
pBitmask->setPixel(col, row, true);
}
break;
default:
reportError("Unknown or invalid pass area.", "{19c92b3b-52e9-442b-a01f-b545f819f200}");
return false;
}
acc->nextColumn();
}
acc->nextRow();
}
std::string aoiName = pDesc->getName() + "_aoi";
ModelResource<AoiElement> pAoi(aoiName, mpInputElement);
if (pAoi.get() == NULL)
{
reportWarning("Overwriting existing AOI.", "{d953a030-dd63-43a1-98db-b0f491dee123}");
Service<ModelServices>()->destroyElement(
Service<ModelServices>()->getElement(aoiName, TypeConverter::toString<AoiElement>(), mpInputElement));
//.........这里部分代码省略.........
示例8: displayErrorMessage
bool BandMath::createReturnValue(string partialResultsName)
{
// Set the short and long result names
FactoryResource<Filename> pFilename;
string shortResultsName;
string longResultsName;
if (pFilename.get() != NULL)
{
pFilename->setFullPathAndName(mpCube->getFilename());
shortResultsName = pFilename->getTitle() + " = " + partialResultsName;
longResultsName = pFilename->getPath() + "/" + pFilename->getTitle() + " = " + partialResultsName;
}
mResultsName = longResultsName;
const RasterDataDescriptor* pOrigDescriptor = dynamic_cast<RasterDataDescriptor*>(mpCube->getDataDescriptor());
const vector<DimensionDescriptor>& origRows = pOrigDescriptor->getRows();
const vector<DimensionDescriptor>& origColumns = pOrigDescriptor->getColumns();
mpResultData = NULL;
unsigned int bandCount = mCubeBands;
if (mbCubeMath == false)
{
bandCount = 1;
}
RasterElement* pParent = NULL;
if (mbAsLayerOnExistingView)
{
pParent = mpCube;
}
RasterElement* pRaster = RasterUtilities::createRasterElement(mResultsName, origRows.size(),
origColumns.size(), bandCount, FLT4BYTES, BIP, pOrigDescriptor->getProcessingLocation() == IN_MEMORY, pParent);
if (pRaster == NULL)
{
mstrProgressString = "Error creating result raster element";
meGabbiness = ERRORS;
displayErrorMessage();
mbError = true;
return false;
}
if (!mbAsLayerOnExistingView)
{
// need to copy classification since parent was NULL in call to createRasterElement
pRaster->copyClassification(mpCube);
// make copies of existing GcpLists only if going into a new view
vector<DataElement*> gcps = mpDataModel->getElements(mpCube, "GcpList");
if (!gcps.empty())
{
vector<DataElement*>::iterator iter;
for (iter = gcps.begin(); iter != gcps.end(); ++iter)
{
GcpList* theGcp = dynamic_cast<GcpList*>(*iter);
theGcp->copy(theGcp->getName(), pRaster);
}
}
}
mpResultData = pRaster;
RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>
(mpResultData->getDataDescriptor());
if (pDescriptor != NULL)
{
// Rows
vector<DimensionDescriptor> rows = pDescriptor->getRows();
for (unsigned int i = 0; i < origRows.size(); ++i)
{
// Original number
DimensionDescriptor origRow = origRows[i];
if (origRow.isOriginalNumberValid() == true)
{
rows[i].setOriginalNumber(origRow.getOriginalNumber());
}
}
pDescriptor->setRows(rows);
// Columns
vector<DimensionDescriptor> columns = pDescriptor->getColumns();
for (unsigned int i = 0; i < origColumns.size(); ++i)
{
// Original number
DimensionDescriptor origColumn = origColumns[i];
if (origColumn.isOriginalNumberValid() == true)
{
columns[i].setOriginalNumber(origColumn.getOriginalNumber());
}
}
pDescriptor->setColumns(columns);
}
return true;
}
示例9: parseHeader
vector<ImportDescriptor*> EnviImporter::getImportDescriptors(const string& filename)
{
string headerFile = filename;
string dataFile;
bool bSuccess = parseHeader(headerFile);
if (bSuccess == false)
{
dataFile = filename; // was passed data file name instead of header file name
headerFile = findHeaderFile(headerFile);
if (headerFile.empty() == false)
{
bSuccess = parseHeader(headerFile);
}
}
EnviField* pField = NULL;
vector<ImportDescriptor*> descriptors;
if (bSuccess == true)
{
if (dataFile.empty() == true) // was passed header file name and now need to find the data file name
{
dataFile = findDataFile(headerFile);
}
if (dataFile.empty() == false)
{
ImportDescriptor* pImportDescriptor = mpModel->createImportDescriptor(dataFile, "RasterElement", NULL);
if (pImportDescriptor != NULL)
{
RasterDataDescriptor* pDescriptor =
dynamic_cast<RasterDataDescriptor*>(pImportDescriptor->getDataDescriptor());
if (pDescriptor != NULL)
{
FactoryResource<RasterFileDescriptor> pFileDescriptor;
if (pFileDescriptor.get() != NULL)
{
// Filename
pFileDescriptor->setFilename(dataFile);
// Coordinate offset
int columnOffset = 0;
int rowOffset = 0;
pField = mFields.find("x start");
if (pField != NULL)
{
// ENVI numbers are 1 based vs Opticks being 0 based
columnOffset = atoi(pField->mValue.c_str()) - 1;
}
pField = mFields.find("y start");
if (pField != NULL)
{
rowOffset = atoi(pField->mValue.c_str()) - 1; // ENVI numbers are 1 based vs Opticks being 0 based
}
// Rows
vector<DimensionDescriptor> rows;
pField = mFields.find("lines");
if (pField != NULL)
{
int numRows = atoi(pField->mValue.c_str());
for (int i = 0; i < numRows; ++i)
{
DimensionDescriptor rowDim;
rowDim.setOriginalNumber(static_cast<unsigned int>(rowOffset + i));
rowDim.setOnDiskNumber(static_cast<unsigned int>(i));
rows.push_back(rowDim);
}
pDescriptor->setRows(rows);
pFileDescriptor->setRows(rows);
}
string samplesStr = "samples";
string bandsStr = "bands";
// Special case: if the file type is an ENVI Spectral Library, then swap samples with bands
// If no file type field exists, assume this is a normal ENVI header (not a Spectral Library)
EnviField* pFileTypeField = mFields.find("file type");
if (pFileTypeField != NULL && (pFileTypeField->mValue ==
"ENVI Spectral Library" || pFileTypeField->mValue == "Spectral Library"))
{
samplesStr = "bands";
bandsStr = "samples";
// Since bands and samples are swapped, force the interleave to BIP
pField = mFields.find("interleave");
if (pField != NULL)
{
pField->mValue = "bip";
}
}
// Columns
vector<DimensionDescriptor> columns;
pField = mFields.find(samplesStr);
if (pField != NULL)
{
int numColumns = atoi(pField->mValue.c_str());
//.........这里部分代码省略.........
示例10: pFile
vector<ImportDescriptor*> SioImporter::getImportDescriptors(const string& filename)
{
vector<ImportDescriptor*> descriptors;
if (filename.empty() == false)
{
// Read the header values
FileResource pFile(filename.c_str(), "rb");
SioFile sioFile;
bool bSuccess = sioFile.deserialize(pFile.get());
if (bSuccess == false)
{
return descriptors;
}
if (sioFile.mOriginalVersion == 9)
{
mVersion9Sio = true;
}
// Create the import descriptor
ImportDescriptor* pImportDescriptor = mpModel->createImportDescriptor(filename, "RasterElement", NULL);
if (pImportDescriptor != NULL)
{
RasterDataDescriptor* pDescriptor =
dynamic_cast<RasterDataDescriptor*>(pImportDescriptor->getDataDescriptor());
if (pDescriptor != NULL)
{
FactoryResource<RasterFileDescriptor> pFileDescriptor;
if (pFileDescriptor.get() != NULL)
{
// Filename
pFileDescriptor->setFilename(filename);
// Endian
pFileDescriptor->setEndian(sioFile.mEndian);
// Rows
vector<DimensionDescriptor> rows;
for (int i = 0; i < sioFile.mRows; ++i)
{
DimensionDescriptor rowDim;
// Do not set an active number since the user has not selected the rows to load
if (static_cast<unsigned int>(i) < sioFile.mOrigRowNumbers.size())
{
rowDim.setOriginalNumber(sioFile.mOrigRowNumbers[i]);
}
else
{
rowDim.setOriginalNumber(i);
}
rowDim.setOnDiskNumber(i);
rows.push_back(rowDim);
}
pDescriptor->setRows(rows);
pFileDescriptor->setRows(rows);
// Columns
vector<DimensionDescriptor> columns;
for (int i = 0; i < sioFile.mColumns; ++i)
{
DimensionDescriptor columnDim;
// Do not set an active number since the user has not selected the rows to load
if (static_cast<unsigned int>(i) < sioFile.mOrigColumnNumbers.size())
{
columnDim.setOriginalNumber(sioFile.mOrigColumnNumbers[i]);
}
else
{
columnDim.setOriginalNumber(i);
}
columnDim.setOnDiskNumber(i);
columns.push_back(columnDim);
}
pDescriptor->setColumns(columns);
pFileDescriptor->setColumns(columns);
// Bands
vector<DimensionDescriptor> bands;
for (int i = 0; i < (sioFile.mBands - sioFile.mBadBands); ++i)
{
DimensionDescriptor bandDim;
// Do not set an active number since the user has not selected the rows to load
if (static_cast<unsigned int>(i) < sioFile.mOrigBandNumbers.size())
{
bandDim.setOriginalNumber(sioFile.mOrigBandNumbers[i]);
}
else
{
bandDim.setOriginalNumber(i);
}
bandDim.setOnDiskNumber(i);
//.........这里部分代码省略.........
示例11: if
std::vector<ImportDescriptor*> LandsatGeotiffImporter::createImportDescriptors(const std::string& filename,
const DynamicObject* pImageMetadata,
Landsat::LandsatImageType type)
{
std::string suffix;
if (type == Landsat::LANDSAT_VNIR)
{
suffix = "vnir";
}
else if (type == Landsat::LANDSAT_PAN)
{
suffix = "pan";
}
else if (type == Landsat::LANDSAT_TIR)
{
suffix = "tir";
}
std::vector<ImportDescriptor*> descriptors;
std::string spacecraft = dv_cast<std::string>(
pImageMetadata->getAttributeByPath("LANDSAT_MTL/L1_METADATA_FILE/PRODUCT_METADATA/SPACECRAFT_ID"), "");
std::vector<std::string> bandNames = Landsat::getSensorBandNames(spacecraft, type);
if (bandNames.empty())
{
//this spacecraft and iamge type
//isn't meant to have any bands, so terminate early
//e.g. spacecraft == "Landsat5" && type == Landsat::LANDSAT_PAN
return descriptors;
}
std::vector<unsigned int> validBands;
std::vector<std::string> bandFiles = Landsat::getGeotiffBandFilenames(
pImageMetadata, filename, type, validBands);
if (bandFiles.empty())
{
mWarnings.push_back("Unable to locate band files for " + suffix + " product.");
return descriptors;
}
ImportDescriptorResource pImportDescriptor(filename + "-" + suffix,
TypeConverter::toString<RasterElement>(), NULL, false);
if (pImportDescriptor.get() == NULL)
{
return descriptors;
}
RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pImportDescriptor->getDataDescriptor());
if (pDescriptor == NULL)
{
return descriptors;
}
pDescriptor->setProcessingLocation(ON_DISK);
DynamicObject* pMetadata = pDescriptor->getMetadata();
pMetadata->merge(pImageMetadata);
FactoryResource<RasterFileDescriptor> pFileDescriptorRes;
pDescriptor->setFileDescriptor(pFileDescriptorRes.get());
RasterFileDescriptor* pFileDescriptor = dynamic_cast<RasterFileDescriptor*>(pDescriptor->getFileDescriptor());
pFileDescriptor->setFilename(filename);
std::string tiffFile = bandFiles[0];
if (!Landsat::parseBasicsFromTiff(tiffFile, pDescriptor))
{
mWarnings.push_back("Unable to parse basic information about image from tiff file for " + suffix + " product.");
return descriptors;
}
if (pDescriptor->getBandCount() != 1 || pDescriptor->getDataType() != INT1UBYTE)
{
mWarnings.push_back("Improperly formatted tiff file for " + suffix + " product.");
return descriptors;
}
pDescriptor->setInterleaveFormat(BSQ); //one tiff file per band.
pFileDescriptor->setInterleaveFormat(BSQ);
std::vector<DimensionDescriptor> bands = RasterUtilities::generateDimensionVector(
bandFiles.size(), true, false, true);
pDescriptor->setBands(bands);
pFileDescriptor->setBands(bands);
pDescriptor->setBadValues(std::vector<int>(1, 0));
pFileDescriptor->setDatasetLocation(suffix);
//special metadata here
Landsat::fixMtlMetadata(pMetadata, type, validBands);
std::vector<std::string> defaultImport = OptionsLandsatImport::getSettingDefaultImport();
bool fallbackToDn = false;
descriptors.push_back(pImportDescriptor.release());
if (type == Landsat::LANDSAT_VNIR)
{
//attempt to display true-color
DimensionDescriptor redBand = RasterUtilities::findBandWavelengthMatch(0.630, 0.690, pDescriptor);
DimensionDescriptor greenBand = RasterUtilities::findBandWavelengthMatch(0.510, 0.590, pDescriptor);
DimensionDescriptor blueBand = RasterUtilities::findBandWavelengthMatch(0.410, 0.490, pDescriptor);
if (redBand.isValid() && greenBand.isValid() && blueBand.isValid())
{
pDescriptor->setDisplayMode(RGB_MODE);
pDescriptor->setDisplayBand(RED, redBand);
pDescriptor->setDisplayBand(GREEN, greenBand);
pDescriptor->setDisplayBand(BLUE, blueBand);
}
}
std::vector<std::pair<double, double> > radianceFactors = Landsat::determineRadianceConversionFactors(
pMetadata, type, validBands);
bool shouldDefaultImportRadiance =
//.........这里部分代码省略.........
示例12: VERIFYRV
RasterPage* ConvertToBsqPager::getPage(DataRequest* pOriginalRequest, DimensionDescriptor startRow,
DimensionDescriptor startColumn, DimensionDescriptor startBand)
{
VERIFYRV(pOriginalRequest != NULL, NULL);
if (pOriginalRequest->getWritable())
{
return NULL;
}
InterleaveFormatType requestedType = pOriginalRequest->getInterleaveFormat();
DimensionDescriptor stopRow = pOriginalRequest->getStopRow();
DimensionDescriptor stopColumn = pOriginalRequest->getStopColumn();
DimensionDescriptor stopBand = pOriginalRequest->getStopBand();
unsigned int concurrentRows = std::min(pOriginalRequest->getConcurrentRows(),
stopRow.getActiveNumber() - startRow.getActiveNumber() + 1);
unsigned int concurrentBands = pOriginalRequest->getConcurrentBands();
VERIFY(requestedType == BSQ);
VERIFY(startBand == stopBand && concurrentBands == 1);
VERIFY(mpRaster != NULL);
const RasterDataDescriptor* pDd = dynamic_cast<const RasterDataDescriptor*>(mpRaster->getDataDescriptor());
VERIFY(pDd != NULL);
InterleaveFormatType interleave = pDd->getInterleaveFormat();
VERIFY(interleave == BIL || interleave == BIP);
unsigned int numRows = pDd->getRowCount();
unsigned int numCols = pDd->getColumnCount();
unsigned int numBands = pDd->getBandCount();
if (startRow.getActiveNumber() >= numRows || stopRow.getActiveNumber() >= numRows ||
startColumn.getActiveNumber() >= numCols || stopColumn.getActiveNumber() >= numCols ||
startBand.getActiveNumber() >= numBands || stopBand.getActiveNumber() >= numBands)
{
return NULL;
}
unsigned int cols = stopColumn.getActiveNumber() - startColumn.getActiveNumber() + 1;
std::auto_ptr<ConvertToBsqPage> pPage(new ConvertToBsqPage(concurrentRows, cols, mBytesPerElement));
unsigned char* pDst = reinterpret_cast<unsigned char*>(pPage->getRawData());
if (pDst == NULL)
{
return NULL;
}
FactoryResource<DataRequest> pRequest;
pRequest->setRows(startRow, stopRow);
pRequest->setColumns(startColumn, stopColumn, cols);
pRequest->setBands(startBand, startBand, 1);
DataAccessor da = mpRaster->getDataAccessor(pRequest.release());
if (interleave == BIP)
{
for (unsigned int row = 0; row < concurrentRows; ++row)
{
for (unsigned int col = 0; col < cols; ++col)
{
if (da.isValid() == false)
{
return NULL;
}
memcpy(pDst, da->getColumn(), mBytesPerElement);
pDst += mBytesPerElement;
da->nextColumn();
}
da->nextRow();
}
}
else if (interleave == BIL)
{
for (unsigned int row = 0; row < concurrentRows; ++row)
{
if (da.isValid() == false)
{
return NULL;
}
memcpy(pDst, da->getRow(), mBytesPerElement * cols);
pDst += mBytesPerElement * cols;
da->nextRow();
}
}
return pPage.release();
}
示例13: if
void PropertiesRasterLayer::updateDisplayedBandCombo(int index)
{
// Get the selected raster element
RasterElement* pElement = NULL;
if ((index > -1) && (static_cast<int>(mRasterElements.size()) > index))
{
pElement = mRasterElements[index];
}
// Get the band names from the element
QStringList strBandNames;
if (pElement != NULL)
{
RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pElement->getDataDescriptor());
if (pDescriptor != NULL)
{
vector<string> bandNames = RasterUtilities::getBandNames(pDescriptor);
for (vector<string>::iterator iter = bandNames.begin(); iter != bandNames.end(); ++iter)
{
strBandNames.append(QString::fromStdString(*iter));
}
}
}
// Update the display band combo
QComboBox* pCombo = dynamic_cast<QComboBox*>(sender());
if (pCombo == mpGrayElementCombo)
{
mpGrayBandCombo->clear();
mpGrayBandCombo->addItems(strBandNames);
if (strBandNames.isEmpty() == false)
{
mpGrayBandCombo->setCurrentIndex(0);
if ((mpRasterLayer != NULL) && (mpRasterLayer->getDataElement() == pElement))
{
DimensionDescriptor displayedBand = mpRasterLayer->getDisplayedBand(GRAY);
if (displayedBand.isActiveNumberValid() == true)
{
mpGrayBandCombo->setCurrentIndex(displayedBand.getActiveNumber());
}
}
}
}
else if (pCombo == mpRedElementCombo)
{
mpRedBandCombo->clear();
mpRedBandCombo->addItems(strBandNames);
if (strBandNames.isEmpty() == false)
{
mpRedBandCombo->setCurrentIndex(0);
if ((mpRasterLayer != NULL) && (mpRasterLayer->getDataElement() == pElement))
{
DimensionDescriptor displayedBand = mpRasterLayer->getDisplayedBand(RED);
if (displayedBand.isActiveNumberValid() == true)
{
mpRedBandCombo->setCurrentIndex(displayedBand.getActiveNumber());
}
}
}
}
else if (pCombo == mpGreenElementCombo)
{
mpGreenBandCombo->clear();
mpGreenBandCombo->addItems(strBandNames);
if (strBandNames.isEmpty() == false)
{
mpGreenBandCombo->setCurrentIndex(0);
if ((mpRasterLayer != NULL) && (mpRasterLayer->getDataElement() == pElement))
{
DimensionDescriptor displayedBand = mpRasterLayer->getDisplayedBand(GREEN);
if (displayedBand.isActiveNumberValid() == true)
{
mpGreenBandCombo->setCurrentIndex(displayedBand.getActiveNumber());
}
}
}
}
else if (pCombo == mpBlueElementCombo)
{
mpBlueBandCombo->clear();
mpBlueBandCombo->addItems(strBandNames);
if (strBandNames.isEmpty() == false)
{
mpBlueBandCombo->setCurrentIndex(0);
if ((mpRasterLayer != NULL) && (mpRasterLayer->getDataElement() == pElement))
{
DimensionDescriptor displayedBand = mpRasterLayer->getDisplayedBand(BLUE);
if (displayedBand.isActiveNumberValid() == true)
{
mpBlueBandCombo->setCurrentIndex(displayedBand.getActiveNumber());
}
}
}
}
}
示例14: getValidationError
bool RasterElementImporterShell::validate(const DataDescriptor* pDescriptor,
const vector<const DataDescriptor*>& importedDescriptors,
string& errorMessage) const
{
bool isValid = ImporterShell::validate(pDescriptor, importedDescriptors, errorMessage);
if (isValid == false)
{
ValidationTest errorTest = getValidationError();
if (errorTest == NO_PRE_POST_BAND_BYTES)
{
errorMessage += " Preband and postband bytes are not supported for interleave formats other than BSQ.";
}
else if (errorTest == NO_BAND_FILES)
{
errorMessage += " Bands in multiple files are not supported for interleave formats other than BSQ.";
}
else if ((errorTest == NO_INTERLEAVE_CONVERSIONS) || (errorTest == NO_ROW_SKIP_FACTOR) ||
(errorTest == NO_COLUMN_SKIP_FACTOR) || (errorTest == NO_BAND_SUBSETS))
{
errorMessage = errorMessage.substr(0, errorMessage.length() - 1);
errorMessage += " with on-disk read-only processing.";
}
}
else
{
// Check for display bands that are not loaded
const RasterDataDescriptor* pRasterDescriptor = dynamic_cast<const RasterDataDescriptor*>(pDescriptor);
VERIFY(pRasterDescriptor != NULL);
DimensionDescriptor grayBand = pRasterDescriptor->getDisplayBand(GRAY);
if (grayBand.isOriginalNumberValid() == true)
{
DimensionDescriptor band = pRasterDescriptor->getOriginalBand(grayBand.getOriginalNumber());
if (band.isValid() == false)
{
if (errorMessage.empty() == false)
{
errorMessage += "\n";
}
errorMessage += "The gray display band is not available. The first loaded band will be displayed instead.";
}
}
DimensionDescriptor redBand = pRasterDescriptor->getDisplayBand(RED);
if (redBand.isOriginalNumberValid() == true)
{
DimensionDescriptor band = pRasterDescriptor->getOriginalBand(redBand.getOriginalNumber());
if (band.isValid() == false)
{
if (errorMessage.empty() == false)
{
errorMessage += "\n";
}
errorMessage += "The red display band is not available. The first loaded band will be displayed instead.";
}
}
DimensionDescriptor greenBand = pRasterDescriptor->getDisplayBand(GREEN);
if (greenBand.isOriginalNumberValid() == true)
{
DimensionDescriptor band = pRasterDescriptor->getOriginalBand(greenBand.getOriginalNumber());
if (band.isValid() == false)
{
if (errorMessage.empty() == false)
{
errorMessage += "\n";
}
errorMessage += "The green display band is not available. The first loaded band will be "
"displayed instead.";
}
}
DimensionDescriptor blueBand = pRasterDescriptor->getDisplayBand(BLUE);
if (blueBand.isOriginalNumberValid() == true)
{
DimensionDescriptor band = pRasterDescriptor->getOriginalBand(blueBand.getOriginalNumber());
if (band.isValid() == false)
{
if (errorMessage.empty() == false)
{
errorMessage += "\n";
}
errorMessage += "The blue display band is not available. The first loaded band will be displayed instead.";
}
}
}
return isValid;
}
示例15: getRasterElement
void ChippingWindow::createView()
{
if (mpChippingWidget == NULL)
{
return;
}
RasterElement* pRaster = getRasterElement();
if (pRaster == NULL)
{
return;
}
// Create the new raster element from the primary element of the source.
// Note that this does not chip displayed elements if they differ from the primary element.
// This causes a special case below where the stretch values are being applied to the chipped layer.
RasterElement* pRasterChip = pRaster->createChip(pRaster->getParent(), "_chip",
mpChippingWidget->getChipRows(), mpChippingWidget->getChipColumns(), mpChippingWidget->getChipBands());
if (pRasterChip == NULL)
{
QMessageBox::critical(this, windowTitle(), "Unable to create a new cube!");
return;
}
const RasterDataDescriptor* pDescriptor =
dynamic_cast<const RasterDataDescriptor*>(pRasterChip->getDataDescriptor());
VERIFYNRV(pDescriptor != NULL);
// Create a view for the new chip
SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(
Service<DesktopServices>()->createWindow(pRasterChip->getName(), SPATIAL_DATA_WINDOW));
if (pWindow == NULL)
{
return;
}
SpatialDataView* pView = pWindow->getSpatialDataView();
if (pView == NULL)
{
Service<DesktopServices>()->deleteWindow(pWindow);
return;
}
UndoLock lock(pView);
if (pView->setPrimaryRasterElement(pRasterChip) == false)
{
Service<DesktopServices>()->deleteWindow(pWindow);
return;
}
// RasterLayerImp is needed for the call to setCurrentStretchAsOriginalStretch().
RasterLayerImp* pLayer = dynamic_cast<RasterLayerImp*>(pView->createLayer(RASTER, pRasterChip));
if (pLayer == NULL)
{
Service<DesktopServices>()->deleteWindow(pWindow);
return;
}
string origName = pRaster->getName();
SpatialDataWindow* pOrigWindow = dynamic_cast<SpatialDataWindow*>(
Service<DesktopServices>()->getWindow(origName, SPATIAL_DATA_WINDOW));
if (pOrigWindow != NULL)
{
SpatialDataView* pOrigView = pOrigWindow->getSpatialDataView();
if (pOrigView != NULL)
{
LayerList* pLayerList = pOrigView->getLayerList();
if (pLayerList != NULL)
{
RasterLayer* pOrigLayer = static_cast<RasterLayer*>(pLayerList->getLayer(RASTER, pRaster));
if (pOrigLayer != NULL)
{
// Set the stretch type first so that stretch values are interpreted correctly.
pLayer->setStretchType(GRAYSCALE_MODE, pOrigLayer->getStretchType(GRAYSCALE_MODE));
pLayer->setStretchType(RGB_MODE, pOrigLayer->getStretchType(RGB_MODE));
pLayer->setDisplayMode(pOrigLayer->getDisplayMode());
// Set the properties of the cube layer in the new view.
// For each channel, display the first band if the previously displayed band was chipped.
vector<RasterChannelType> channels = StringUtilities::getAllEnumValues<RasterChannelType>();
for (vector<RasterChannelType>::const_iterator iter = channels.begin(); iter != channels.end(); ++iter)
{
bool bandCopied = true;
DimensionDescriptor newBand;
DimensionDescriptor oldBand = pOrigLayer->getDisplayedBand(*iter);
if (oldBand.isOriginalNumberValid() == true)
{
newBand = pDescriptor->getOriginalBand(oldBand.getOriginalNumber());
}
if (newBand.isValid() == false)
{
bandCopied = false;
newBand = pDescriptor->getBands().front();
}
// No need to explicitly set the RasterElement here since the new view only has one RasterElement.
pLayer->setDisplayedBand(*iter, newBand);
//.........这里部分代码省略.........