本文整理汇总了C++中FactoryResource::setUnits方法的典型用法代码示例。如果您正苦于以下问题:C++ FactoryResource::setUnits方法的具体用法?C++ FactoryResource::setUnits怎么用?C++ FactoryResource::setUnits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FactoryResource
的用法示例。
在下文中一共展示了FactoryResource::setUnits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pFile
//.........这里部分代码省略.........
// Bad values
if (sioFile.mBadValues.empty() == true)
{
if ((sioFile.mDataType != FLT4BYTES) && (sioFile.mDataType != FLT8COMPLEX) &&
(sioFile.mDataType != FLT8BYTES))
{
vector<int> badValues;
badValues.push_back(0);
pDescriptor->setBadValues(badValues);
}
}
// Header bytes
pFileDescriptor->setHeaderBytes(28);
// Trailer bytes
struct stat statBuffer;
if (stat(filename.c_str(), &statBuffer) == 0)
{
double dataBytes = 28 + (sioFile.mRows * sioFile.mColumns * (sioFile.mBands - sioFile.mBadBands) *
(sioFile.mBitsPerElement / 8));
pFileDescriptor->setTrailerBytes(static_cast<unsigned int>(statBuffer.st_size - dataBytes));
}
// Units
FactoryResource<Units> pUnits;
pUnits->setUnitType(sioFile.mUnitType);
pUnits->setUnitName(sioFile.mUnitName);
pUnits->setRangeMin(sioFile.mRangeMin);
pUnits->setRangeMax(sioFile.mRangeMax);
pUnits->setScaleFromStandard(sioFile.mScale);
pDescriptor->setUnits(pUnits.get());
pFileDescriptor->setUnits(pUnits.get());
// GCPs
GcpPoint gcpLowerLeft;
gcpLowerLeft.mPixel.mX = 0.0;
gcpLowerLeft.mPixel.mY = 0.0;
GcpPoint gcpLowerRight;
gcpLowerRight.mPixel.mX = sioFile.mColumns - 1.0;
gcpLowerRight.mPixel.mY = 0.0;
GcpPoint gcpUpperLeft;
gcpUpperLeft.mPixel.mX = 0.0;
gcpUpperLeft.mPixel.mY = sioFile.mRows - 1.0;
GcpPoint gcpUpperRight;
gcpUpperRight.mPixel.mX = sioFile.mColumns - 1.0;
gcpUpperRight.mPixel.mY = sioFile.mRows - 1.0;
GcpPoint gcpCenter;
gcpCenter.mPixel.mX = sioFile.mColumns / 2.0 - 0.5;
gcpCenter.mPixel.mY = sioFile.mRows / 2.0 - 0.5;
bool bValidGcps = false;
for (int i = ORIGINAL_SENSOR; i < INVALID_LAST_ENUM_ITEM_FLAG; ++i)
{
if (sioFile.mParameters[i].eParameter_Initialized == true)
{
switch (i)
{
case UPPER_LEFT_CORNER_LAT:
if ((sioFile.mVersion == 5) || (sioFile.mVersion == 6))
示例2: unitName
//.........这里部分代码省略.........
{
return descriptors;
}
// load the data
FactoryResource<DynamicObject> pMetadata;
VERIFYRV(pMetadata.get() != NULL, descriptors);
bool readError = false;
string line;
string unitName("Reflectance");
UnitType unitType(REFLECTANCE);
double unitScale(1.0);
// parse the metadata
for (line = pSigFile.readLine(&readError);
(readError == false) && (line.find('=') != string::npos);
line = pSigFile.readLine(&readError))
{
vector<string> metadataEntry;
trim(line);
split(metadataEntry, line, is_any_of("="));
if (metadataEntry.size() == 2)
{
string key = metadataEntry[0];
string value = metadataEntry[1];
trim(key);
trim(value);
if (ends_with(key, "Bands") || key == "Pixels")
{
pMetadata->setAttribute(key, StringUtilities::fromXmlString<unsigned long>(value));
}
else if (key == "UnitName")
{
unitName = value;
}
else if (key == "UnitType")
{
unitType = StringUtilities::fromXmlString<UnitType>(value);
}
else if (key == "UnitScale")
{
unitScale = StringUtilities::fromXmlString<double>(value);
}
else
{
pMetadata->setAttribute(key, value);
}
}
}
if ((readError == true) && (pSigFile.eof() != 1))
{
return descriptors;
}
// Verify that the next line contains float float pairs
vector<string> dataEntry;
trim(line);
split(dataEntry, line, is_space());
if (dataEntry.size() != 2)
{
return descriptors;
}
bool error = false;
StringUtilities::fromXmlString<float>(dataEntry[0], &error);
!error && StringUtilities::fromXmlString<float>(dataEntry[1], &error);
if (error)
{
return descriptors;
}
string datasetName = dv_cast<string>(pMetadata->getAttribute("Name"), filename);
ImportDescriptorResource pImportDescriptor(datasetName, "Signature");
VERIFYRV(pImportDescriptor.get() != NULL, descriptors);
SignatureDataDescriptor* pDataDescriptor =
dynamic_cast<SignatureDataDescriptor*>(pImportDescriptor->getDataDescriptor());
VERIFYRV(pDataDescriptor != NULL, descriptors);
FactoryResource<SignatureFileDescriptor> pFileDescriptor;
VERIFYRV(pFileDescriptor.get() != NULL, descriptors);
pFileDescriptor->setFilename(filename);
FactoryResource<Units> pReflectanceUnits;
VERIFYRV(pReflectanceUnits.get() != NULL, descriptors);
pReflectanceUnits->setUnitName(unitName);
pReflectanceUnits->setUnitType(unitType);
if (unitScale != 0.0)
{
pReflectanceUnits->setScaleFromStandard(1.0 / unitScale);
}
pDataDescriptor->setUnits("Reflectance", pReflectanceUnits.get());
pFileDescriptor->setUnits("Reflectance", pReflectanceUnits.get());
pDataDescriptor->setFileDescriptor(pFileDescriptor.get());
pDataDescriptor->setMetadata(pMetadata.get());
descriptors.push_back(pImportDescriptor.release());
return descriptors;
}