Line data Source code
1 : /********************************************************************** 2 : * 3 : * Project: GDAL 4 : * Purpose: Dataset that modifies the orientation of an underlying dataset 5 : * Author: Even Rouault, <even dot rouault at spatialys dot com> 6 : * 7 : ********************************************************************** 8 : * Copyright (c) 2022, Even Rouault, <even dot rouault at spatialys dot com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #ifndef GDAL_ORIENTED_DATASET_H 14 : #define GDAL_ORIENTED_DATASET_H 15 : 16 : #include "gdal_priv.h" 17 : 18 : //! @cond Doxygen_Suppress 19 : 20 : /************************************************************************/ 21 : /* GDALOrientedDataset */ 22 : /************************************************************************/ 23 : 24 : class CPL_DLL GDALOrientedDataset : public GDALDataset 25 : { 26 : public: 27 : /** Origin of the source dataset. 28 : * 29 : * Defines of the point at (row, col) = (0, 0) in the source dataset 30 : * should be interpreted to generate the dataset taking into account 31 : * this orientation. 32 : * 33 : * Numeric values are the same as in TIFF and EXIF Orientation tags. 34 : * 35 : * See http://sylvana.net/jpegcrop/exif_orientation.html for clear 36 : * explanations. 37 : */ 38 : enum class Origin 39 : { 40 : TOP_LEFT = 1, /* row 0 top, col 0 lhs */ 41 : TOP_RIGHT = 2, /* row 0 top, col 0 rhs */ 42 : BOT_RIGHT = 3, /* row 0 bottom, col 0 rhs */ 43 : BOT_LEFT = 4, /* row 0 bottom, col 0 lhs */ 44 : LEFT_TOP = 5, /* row 0 lhs, col 0 top */ 45 : RIGHT_TOP = 6, /* row 0 rhs, col 0 top */ 46 : RIGHT_BOT = 7, /* row 0 rhs, col 0 bottom */ 47 : LEFT_BOT = 8, /* row 0 lhs, col 0 bottom */ 48 : }; 49 : 50 : GDALOrientedDataset(GDALDataset *poSrcDataset, Origin eOrigin); 51 : GDALOrientedDataset(std::unique_ptr<GDALDataset> &&poSrcDataset, 52 : Origin eOrigin); 53 : 54 0 : char **GetMetadataDomainList() override 55 : { 56 0 : return m_poSrcDS->GetMetadataDomainList(); 57 : } 58 : 59 : char **GetMetadata(const char *pszDomain = "") override; 60 : const char *GetMetadataItem(const char *pszName, 61 : const char *pszDomain = "") override; 62 : 63 : private: 64 : friend class GDALOrientedRasterBand; 65 : 66 : std::unique_ptr<GDALDataset> m_poSrcDSHolder{}; 67 : GDALDataset *m_poSrcDS = nullptr; 68 : Origin m_eOrigin; 69 : CPLStringList m_aosSrcMD{}; 70 : CPLStringList m_aosSrcMD_EXIF{}; 71 : 72 : GDALOrientedDataset(const GDALOrientedDataset &) = delete; 73 : GDALOrientedDataset &operator=(const GDALOrientedDataset &) = delete; 74 : }; 75 : 76 : //! @endcond 77 : 78 : #endif