Coverage Report

Created: 2025-06-09 07:43

/src/gdal/frmts/envisat/adsrange.hpp
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 * Project:  APP ENVISAT Support
3
 * Purpose:  Detect range of ADS records matching the MDS records
4
 * Author:   Martin Paces, martin.paces@eox.at
5
 *
6
 ******************************************************************************
7
 * Copyright (c) 2013, EOX IT Services, GmbH
8
 *
9
 * SPDX-License-Identifier: MIT
10
 *****************************************************************************/
11
12
#ifndef adsrange_hpp
13
#define adsrange_hpp
14
15
#include "cpl_string.h"
16
17
CPL_C_START
18
#include "EnvisatFile.h"
19
CPL_C_END
20
#include "records.h"
21
22
#include "timedelta.hpp"
23
24
/* -------------------------------------------------------------------- */
25
/*
26
 * class ADSRange
27
 *
28
 * Range of ADS record matching the range of the MDS records.
29
 *
30
 */
31
32
class ADSRange
33
{
34
  protected:
35
    int idx_first; /* index of the first matched ADSR */
36
    int idx_last;  /* index of the last matched ADSR */
37
    int off_first; /* num. of lines from 1st matched ADSR to 1st MDSR */
38
    int off_last;  /* num. of lines from last MDSR to last matched ADSR*/
39
40
    TimeDelta mjd_first;   /* MDJ time of the first matched ADS record */
41
    TimeDelta mjd_last;    /* MDJ time of the last matched ADS record */
42
    TimeDelta mjd_m_first; /* MDJ time of the first MDS record */
43
    TimeDelta mjd_m_last;  /* MDJ time of the last MDS record */
44
45
  public:
46
    /* CONSTRUCTOR */
47
    ADSRange()
48
0
        : idx_first(0), idx_last(0), off_first(0), off_last(0), mjd_first(0),
49
0
          mjd_last(0), mjd_m_first(0), mjd_m_last(0)
50
0
    {
51
0
    }
52
53
    ADSRange(const int idx_firstIn, const int idx_lastIn, const int off_firstIn,
54
             const int off_lastIn, const TimeDelta &mjd_firstIn,
55
             const TimeDelta &mjd_lastIn, const TimeDelta &mjd_m_firstIn,
56
             const TimeDelta &mjd_m_lastIn)
57
        : idx_first(idx_firstIn), idx_last(idx_lastIn), off_first(off_firstIn),
58
          off_last(off_lastIn), mjd_first(mjd_firstIn), mjd_last(mjd_lastIn),
59
          mjd_m_first(mjd_m_firstIn), mjd_m_last(mjd_m_lastIn)
60
0
    {
61
0
    }
62
63
    /* get count of matched records */
64
    inline int getDSRCount(void) const
65
0
    {
66
0
        return (idx_last - idx_first + 1);
67
0
    }
68
69
    /* GETTERS */
70
71
    /* get index of the first matched ADS record */
72
    inline int getFirstIndex(void) const
73
0
    {
74
0
        return this->idx_first;
75
0
    }
76
77
    /* get index of the last matched ADS record */
78
    inline int getLastIndex(void) const
79
0
    {
80
0
        return this->idx_last;
81
0
    }
82
83
    /* get offset of the first matched ADS record */
84
    inline int getFirstOffset(void) const
85
0
    {
86
0
        return this->off_first;
87
0
    }
88
89
    /* get offset of the last matched ADS record */
90
    inline int getLastOffset(void) const
91
0
    {
92
0
        return this->off_last;
93
0
    }
94
95
    /* get MJD time of the first matched ADS record */
96
    inline TimeDelta getFirstTime(void) const
97
0
    {
98
0
        return this->mjd_first;
99
0
    }
100
101
    /* get MJD time of the last matched ADS record */
102
    inline TimeDelta getLastTime(void) const
103
0
    {
104
0
        return this->mjd_last;
105
0
    }
106
107
    /* get MJD time of the first MDS record */
108
    inline TimeDelta getMDSRFirstTime(void) const
109
0
    {
110
0
        return this->mjd_m_first;
111
0
    }
112
113
    /* get MJD time of the last MDS record */
114
    inline TimeDelta getMDSRLastTime(void) const
115
0
    {
116
0
        return this->mjd_m_last;
117
0
    }
118
};
119
120
/* -------------------------------------------------------------------- */
121
/*
122
 * NOTE: There are two kinds of ADS records:
123
 *
124
 *  1) One ADS record applicable to all consequent MDS records until replaced
125
 *     by another ADS record, i.e., last MDS records does no need to be
126
 *     followed by an ADS record.
127
 *
128
 *  2) Two ADS records applicable to all MDS records between them
129
 *     (e.g., tiepoints ADS), i.e., last MDS record should be followed
130
 *     by an ADS record having the same or later time-stamp.
131
 *
132
 *  The type of the ADS affects the way how the ADS records corresponding
133
 *  to a set of MDS records should be selected.
134
 */
135
136
class ADSRangeLastAfter : public ADSRange
137
{
138
139
  public:
140
    /* CONSTRUCTOR */
141
    ADSRangeLastAfter(EnvisatFile &envfile, int ads_idx, int mds_idx,
142
                      const TimeDelta &line_interval);
143
};
144
145
#endif /*tiepointrange_hpp*/