#ifndef PB_STEPEXPORTATTRIBUTESASVECTOR_H #define PB_STEPEXPORTATTRIBUTESASVECTOR_H #include #include "ct_step/abstract/ct_abstractstep.h" #include "ct_itemdrawable/ct_plotlistingrid.h" #include "ct_itemdrawable/ct_loopcounter.h" #ifdef USE_GDAL #include "gdal_priv.h" #include "ogr_core.h" #include "ogrsf_frmts.h" #include "cpl_conv.h" #include "readers/tools/gdal/ct_gdaltools.h" #endif class PB_StepExportAttributesAsVector: public CT_AbstractStep { Q_OBJECT using SuperClass = CT_AbstractStep; public: PB_StepExportAttributesAsVector(); QString description() const final; QString detailledDescription() const final; QString inputDescription() const final; QString outputDescription() const final; QString detailsDescription() const final; CT_VirtualAbstractStep* createNewInstance() const final; protected: void declareInputModels(CT_StepInModelStructureManager& manager) final; void fillPostInputConfigurationDialog(CT_StepConfigurableDialog* postInputConfigDialog) final; void declareOutputModels(CT_StepOutModelStructureManager& manager) final; void compute() final; private: #ifdef USE_GDAL struct GDalDatasetScopedPointerCustomDeleter { static inline void cleanup(GDALDataset* pointer) { GDALClose(pointer); } }; QMap _gdalRasterDrivers; QMap _gdalVectorDrivers; QMap _ogrTypes; #endif CT_HandleInResultGroup<> mInResult; CT_HandleInStdZeroOrMoreGroup mInRootGroup; CT_HandleInStdGroup<> mInGroupMain; CT_HandleInSingularItem mInPlotListInGrid; CT_HandleInSingularItem mInItemWithXY; CT_HandleInStdItemAttribute mInItemAttributeX; CT_HandleInStdItemAttribute mInItemAttributeY; CT_HandleInSingularItem mInItemWithAttribute; // optionnal and multiple CT_HandleInStdItemAttribute mInItemAttribute; // optionnal and multiple CT_HandleInResultGroup<0,1> mInResultCounter; CT_HandleInStdGroup<> mInGroupCounter; CT_HandleInSingularItem mInLoopCounter; QList _modelsKeys; QList _modelsKeysWithoutXOrYAttribute; QMap _names; QMap _shortNames; QMap _itemNames; // Step parameters bool _replaceSpecialCharacters; bool _shortenNames; QString _vectorDriverName; QString _vectorPrefix; QStringList _outVectorFolder; QString createExportBaseName(bool& first) const; void computeModelsKeysAndNamesAndOgrTypes(); template void computeModelsKeysAndNamesAndOgrTypes(InHandleT& handle, bool isNotXOrYAttribute) { auto it = handle.template iterateSelectedOutputModels(mInResult); auto begin = it.begin(); auto end = it.end(); while(begin != end) { if(isStopped()) return; const CT_OutAbstractItemAttributeModel* attModel = (*begin); const CT_OutAbstractModel* itemModel = static_cast(attModel->parentModel()); computeModelsKeysAndNamesAndOgrTypesForModels(itemModel, attModel, isNotXOrYAttribute); ++begin; } } void computeModelsKeysAndNamesAndOgrTypesForModels(const CT_OutAbstractModel* itemModel, const CT_OutAbstractItemAttributeModel* attModel, bool isNotXOrYAttribute); QString computeKeyForModels(const CT_OutAbstractModel* itemModel, const CT_OutAbstractModel* attModel) const; #ifdef USE_GDAL void preExportVectorIfNecessary(const QString& exportBaseName, QScopedPointer& vectorDataSet, OGRLayer*& vectorLayer); #endif void addToIndexedAttributesCollection(const CT_AbstractSingularItemDrawable* item, const CT_AbstractItemAttribute* attribute, QMap >& indexedAttributes) const; void replaceSpecialCharacters(QMap &names) const; }; #endif // PB_StepExportAttributesAsVector_H