bool Nitf::Header::importDateYYMMDD(const ossimPropertyInterface *pPropertyInterface, RasterDataDescriptor *pDescriptor, DynamicObject *pDynObj, const string& appName, const string& ossimName) { FactoryResource<DateTime> pDateTime; VERIFY(pDateTime.get() != NULL && pDynObj != NULL); if (pPropertyInterface == NULL) { return false; } ossimRefPtr<ossimProperty> pProperty = pPropertyInterface->getProperty(ossimName); ossimProperty* pProp = pProperty.get(); if (pProp == NULL) { return false; } ossimString date; pProp->valueToString(date); // Purposely ignore the return value of DtgParseYYMMDD so that a DateTime is // present in the metadata even if the value is invalid. DtgParseYYMMDD(date, pDateTime.get()); return pDynObj->setAttribute(appName, *pDateTime.get()); }
unsigned char LandsatGeotiffImporter::getFileAffinity(const std::string& filename) { if (filename.empty()) { return CAN_NOT_LOAD; } bool originallyTiff = false; std::string metadataFile = determineMetadataFile(filename, &originallyTiff); bool readMetadata = false; FactoryResource<DynamicObject> pImageMetadata = Landsat::parseMtlFile(metadataFile, readMetadata); if (!readMetadata) { return CAN_NOT_LOAD; } std::string spacecraft = dv_cast<std::string>( pImageMetadata->getAttributeByPath("LANDSAT_MTL/L1_METADATA_FILE/PRODUCT_METADATA/SPACECRAFT_ID"), ""); if (spacecraft != "Landsat5" && spacecraft != "Landsat7") { return CAN_NOT_LOAD; } if (originallyTiff) { return CAN_LOAD + 5; //override normal tiff importers } return CAN_LOAD; }
vector<ImportDescriptor*> SignatureSetImporter::getImportDescriptors(const string &filename) { vector<ImportDescriptor*> descriptors; if (filename.empty()) { return descriptors; } mFilename = filename; try { loadDoc(filename); if (mDoc[filename] == NULL) { return descriptors; } FactoryResource<DynamicObject> pMetadata; VERIFYRV(pMetadata.get() != NULL, descriptors); mDatasetNumber = 0; ImportDescriptorFilter filter; DOMTreeWalker* pTree = mDoc[filename]->createTreeWalker(mDoc[filename]->getDocumentElement(), DOMNodeFilter::SHOW_ELEMENT, &filter, false); std::vector<std::string> dummy; descriptors = createImportDescriptors(pTree, dummy); } catch(const DOMException &) {} catch(const XMLException &) {} return descriptors; }
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; }
FactoryResource<DynamicObject> Nitf::DesSubheader::createDefaultsDynamicObject( const RasterDataDescriptor *pDescriptor) { FactoryResource<DynamicObject> pDesSubheader; // Per the NITF spec, the field "DE" must contain the value "DE". pDesSubheader->setAttribute(DE, DE); return pDesSubheader; }
bool ResamplerPlugIn::getWavelengthsFromFile(const std::string& filename, Wavelengths* pWavelengths, std::string& errorMsg) { errorMsg.clear(); if (filename.empty() || pWavelengths == NULL) { errorMsg = "Invalid input parameters."; return false; } pWavelengths->clear(); FactoryResource<Filename> pFilename; pFilename->setFullPathAndName(filename); std::string importerName; std::string extension; std::vector<std::string> extensionStrs = StringUtilities::split(StringUtilities::toLower(pFilename->getExtension()), '.'); if (extensionStrs.empty() == false) { extension = extensionStrs.back(); } if (extension == "wmd") { importerName = "Wavelength Metadata Importer"; } else { importerName = "Wavelength Text Importer"; } ExecutableResource pImporter(importerName, std::string()); if (pImporter->getInArgList().setPlugInArgValue(Wavelengths::WavelengthFileArg(), pFilename.get()) == false) { errorMsg = "Unable to set filename into plug-in \"" + importerName + "\"."; return false; } if (pImporter->execute() == false) { errorMsg = "Unable to load file \"" + filename + "\"."; return false; } Wavelengths* pWave = pImporter->getOutArgList().getPlugInArgValue<Wavelengths>(Wavelengths::WavelengthsArg()); if (pWave == NULL) { errorMsg = "Unable to extract wavelengths from plug-in \"" + importerName + "\"."; return false; } if (pWavelengths->initializeFromWavelengths(pWave) == false) { errorMsg = "Unable to retrieve the wavelengths."; return false; } return true; }
void Simulation_GUI::StartOrtho() { mpStartOrtho->setEnabled(false); // Update Grid Information OrthoGrid.X_Step = X_Spacing->value(); OrthoGrid.Y_Step = Y_Spacing->value(); OrthoGrid.X_Dim = int(OrthoGrid.X_Dim/OrthoGrid.X_Step)+1.0; OrthoGrid.Y_Dim = int(OrthoGrid.Y_Dim/OrthoGrid.Y_Step)+1.0; OrthoGrid.Lon_Step = (OrthoGrid.Lon_Max-OrthoGrid.Lon_Min)/OrthoGrid.X_Dim; OrthoGrid.Lat_Step = (OrthoGrid.Lat_Max-OrthoGrid.Lat_Min)/OrthoGrid.Y_Dim; //Start Ortho RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor()); FactoryResource<DataRequest> pRequest; DataAccessor pAcc = pCube->getDataAccessor(pRequest.release()); DataDescriptor* dMeta = pCube->getDataDescriptor(); DynamicObject* oMetadata = dMeta->getMetadata(); // RETRIEVE & UPDATE METADATA INFORMATION // bool control = Metadata->ReadFile(image_path); Metadata->UpdateMetadata(oMetadata); SAR_Model *ModProva; ModProva = new SAR_Slant_Model(*Metadata, 10); if(Metadata->Projection == "SGF") { ModProva = new SAR_Ground_Model(*Metadata,10); } SAR_Simulator_Processor ProcessOrtho(pCube, ModProva, OrthoGrid, Height->value()); // RETRIVE SELECTED RESAMPLING METHOD AND EXECUTE ORTHO int indexR = mpInterpolationList->currentIndex(); //if (mpFlatten->isChecked() ==true) //{ //VERIFYNRV(ProcessOrtho.process(indexR)); //} //else //{ VERIFYNRV(RetrieveDSMGrid()); VERIFYNRV(ProcessOrtho.process(indexR, pDSM, DSMGrid, GeoidOffSet->value(),mpDSMInterpolationList->currentIndex())); //} }
vector<ImportDescriptor*> Jpeg2000Importer::getImportDescriptors(const string& filename) { vector<ImportDescriptor*> descriptors; if (filename.empty() == true) { return descriptors; } vector<string>& warnings = msWarnings[filename]; warnings.clear(); vector<string>& errors = msErrors[filename]; errors.clear(); ImportDescriptor* pImportDescriptor = mpModel->createImportDescriptor(filename, "RasterElement", NULL); if (pImportDescriptor != NULL) { RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pImportDescriptor->getDataDescriptor()); if (pDescriptor != NULL) { vector<EncodingType> validDataTypes; validDataTypes.push_back(INT1UBYTE); validDataTypes.push_back(INT1SBYTE); validDataTypes.push_back(INT2UBYTES); validDataTypes.push_back(INT2SBYTES); validDataTypes.push_back(INT4UBYTES); validDataTypes.push_back(INT4SBYTES); validDataTypes.push_back(FLT4BYTES); pDescriptor->setValidDataTypes(validDataTypes); pDescriptor->setProcessingLocation(IN_MEMORY); // Create and set a file descriptor in the data descriptor FactoryResource<RasterFileDescriptor> pFileDescriptor; pFileDescriptor->setEndian(BIG_ENDIAN_ORDER); if (pFileDescriptor.get() != NULL) { pFileDescriptor->setFilename(filename); pDescriptor->setFileDescriptor(pFileDescriptor.get()); } // Populate the data descriptor from the file bool bSuccess = populateDataDescriptor(pDescriptor); if (bSuccess == true) { descriptors.push_back(pImportDescriptor); } else { // Delete the import descriptor mpModel->destroyImportDescriptor(pImportDescriptor); } } } return descriptors; }
// FileDescriptor FileDescriptor* FileDescriptorAdapter::copy() const { FactoryResource<FileDescriptor> pFileDescriptor; if (pFileDescriptor->clone(this) == false) { return NULL; } return pFileDescriptor.release(); }
void OptionsFileLocations::applyChanges(CustomTreeWidget* pTree) { VERIFYNR(pTree != NULL); Service<ConfigurationSettings> pSettings; QTreeWidgetItemIterator iter(pTree); while (*iter != NULL) { QTreeWidgetItem* pItem = *iter; if (pItem != NULL) { string type = pItem->text(0).toStdString(); string confSettingsKey; string confSettingsArgumentKey; for (vector<FileLocationDescriptor>::iterator iter2 = mFileLocations.begin(); iter2 != mFileLocations.end(); ++iter2) { if (iter2->getText() == type) { confSettingsKey = iter2->getKey(); confSettingsArgumentKey = iter2->getArgumentKey(); break; } } if (!confSettingsKey.empty()) { QString strLocation = pItem->text(1); strLocation.replace(QRegExp("\\\\"), "/"); FactoryResource<Filename> pFilename; string location = strLocation.toStdString(); pFilename->setFullPathAndName(location); pSettings->setSetting(confSettingsKey, *(pFilename.get())); if (type == "Message Log Path") { MessageLogMgrImp::instance()->setPath(location); } else if (type == "Wizard Path") { Service<DesktopServices> pDesktop; ApplicationWindow* pAppWindow = static_cast<ApplicationWindow*>(pDesktop->getMainWidget()); if ((location != mWizardPath) && (pAppWindow != NULL)) { pAppWindow->updateWizardCommands(); } } } if (!confSettingsArgumentKey.empty()) { pSettings->setSetting(confSettingsArgumentKey, pItem->text(2).toStdString()); } } ++iter; } }
bool DynamicObjectImp::setAttributeByPath(QStringList pathComponents, DataVariant& value, bool swap) { if (!value.isValid()) { return false; } QString finalName = pathComponents.back(); pathComponents.pop_back(); string loopType = "DynamicObject"; DynamicObject* pLoopObj = dynamic_cast<DynamicObject*>(this); DynamicObject* pCurObj = pLoopObj; for (QStringList::const_iterator iter = pathComponents.begin(); iter != pathComponents.end(); ++iter) { if (pLoopObj == NULL || loopType != "DynamicObject") { return false; } pCurObj = pLoopObj; DataVariant& attrValue = pCurObj->getAttribute(iter->toStdString()); loopType = attrValue.getTypeName(); pLoopObj = attrValue.getPointerToValue<DynamicObject>(); if ((pLoopObj != NULL) && (loopType != "DynamicObject")) { return false; } if (pLoopObj == NULL) { FactoryResource<DynamicObject> pNewObj; if (pCurObj != NULL) { pCurObj->setAttribute(iter->toStdString(), *pNewObj.get()); DataVariant& currentValue = pCurObj->getAttribute(iter->toStdString()); loopType = currentValue.getTypeName(); pLoopObj = currentValue.getPointerToValue<DynamicObject>(); } } } if (pLoopObj == NULL || loopType != "DynamicObject") { return false; } pCurObj = pLoopObj; DynamicObjectImp* const pCurObjImp = dynamic_cast<DynamicObjectImp*>(pCurObj); VERIFY(pCurObjImp != NULL); return pCurObjImp->setAttribute(finalName.toStdString(), value, swap); }
bool bilinear_bayer::copyImage(RasterElement * pRaster, RasterElement * dRaster, int i, Progress * pProgress) { VERIFY(pRaster != NULL); RasterDataDescriptor *pDesc = dynamic_cast < RasterDataDescriptor * >(pRaster->getDataDescriptor()); VERIFY(dRaster != NULL); RasterDataDescriptor *rDesc = dynamic_cast < RasterDataDescriptor * >(dRaster->getDataDescriptor()); DimensionDescriptor thirdBand = pDesc->getActiveBand(i); // get active // band // source FactoryResource < DataRequest > pRequest; pRequest->setInterleaveFormat(BSQ); pRequest->setBands(thirdBand, thirdBand); DataAccessor thirdBandDa = pRaster->getDataAccessor(pRequest.release()); thirdBand = rDesc->getActiveBand(i); // destination FactoryResource < DataRequest > pResultRequest; pResultRequest->setWritable(true); pRequest->setInterleaveFormat(BSQ); pResultRequest->setBands(thirdBand, thirdBand); DataAccessor pDestAcc = dRaster->getDataAccessor(pResultRequest.release()); VERIFY(thirdBandDa.isValid()); VERIFY(pDestAcc.isValid()); for (unsigned int curRow = 0; curRow < pDesc->getRowCount(); ++curRow) { for (unsigned int curCol = 0; curCol < pDesc->getColumnCount(); ++curCol) { switchOnEncoding(pDesc->getDataType(), bilinear, pDestAcc->getColumn(), thirdBandDa, curRow, curCol, pDesc->getRowCount(), pDesc->getColumnCount(), i, pRaster); pDestAcc->nextColumn(); } pDestAcc->nextRow(); } return true; }
bool LandsatEtmPlusImporter::createRasterPager(RasterElement* pRaster) const { string srcFile = pRaster->getFilename(); if (srcFile.empty()) { return false; } { //scoping to ensure the file is closed before creating the pager LargeFileResource srcFileRes; if (!srcFileRes.open(srcFile, O_RDONLY | O_BINARY, S_IREAD)) { return false; } } // create the pager ExecutableResource pPager("BandResamplePager"); VERIFY(pPager->getPlugIn() != NULL); bool isWritable = false; bool useDataDescriptor = false; FactoryResource<Filename> pFilename; VERIFY(pFilename.get() != NULL); pFilename->setFullPathAndName(pRaster->getFilename()); pPager->getInArgList().setPlugInArgValue("Raster Element", pRaster); pPager->getInArgList().setPlugInArgValue("Filename", pFilename.get()); pPager->getInArgList().setPlugInArgValue("isWritable", &isWritable); pPager->getInArgList().setPlugInArgValue("Use Data Descriptor", &useDataDescriptor); RasterDataDescriptor* pDescriptor = static_cast<RasterDataDescriptor*>(pRaster->getDataDescriptor()); VERIFY(pDescriptor != NULL); RasterFileDescriptor* pFileDescriptor = static_cast<RasterFileDescriptor*>(pDescriptor->getFileDescriptor()); VERIFY(pFileDescriptor != NULL); unsigned int band = 5, rows = mB6Rows, cols = mB6Cols; pPager->getInArgList().setPlugInArgValue("Band", &band); pPager->getInArgList().setPlugInArgValue("Rows", &rows); pPager->getInArgList().setPlugInArgValue("Columns", &cols); if (!pPager->execute()) { return false; } RasterPager* pRasterPager = dynamic_cast<RasterPager*>(pPager->getPlugIn()); if (pRasterPager != NULL) { pPager->releasePlugIn(); } else { return false; } pRaster->setPager(pRasterPager); return true; }
bool AoiLogical::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { if (pInArgList == NULL || pOutArgList == NULL) { return false; } if (!extractInputArgs(pInArgList)) { return false; } mProgress.report("Begin AOI set operation.", 1, NORMAL); if (isBatch()) { mProgress.report("Batch mode is not supported.", 0, ERRORS, true); return false; } FactoryResource<BitMask> pResultMask; if (pResultMask.get() == NULL) { mProgress.report("Unable to create result AOI.", 0, ERRORS, true); return false; } mpResult = pResultMask.get(); if (mOperation == "Union") { mpResult->merge(*mpSet1); mpResult->merge(*mpSet2); } else if (mOperation == "Intersection") { mpResult->merge(*mpSet1); mpResult->intersect(*mpSet2); } else { mProgress.report("Invalid operation: " + mOperation, 0, ERRORS, true); return false; } if (!displayResult()) { return false; } mProgress.upALevel(); return true; }
RasterElement* AceAlgorithm::createResults(int numRows, int numColumns, const string& sigName) { RasterElement* pElement = getRasterElement(); if (pElement == NULL) { return NULL; } // Delete an existing element to ensure that the new results element is the correct size Service<ModelServices> pModel; RasterElement* pExistingResults = static_cast<RasterElement*>(pModel->getElement(sigName, TypeConverter::toString<RasterElement>(), pElement)); if (pExistingResults != NULL) { pModel->destroyElement(pExistingResults); } // Create the new results element ModelResource<RasterElement> pResults(RasterUtilities::createRasterElement(sigName, numRows, numColumns, FLT4BYTES, true, pElement)); if (pResults.get() == NULL) { pResults = ModelResource<RasterElement>(RasterUtilities::createRasterElement(sigName, numRows, numColumns, FLT4BYTES, false, pElement)); if (pResults.get() == NULL) { reportProgress(ERRORS, 0, ACEERR009); MessageResource(ACEERR009, "spectral", "C89D361B-DB12-43ED-B276-6D98CA3539EE"); return NULL; } } FactoryResource<Units> pUnits; pUnits->setUnitName("degrees"); vector<int> badValues(1, 181); RasterDataDescriptor* pResultsDescriptor = static_cast<RasterDataDescriptor*>(pResults->getDataDescriptor()); VERIFYRV(pResultsDescriptor != NULL, NULL); pResultsDescriptor->setUnits(pUnits.get()); pResultsDescriptor->setBadValues(badValues); Statistics* pStatistics = pResults->getStatistics(); VERIFYRV(pStatistics != NULL, NULL); pStatistics->setBadValues(badValues); return pResults.release(); }
DataAccessor BackgroundSuppressionShell::getCurrentFrameAccessor() const { if(mpRaster == NULL) { return DataAccessor(NULL, NULL); } RasterDataDescriptor *pDesc = static_cast<RasterDataDescriptor*>(mpRaster->getDataDescriptor()); VERIFYRV(pDesc != NULL, DataAccessor(NULL, NULL)); FactoryResource<DataRequest> request; VERIFYRV(request.get() != NULL, DataAccessor(NULL, NULL)); request->setInterleaveFormat(BSQ); DimensionDescriptor band = pDesc->getBands()[mCurrentFrame]; request->setBands(band, band, 1); return mpRaster->getDataAccessor(request.release()); }
int setRasterLayerColormapName(Layer* pLayer, const char* pName) { RasterLayer* pRaster = dynamic_cast<RasterLayer*>(pLayer); if (pRaster == NULL) { setLastError(SIMPLE_BAD_PARAMS); return 1; } std::string name(pName); ColorMap map; if (!map.loadFromFile(name)) { // see if name is a colormap name const Filename* pSupportFiles = Service<ConfigurationSettings>()->getSettingSupportFilesPath(); if (pSupportFiles == NULL) { setLastError(SIMPLE_OTHER_FAILURE); return 1; } std::string mapDir = pSupportFiles->getFullPathAndName() + SLASH + "ColorTables" + SLASH; if (!map.loadFromFile(mapDir + name) && !map.loadFromFile(mapDir + name + ".clu") && !map.loadFromFile(mapDir + name + ".cgr")) { // scan all the default files and check for a valid name bool located = false; FactoryResource<FileFinder> pFinder; pFinder->findFile(mapDir, "*.c??"); while (pFinder->findNextFile()) { std::string filePath; pFinder->getFullPath(filePath); if (map.loadFromFile(filePath) && map.getName() == name) { located = true; break; } } if (!located) { setLastError(SIMPLE_NOT_FOUND); return 1; } } } pRaster->setColorMap(map); setLastError(SIMPLE_NO_ERROR); return 0; }
bool Nitf::DesSubheader::importMetadata(const ossimPropertyInterface *pHeader, RasterDataDescriptor *pDescriptor) { VERIFY(pHeader != NULL && pDescriptor != NULL); FactoryResource<DynamicObject> pDesSubheaderMetadata; VERIFY(pDesSubheaderMetadata.get() != NULL); VERIFY(Header::importMetadata(pHeader, pDescriptor, pDesSubheaderMetadata.get())); VERIFY(pDescriptor != NULL); DynamicObject* pMetadata = pDescriptor->getMetadata(); VERIFY(pMetadata != NULL); pMetadata->setAttributeByPath(getMetadataPath(), *pDesSubheaderMetadata.get()); return true; }
bool Nitf::EngrdaParser::toDynamicObject(std::istream& input, size_t numBytes, DynamicObject& output, std::string &errorMessage) const { std::vector<char> buf; bool success(true); Nitf::readField<std::string>(input, output, success, ENGRDA::RESRC, 20, errorMessage, buf); Nitf::readField<unsigned int>(input, output, success, ENGRDA::RECNT, 3, errorMessage, buf); unsigned int recnt = QString(&buf.front()).toUInt(); for (unsigned int rec = 0; rec < recnt; ++rec) { std::string recId = QString::number(rec).toStdString(); { FactoryResource<DynamicObject> record; output.setAttribute(recId, *record.get()); } DynamicObject& record = dv_cast<DynamicObject>(output.getAttribute(recId)); unsigned int lbln(0); Nitf::readAndConvertFromStream(input, lbln, success, ENGRDA::ENGLN, 2, errorMessage, buf); Nitf::readField<std::string>(input, record, success, ENGRDA::ENGLBL, lbln, errorMessage, buf); Nitf::readField<unsigned int>(input, record, success, ENGRDA::ENGMTXC, 4, errorMessage, buf); Nitf::readField<unsigned int>(input, record, success, ENGRDA::ENGMTXR, 4, errorMessage, buf); Nitf::readField<std::string>(input, record, success, ENGRDA::ENGTYP, 1, errorMessage, buf); Nitf::readField<unsigned int>(input, record, success, ENGRDA::ENGDTS, 1, errorMessage, buf); int dts = QString(&buf.front()).toInt(); // bytes per element Nitf::readField<std::string>(input, record, success, ENGRDA::ENGDATU, 2, errorMessage, buf); unsigned int datc(0); // data count Nitf::readAndConvertFromStream(input, datc, success, ENGRDA::ENGDATC, 8, errorMessage, buf); // read the data Nitf::readFromStream(input, buf, datc * dts, false); record.setAttribute(ENGRDA::ENGDATA, Blob(&buf.front(), buf.size())); } int64_t numRead = input.tellg(); if (numRead < 0 || static_cast<uint64_t>(numRead) > std::numeric_limits<size_t>::max() || numRead != static_cast<int64_t>(numBytes)) { numReadErrMsg(numRead, numBytes, errorMessage); return false; } return success; }
bool Nitf::Header::exportMetadata(const RasterDataDescriptor *pDescriptor, ossimContainerProperty *pExportHeader) { VERIFY(pDescriptor != NULL); FactoryResource<DynamicObject> pDefaults = createDefaultsDynamicObject(pDescriptor); VERIFY(Header::exportMetadata(pDescriptor, pDefaults.get(), pExportHeader)); const DynamicObject* pMetadata = pDescriptor->getMetadata(); VERIFY(pMetadata != NULL); const DynamicObject* pHeaderMetadata = pMetadata->getAttributeByPath(getMetadataPath()).getPointerToValue<DynamicObject>(); VERIFY(Header::exportMetadata(pDescriptor, pHeaderMetadata, pExportHeader)); return true; }
DataAccessorImpl* createDataAccessor(DataElement* pElement, DataAccessorArgs* pArgs) { RasterElement* pRasterElement = dynamic_cast<RasterElement*>(pElement); if (pRasterElement == NULL) { setLastError(SIMPLE_BAD_PARAMS); return NULL; } FactoryResource<DataRequest> pRequest; RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pRasterElement->getDataDescriptor()); if (pArgs != NULL) { pRequest->setRows(pDescriptor->getActiveRow(pArgs->rowStart), pDescriptor->getActiveRow(pArgs->rowEnd),pArgs->concurrentRows); pRequest->setColumns(pDescriptor->getActiveColumn(pArgs->columnStart), pDescriptor->getActiveColumn(pArgs->columnEnd),pArgs->concurrentColumns); pRequest->setBands(pDescriptor->getActiveBand(pArgs->bandStart), pDescriptor->getActiveBand(pArgs->bandEnd),pArgs->concurrentBands); pRequest->setInterleaveFormat(static_cast<InterleaveFormatTypeEnum>(pArgs->interleaveFormat)); pRequest->setWritable(pArgs->writable != 0); } DataAccessor dataAccessor(pRasterElement->getDataAccessor(pRequest.release())); if (!dataAccessor.isValid()) { setLastError(SIMPLE_BAD_PARAMS); return NULL; } DataAccessorImpl* pRval = dataAccessor.operator->(); pRval->incrementRefCount(); setLastError(SIMPLE_NO_ERROR); return pRval; }
bool SkinsPlugIn::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { MenuBar* pMenu = Service<DesktopServices>()->getMainMenuBar(); QAction* pBefore = pMenu->getMenuItem("&View/&Status Bar"); mpSkinsMenu = pMenu->addMenu("&View/S&kins", pBefore); mpSkinsMenu->setStatusTip("Change the current application skin."); VERIFY(mpSkinsMenu); VERIFY(connect(mpSkinsMenu, SIGNAL(triggered(QAction*)), this, SLOT(changeSkin(QAction*)))); QActionGroup* pActionGroup = new QActionGroup(mpSkinsMenu); pActionGroup->setExclusive(true); // Add default menu entries mpDefaultAction = mpSkinsMenu->addAction("Default"); mpDefaultAction->setCheckable(true); pActionGroup->addAction(mpDefaultAction); // Scan the skins directory const Filename* pPath = ConfigurationSettings::getSettingSupportFilesPath(); FactoryResource<FileFinder> pFinder; VERIFY(pPath && pFinder.get()); pFinder->findFile(pPath->getFullPathAndName() + "/Skins", "*.css", true); while (pFinder->findNextFile()) { std::string title; pFinder->getFileTitle(title); QAction* pAction = mpSkinsMenu->addAction(QString::fromStdString(title)); pAction->setCheckable(true); pActionGroup->addAction(pAction); } pFinder->findFile(pPath->getFullPathAndName() + "/Skins", "*.rcc", true); while (pFinder->findNextFile()) { std::string fullPath; std::string fileTitle; pFinder->getFullPath(fullPath); pFinder->getFileTitle(fileTitle); QString path = QString::fromStdString(fullPath); QString root = "/" + QString::fromStdString(fileTitle); if (QResource::registerResource(path, root)) { mRegisteredResources[root] = path; } } mDefaultStyleSheet = qApp->styleSheet(); mpDefaultAction->setChecked(true); return true; }
vector<ImportDescriptor*> CgmImporter::getImportDescriptors(const string& filename) { vector<ImportDescriptor*> descriptors; if (!filename.empty()) { FactoryResource<Filename> pFullFilename; pFullFilename->setFullPathAndName(filename); ImportDescriptor* pImportDescriptor = mpModel->createImportDescriptor(filename, "AnnotationElement", NULL); if (pImportDescriptor != NULL) { DataDescriptor* pDescriptor = pImportDescriptor->getDataDescriptor(); if (pDescriptor != NULL) { FactoryResource<FileDescriptor> pFileDescriptor; if (pFileDescriptor.get() != NULL) { pFileDescriptor->setFilename(filename); pDescriptor->setFileDescriptor(pFileDescriptor.get()); } } descriptors.push_back(pImportDescriptor); } } return descriptors; }
bool Nitf::NitfImporterShell::createRasterPager(RasterElement *pRaster) const { VERIFY(pRaster != NULL); DataDescriptor* pDd = pRaster->getDataDescriptor(); VERIFY(pDd != NULL); FileDescriptor* pFd = pDd->getFileDescriptor(); VERIFY(pFd != NULL); const string& datasetLocation = pFd->getDatasetLocation(); if (datasetLocation.empty() == true) { return false; } stringstream imageNameStream(datasetLocation.substr(1)); int imageSegment; imageNameStream >> imageSegment; FactoryResource<Filename> pFn; pFn->setFullPathAndName(pFd->getFilename()); ExecutableResource pPlugIn("NitfPager"); pPlugIn->getInArgList().setPlugInArgValue("Segment Number", &imageSegment); pPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedElementArg(), pRaster); pPlugIn->getInArgList().setPlugInArgValue(CachedPager::PagedFilenameArg(), pFn.get()); if (pPlugIn->execute() == true) { RasterPager* pPager = dynamic_cast<RasterPager*>(pPlugIn->getPlugIn()); if (pPager != NULL) { pRaster->setPager(pPager); pPlugIn->releasePlugIn(); return true; } } return false; }
vector<ImportDescriptor*> SignatureSetImporter::createImportDescriptors(DOMTreeWalker* pTree, vector<string> &datasetPath) { vector<ImportDescriptor*> descriptors; FactoryResource<DynamicObject> pMetadata; VERIFYRV(pMetadata.get() != NULL, descriptors); string datasetName = StringUtilities::toDisplayString(mDatasetNumber++); for (DOMNode* pChld = pTree->firstChild(); pChld != NULL; pChld = pTree->nextSibling()) { if (XMLString::equals(pChld->getNodeName(), X("metadata"))) { DOMElement* pElmnt = static_cast<DOMElement*>(pChld); string name = A(pElmnt->getAttribute(X("name"))); string val = A(pElmnt->getAttribute(X("value"))); pMetadata->setAttribute(name, val); if (name == "Name") { datasetName = val; } } else if (XMLString::equals(pChld->getNodeName(), X("signature_set"))) { datasetPath.push_back(datasetName); vector<ImportDescriptor*> sub = createImportDescriptors(pTree, datasetPath); datasetPath.pop_back(); descriptors.insert(descriptors.end(), sub.begin(), sub.end()); pTree->parentNode(); } } ImportDescriptorResource pImportDescriptor(datasetName, "SignatureSet", datasetPath); VERIFYRV(pImportDescriptor.get() != NULL, descriptors); DataDescriptor* pDataDescriptor = pImportDescriptor->getDataDescriptor(); VERIFYRV(pDataDescriptor != NULL, descriptors); FactoryResource<SignatureFileDescriptor> pFileDescriptor; VERIFYRV(pFileDescriptor.get() != NULL, descriptors); pFileDescriptor->setFilename(mFilename); datasetPath.push_back(datasetName); string loc = "/" + StringUtilities::join(datasetPath, "/"); datasetPath.pop_back(); pFileDescriptor->setDatasetLocation(loc); pDataDescriptor->setFileDescriptor(pFileDescriptor.get()); pDataDescriptor->setMetadata(pMetadata.get()); descriptors.push_back(pImportDescriptor.release()); return descriptors; }
const double *SignatureLibraryImp::getOrdinateData(unsigned int index) const { if (mNeedToResample || mResampledData.empty()) { const_cast<SignatureLibraryImp*>(this)->resample(mAbscissa); } if (index < mSignatures.size() && (!mAbscissa.empty() || mpOdre.get() != NULL)) { if (mAbscissa.empty()) { const RasterDataDescriptor* pDesc = dynamic_cast<const RasterDataDescriptor*>(mpOdre.get()->getDataDescriptor()); if (pDesc != NULL) { FactoryResource<DataRequest> pRequest; pRequest->setInterleaveFormat(BIP); pRequest->setBands(pDesc->getActiveBand(0), pDesc->getActiveBand(pDesc->getBandCount() - 1), pDesc->getBandCount()); pRequest->setRows(pDesc->getActiveRow(index), pDesc->getActiveRow(index), 1); DataAccessor da = mpOdre->getDataAccessor(pRequest.release()); if (da.isValid()) { static vector<double> sOriginalOrdinateData; sOriginalOrdinateData.resize(mOriginalAbscissa.size()); switchOnEncoding(pDesc->getDataType(), getOriginalAsDouble, da->getRow(), mOriginalAbscissa.size(), sOriginalOrdinateData); return &sOriginalOrdinateData[0]; } } return NULL; } return &mResampledData[index * getAbscissa().size()]; } return NULL; }
bool SpectralLibraryManager::getResampledSignatureValues(const RasterElement* pRaster, const Signature* pSignature, std::vector<double>& values) { values.clear(); if (pRaster == NULL || pSignature == NULL) { return false; } const RasterElement* pLibData = getResampledLibraryData(pRaster); if (pLibData == NULL) { return false; } int index = getSignatureIndex(pSignature); if (index < 0) { return false; } const RasterDataDescriptor* pLibDesc = dynamic_cast<const RasterDataDescriptor*>(pLibData->getDataDescriptor()); VERIFY(pLibDesc != NULL); unsigned int numBands = pLibDesc->getBandCount(); values.reserve(numBands); FactoryResource<DataRequest> pRqt; unsigned int row = static_cast<unsigned int>(index); pRqt->setInterleaveFormat(BIP); pRqt->setRows(pLibDesc->getActiveRow(row), pLibDesc->getActiveRow(row), 1); DataAccessor acc = pLibData->getDataAccessor(pRqt.release()); VERIFY(acc.isValid()); double* pDbl = reinterpret_cast<double*>(acc->getColumn()); for (unsigned int band = 0; band < numBands; ++band) { values.push_back(*pDbl); ++pDbl; } return true; }
void FeatureClassDlg::addFeatureClass() { // Assign a unique default name for the feature class int featureClassNumber = 1; QString className = "Feature Class " + QString::number(featureClassNumber); while (mpClassList->findItems(className, Qt::MatchExactly).empty() == false) { className = "Feature Class " + QString::number(++featureClassNumber); } // Add the feature class to the member DynamicObject FactoryResource<DynamicObject> pFields; mpFeatureClasses->setAttribute(className.toStdString(), *(pFields.get())); // Create a new list widget item and select it QListWidgetItem* pItem = new QListWidgetItem(className, mpClassList); pItem->setData(Qt::UserRole, QVariant(className)); pItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable); mpClassList->addItem(pItem); mpClassList->setCurrentItem(pItem); }
DataAccessor getAccessor(int band, bool writable = false) { FactoryResource<DataRequest> pRequest = FactoryResource<DataRequest>(); pRequest->setRows(pDataDescriptor->getActiveRow(0), pDataDescriptor->getActiveRow(getRowCount() - 1)); pRequest->setColumns(pDataDescriptor->getActiveColumn(0), pDataDescriptor->getActiveColumn(getColumnCount() - 1)); pRequest->setBands(pDataDescriptor->getActiveBand(band), pDataDescriptor->getActiveBand(band)); pRequest->setWritable(writable); return pRaster->getDataAccessor(pRequest.release()); }
bool Nitf::TrePlugInResource::exportMetadata(const RasterDataDescriptor& descriptor, const RasterFileDescriptor& exportDescriptor, ossimNitfWriter& writer, string& errorMessage) const { const TreParser* pParser = dynamic_cast<const TreParser*>(get()); VERIFY(pParser != NULL); string treErrorMessage; FactoryResource<DynamicObject> pTre; VERIFY(pTre.get() != NULL); unsigned int ownerIndex = 1; string tagType = "IXSHD"; TreExportStatus status = pParser->exportMetadata(descriptor, exportDescriptor, *pTre.get(), ownerIndex, tagType, treErrorMessage); if (treErrorMessage.empty() == false) { errorMessage = getArgs().mPlugInName + ": " + treErrorMessage; } string writeErrorMessage; switch (status) { case REPLACE: writeTag(*pTre.get(), ownerIndex, ossimString(tagType), writer, writeErrorMessage); if (!writeErrorMessage.empty()) { errorMessage += "," + writeErrorMessage; } return true; case REMOVE: return true; default: break; } return false; }