Coverage Report

Created: 2026-03-30 09:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/pcidsk/sdk/segment/systiledir.cpp
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Purpose:  Declaration of the SysTileDir class.
4
 *
5
 * This class is used to manage access to the system block tile directory.
6
 * This segment is used to keep track of one or more tile layers stored in
7
 * system block data segments. These tile layers are used to hold tiled images
8
 * for primary bands or overviews.
9
 *
10
 * This class is closely partnered with the CTiledChannel class.
11
 *
12
 ******************************************************************************
13
 * Copyright (c) 2009
14
 * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, Canada.
15
 *
16
 * SPDX-License-Identifier: MIT
17
 ****************************************************************************/
18
19
#include "segment/systiledir.h"
20
#include "blockdir/asciitiledir.h"
21
#include "blockdir/binarytiledir.h"
22
#include "blockdir/blocktilelayer.h"
23
#include "core/cpcidskblockfile.h"
24
#include "pcidsk_exception.h"
25
26
using namespace PCIDSK;
27
28
/************************************************************************/
29
/*                             SysTileDir()                             */
30
/************************************************************************/
31
SysTileDir::SysTileDir(PCIDSKFile * poFile, int nSegment,
32
                       const char * pbySegmentData)
33
108
    : CPCIDSKSegment(poFile, nSegment, pbySegmentData)
34
108
{
35
108
    mpoTileDir = nullptr;
36
108
}
Unexecuted instantiation: PCIDSK::SysTileDir::SysTileDir(PCIDSK::PCIDSKFile*, int, char const*)
PCIDSK::SysTileDir::SysTileDir(PCIDSK::PCIDSKFile*, int, char const*)
Line
Count
Source
33
108
    : CPCIDSKSegment(poFile, nSegment, pbySegmentData)
34
108
{
35
108
    mpoTileDir = nullptr;
36
108
}
37
38
/************************************************************************/
39
/*                            ~SysTileDir()                             */
40
/************************************************************************/
41
SysTileDir::~SysTileDir(void)
42
107
{
43
107
    try
44
107
    {
45
107
        Synchronize();
46
107
    }
47
107
    catch( const PCIDSKException& )
48
107
    {
49
        // TODO ?
50
0
    }
51
107
    delete mpoTileDir;
52
107
}
53
54
/************************************************************************/
55
/*                             Initialize()                             */
56
/************************************************************************/
57
void SysTileDir::Initialize(void)
58
0
{
59
0
}
60
61
/************************************************************************/
62
/*                            Synchronize()                             */
63
/************************************************************************/
64
void SysTileDir::Synchronize(void)
65
107
{
66
107
    if (mpoTileDir)
67
73
        mpoTileDir->Sync();
68
107
}
69
70
/************************************************************************/
71
/*                            LoadTileDir()                             */
72
/************************************************************************/
73
void SysTileDir::LoadTileDir(void)
74
123
{
75
123
    if (mpoTileDir)
76
16
        return;
77
78
107
    CPCIDSKBlockFile * poBlockFile = new CPCIDSKBlockFile(file);
79
80
107
    if (segment_name == "SysBMDir")
81
65
    {
82
65
        mpoTileDir = new AsciiTileDir(poBlockFile, (uint16) segment);
83
65
    }
84
42
    else if (segment_name == "TileDir")
85
42
    {
86
42
        mpoTileDir = new BinaryTileDir(poBlockFile, (uint16) segment);
87
42
    }
88
0
    else
89
0
    {
90
0
        delete poBlockFile;
91
0
        return ThrowPCIDSKException("Unknown block tile directory name.");
92
0
    }
93
107
}
94
95
/************************************************************************/
96
/*                           CreateTileDir()                            */
97
/************************************************************************/
98
void SysTileDir::CreateTileDir(void)
99
0
{
100
0
    CPCIDSKBlockFile * poBlockFile = new CPCIDSKBlockFile(file);
101
102
0
    if (segment_name == "SysBMDir")
103
0
    {
104
0
        mpoTileDir = new AsciiTileDir(poBlockFile, (uint16) segment, 8192);
105
0
    }
106
0
    else if (segment_name == "TileDir")
107
0
    {
108
0
        uint32 nBlockSize = BinaryTileDir::GetOptimizedBlockSize(poBlockFile);
109
110
0
        mpoTileDir = new BinaryTileDir(poBlockFile, (uint16) segment,
111
0
                                       nBlockSize);
112
0
    }
113
0
    else
114
0
    {
115
0
        delete poBlockFile;
116
0
        return ThrowPCIDSKException("Unknown block tile directory name.");
117
0
    }
118
0
}
119
120
/************************************************************************/
121
/*                            GetTileLayer()                            */
122
/************************************************************************/
123
BlockTileLayer * SysTileDir::GetTileLayer(uint32 nLayer)
124
123
{
125
123
    LoadTileDir();
126
127
123
    return mpoTileDir->GetTileLayer(nLayer);
128
123
}
129
130
/************************************************************************/
131
/*                          CreateTileLayer()                           */
132
/************************************************************************/
133
uint32 SysTileDir::CreateTileLayer(uint32 nWidth, uint32 nHeight,
134
                                   uint32 nTileWidth, uint32 nTileHeight,
135
                                   eChanType nDataType, std::string oCompress)
136
0
{
137
0
    if (oCompress.empty())
138
0
        oCompress = "NONE";
139
140
0
    LoadTileDir();
141
142
0
    uint32 nLayer = mpoTileDir->CreateLayer(BLTImage);
143
144
0
    BlockTileLayer * poTileLayer = mpoTileDir->GetTileLayer(nLayer);
145
146
0
    poTileLayer->SetTileLayerInfo(nWidth, nHeight, nTileWidth, nTileHeight,
147
0
                                  DataTypeName(nDataType), oCompress);
148
149
0
    return nLayer;
150
0
}