Coverage Report

Created: 2026-02-14 09:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/miramon/miramon_dataset.h
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Project:  MiraMon Raster Driver
4
 * Purpose:  Implements MMRDataset class: responsible for generating the
5
 *           main dataset or the subdatasets as needed.
6
 * Author:   Abel Pau
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 2025, Xavier Pons
10
 *
11
 * SPDX-License-Identifier: MIT
12
 ****************************************************************************/
13
14
#ifndef MMRDATASET_H_INCLUDED
15
#define MMRDATASET_H_INCLUDED
16
17
#include <cstddef>
18
#include <vector>
19
#include <optional>
20
#include <array>
21
22
#include "gdal_pam.h"
23
#include "gdal_rat.h"
24
25
#include "../miramon_common/mm_gdal_constants.h"  // For MM_EXT_DBF_N_FIELDS
26
#include "miramon_rel.h"
27
28
/* ==================================================================== */
29
/*                              MMRDataset                              */
30
/* ==================================================================== */
31
32
class MMRRasterBand;
33
class MMRRel;
34
35
/*
36
    * -oo  RAT_OR_CT
37
    Controls whether the Raster Attribute Table (RAT) and/or the Color Table (CT) are exposed.
38
39
      ALL
40
            Expose both the attribute table and the color table. Note that in some software this option may cause visualization and/or legend issues.
41
      RAT
42
            Expose the attribute table only, without the color table.
43
      PER_BAND_ONLY
44
            Expose the color table only, without the attribute table.
45
    */
46
enum class RAT_OR_CT
47
{
48
    ALL,
49
    RAT,
50
    CT
51
};
52
53
class MMRDataset final : public GDALPamDataset
54
{
55
  public:
56
    explicit MMRDataset(GDALOpenInfo *poOpenInfo);
57
    MMRDataset(const MMRDataset &) =
58
        delete;  // I don't want to construct a MMRDataset from another MMRDataset (effc++)
59
    MMRDataset &operator=(const MMRDataset &) =
60
        delete;  // I don't want to assign a MMRDataset to another MMRDataset (effc++)
61
    ~MMRDataset() override;
62
63
    static int Identify(GDALOpenInfo *);
64
    static GDALDataset *Open(GDALOpenInfo *);
65
66
    MMRRel *GetRel()
67
3.27k
    {
68
3.27k
        return m_pMMRRel.get();
69
3.27k
    }
70
71
    RAT_OR_CT GetRatOrCT() const
72
3.27k
    {
73
3.27k
        return nRatOrCT;
74
3.27k
    }
75
76
  private:
77
    void ReadProjection();
78
    void AssignBandsToSubdataSets();
79
    void CreateSubdatasetsFromBands();
80
    bool CreateRasterBands();
81
    bool BandInTheSameDataset(int nIBand1, int nIBan2) const;
82
83
    int UpdateGeoTransform();
84
    const OGRSpatialReference *GetSpatialRef() const override;
85
    CPLErr GetGeoTransform(GDALGeoTransform &gt) const override;
86
87
    bool IsValid() const
88
5.49k
    {
89
5.49k
        return m_bIsValid;
90
5.49k
    }
91
92
    GDALGeoTransform m_gt{};
93
    OGRSpatialReference m_oSRS{};
94
95
    bool m_bIsValid =
96
        false;  // Determines if the created object is valid or not.
97
    std::unique_ptr<MMRRel> m_pMMRRel = nullptr;
98
99
    std::vector<gdal::GCP> m_aoGCPs{};
100
101
    // Numbers of subdatasets (if any) in this dataset.
102
    int m_nNSubdataSets = 0;
103
104
    // To expose CT, RAT or both
105
    RAT_OR_CT nRatOrCT = RAT_OR_CT::ALL;
106
};
107
108
#endif  // MMRDATASET_H_INCLUDED