• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OSGeo / gdal / 15885686134

25 Jun 2025 07:44PM UTC coverage: 71.084%. Remained the same
15885686134

push

github

rouault
gdal_priv.h: fix C++11 compatibility

573814 of 807237 relevant lines covered (71.08%)

250621.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.71
/frmts/raw/byndataset.cpp
1
/******************************************************************************
2
 *
3
 * Project:  Natural Resources Canada's Geoid BYN file format
4
 * Purpose:  Implementation of BYN format
5
 * Author:   Ivan Lucena, ivan.lucena@outlook.com
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2018, Ivan Lucena
9
 * Copyright (c) 2018, Even Rouault
10
 *
11
 * SPDX-License-Identifier: MIT
12
 ****************************************************************************/
13

14
#include "cpl_port.h"
15
#include "byndataset.h"
16
#include "rawdataset.h"
17

18
#include "cpl_string.h"
19
#include "gdal_frmts.h"
20
#include "ogr_spatialref.h"
21
#include "ogr_srs_api.h"
22

23
#include <algorithm>
24
#include <cstdlib>
25
#include <limits>
26

27
// Specification at
28
// https://www.nrcan.gc.ca/sites/www.nrcan.gc.ca/files/earthsciences/pdf/gpshgrid_e.pdf
29

30
const static BYNEllipsoids EllipsoidTable[] = {
31
    {"GRS80", 6378137.0, 298.257222101},
32
    {"WGS84", 6378137.0, 298.257223564},
33
    {"ALT1", 6378136.3, 298.256415099},
34
    {"GRS67", 6378160.0, 298.247167427},
35
    {"ELLIP1", 6378136.46, 298.256415099},
36
    {"ALT2", 6378136.3, 298.257},
37
    {"ELLIP2", 6378136.0, 298.257},
38
    {"CLARKE 1866", 6378206.4, 294.9786982}};
39

40
/************************************************************************/
41
/*                            BYNRasterBand()                           */
42
/************************************************************************/
43

44
BYNRasterBand::BYNRasterBand(GDALDataset *poDSIn, int nBandIn,
4✔
45
                             VSILFILE *fpRawIn, vsi_l_offset nImgOffsetIn,
46
                             int nPixelOffsetIn, int nLineOffsetIn,
47
                             GDALDataType eDataTypeIn, int bNativeOrderIn)
4✔
48
    : RawRasterBand(poDSIn, nBandIn, fpRawIn, nImgOffsetIn, nPixelOffsetIn,
49
                    nLineOffsetIn, eDataTypeIn, bNativeOrderIn,
50
                    RawRasterBand::OwnFP::NO)
4✔
51
{
52
}
4✔
53

54
/************************************************************************/
55
/*                           ~BYNRasterBand()                           */
56
/************************************************************************/
57

58
BYNRasterBand::~BYNRasterBand()
8✔
59
{
60
}
8✔
61

62
/************************************************************************/
63
/*                           GetNoDataValue()                           */
64
/************************************************************************/
65

66
double BYNRasterBand::GetNoDataValue(int *pbSuccess)
×
67
{
68
    if (pbSuccess)
×
69
        *pbSuccess = TRUE;
×
70
    int bSuccess = FALSE;
×
71
    double dfNoData = GDALPamRasterBand::GetNoDataValue(&bSuccess);
×
72
    if (bSuccess)
×
73
    {
74
        return dfNoData;
×
75
    }
76
    const double dfFactor =
×
77
        reinterpret_cast<BYNDataset *>(poDS)->hHeader.dfFactor;
×
78
    return eDataType == GDT_Int16 ? 32767.0 : 9999.0 * dfFactor;
×
79
}
80

81
/************************************************************************/
82
/*                              GetScale()                              */
83
/************************************************************************/
84

85
double BYNRasterBand::GetScale(int *pbSuccess)
×
86
{
87
    if (pbSuccess != nullptr)
×
88
        *pbSuccess = TRUE;
×
89
    const double dfFactor =
×
90
        reinterpret_cast<BYNDataset *>(poDS)->hHeader.dfFactor;
×
91
    return (dfFactor != 0.0) ? 1.0 / dfFactor : 0.0;
×
92
}
93

94
/************************************************************************/
95
/* ==================================================================== */
96
/*                              BYNDataset                              */
97
/* ==================================================================== */
98
/************************************************************************/
99

100
BYNDataset::BYNDataset()
4✔
101
    : fpImage(nullptr), hHeader{0, 0, 0, 0, 0, 0,   0,   0, 0.0, 0,   0, 0,
102
                                0, 0, 0, 0, 0, 0.0, 0.0, 0, 0,   0.0, 0}
4✔
103
{
104
    m_oSRS.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
4✔
105
}
4✔
106

107
/************************************************************************/
108
/*                            ~BYNDataset()                             */
109
/************************************************************************/
110

111
BYNDataset::~BYNDataset()
8✔
112

113
{
114
    BYNDataset::Close();
4✔
115
}
8✔
116

117
/************************************************************************/
118
/*                              Close()                                 */
119
/************************************************************************/
120

121
CPLErr BYNDataset::Close()
8✔
122
{
123
    CPLErr eErr = CE_None;
8✔
124
    if (nOpenFlags != OPEN_FLAGS_CLOSED)
8✔
125
    {
126
        if (BYNDataset::FlushCache(true) != CE_None)
4✔
127
            eErr = CE_Failure;
×
128

129
        if (fpImage != nullptr)
4✔
130
        {
131
            if (VSIFCloseL(fpImage) != 0)
4✔
132
            {
133
                eErr = CE_Failure;
×
134
                CPLError(CE_Failure, CPLE_FileIO, "I/O error");
×
135
            }
136
        }
137

138
        if (GDALPamDataset::Close() != CE_None)
4✔
139
            eErr = CE_Failure;
×
140
    }
141
    return eErr;
8✔
142
}
143

144
/************************************************************************/
145
/*                              Identify()                              */
146
/************************************************************************/
147

148
int BYNDataset::Identify(GDALOpenInfo *poOpenInfo)
56,935✔
149

150
{
151
    if (poOpenInfo->nHeaderBytes < BYN_HDR_SZ)
56,935✔
152
        return FALSE;
53,563✔
153

154
/* -------------------------------------------------------------------- */
155
/*      Check file extension (.byn/.err)                                */
156
/* -------------------------------------------------------------------- */
157
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
158
    const char *pszFileExtension = poOpenInfo->osExtension.c_str();
3,372✔
159

160
    if (!EQUAL(pszFileExtension, "byn") && !EQUAL(pszFileExtension, "err"))
3,372✔
161
    {
162
        return FALSE;
3,364✔
163
    }
164
#endif
165

166
    /* -------------------------------------------------------------------- */
167
    /*      Check some value's ranges on header                             */
168
    /* -------------------------------------------------------------------- */
169

170
    BYNHeader hHeader = {0, 0, 0, 0, 0, 0,   0,   0, 0.0, 0,   0, 0,
8✔
171
                         0, 0, 0, 0, 0, 0.0, 0.0, 0, 0,   0.0, 0};
172

173
    buffer2header(poOpenInfo->pabyHeader, &hHeader);
8✔
174

175
    if (hHeader.nGlobal < 0 || hHeader.nGlobal > 1 || hHeader.nType < 0 ||
8✔
176
        hHeader.nType > 9 || (hHeader.nSizeOf != 2 && hHeader.nSizeOf != 4) ||
8✔
177
        hHeader.nVDatum < 0 || hHeader.nVDatum > 3 || hHeader.nDescrip < 0 ||
8✔
178
        hHeader.nDescrip > 3 || hHeader.nSubType < 0 || hHeader.nSubType > 9 ||
8✔
179
        hHeader.nDatum < 0 || hHeader.nDatum > 1 || hHeader.nEllipsoid < 0 ||
8✔
180
        hHeader.nEllipsoid > 7 || hHeader.nByteOrder < 0 ||
8✔
181
        hHeader.nByteOrder > 1 || hHeader.nScale < 0 || hHeader.nScale > 1)
8✔
182
        return FALSE;
×
183

184
#if 0
185
    // We have disabled those checks as invalid values are often found in some
186
    // datasets, such as http://s3.microsurvey.com/os/fieldgenius/geoids/Lithuania.zip
187
    // We don't use those fields, so we may just ignore them.
188
    if((hHeader.nTideSys   < 0 || hHeader.nTideSys   > 2 ||
189
        hHeader.nPtType    < 0 || hHeader.nPtType    > 1 ))
190
    {
191
        // Some datasets use 0xCC as a marker for invalidity for
192
        // records starting from Geopotential Wo
193
        for( int i = 52; i < 78; i++ )
194
        {
195
            if( poOpenInfo->pabyHeader[i] != 0xCC )
196
                return FALSE;
197
        }
198
    }
199
#endif
200

201
    if (hHeader.nScale == 0)
8✔
202
    {
203
        if ((std::abs(static_cast<GIntBig>(hHeader.nSouth) -
16✔
204
                      (hHeader.nDLat / 2)) > BYN_MAX_LAT) ||
16✔
205
            (std::abs(static_cast<GIntBig>(hHeader.nNorth) +
8✔
206
                      (hHeader.nDLat / 2)) > BYN_MAX_LAT) ||
16✔
207
            (std::abs(static_cast<GIntBig>(hHeader.nWest) -
8✔
208
                      (hHeader.nDLon / 2)) > BYN_MAX_LON) ||
24✔
209
            (std::abs(static_cast<GIntBig>(hHeader.nEast) +
8✔
210
                      (hHeader.nDLon / 2)) > BYN_MAX_LON))
8✔
211
            return FALSE;
×
212
    }
213
    else
214
    {
215
        if ((std::abs(static_cast<GIntBig>(hHeader.nSouth) -
×
216
                      (hHeader.nDLat / 2)) > BYN_MAX_LAT_SCL) ||
×
217
            (std::abs(static_cast<GIntBig>(hHeader.nNorth) +
×
218
                      (hHeader.nDLat / 2)) > BYN_MAX_LAT_SCL) ||
×
219
            (std::abs(static_cast<GIntBig>(hHeader.nWest) -
×
220
                      (hHeader.nDLon / 2)) > BYN_MAX_LON_SCL) ||
×
221
            (std::abs(static_cast<GIntBig>(hHeader.nEast) +
×
222
                      (hHeader.nDLon / 2)) > BYN_MAX_LON_SCL))
×
223
            return FALSE;
×
224
    }
225

226
    return TRUE;
8✔
227
}
228

229
/************************************************************************/
230
/*                                Open()                                */
231
/************************************************************************/
232

233
GDALDataset *BYNDataset::Open(GDALOpenInfo *poOpenInfo)
4✔
234

235
{
236
    if (!Identify(poOpenInfo) || poOpenInfo->fpL == nullptr ||
8✔
237
        poOpenInfo->eAccess == GA_Update)
4✔
238
        return nullptr;
×
239

240
    /* -------------------------------------------------------------------- */
241
    /*      Create a corresponding GDALDataset.                             */
242
    /* -------------------------------------------------------------------- */
243

244
    auto poDS = std::make_unique<BYNDataset>();
8✔
245

246
    poDS->eAccess = poOpenInfo->eAccess;
4✔
247
    std::swap(poDS->fpImage, poOpenInfo->fpL);
4✔
248

249
    /* -------------------------------------------------------------------- */
250
    /*      Read the header.                                                */
251
    /* -------------------------------------------------------------------- */
252

253
    buffer2header(poOpenInfo->pabyHeader, &poDS->hHeader);
4✔
254

255
    /********************************/
256
    /* Scale boundaries and spacing */
257
    /********************************/
258

259
    double dfSouth = poDS->hHeader.nSouth;
4✔
260
    double dfNorth = poDS->hHeader.nNorth;
4✔
261
    double dfWest = poDS->hHeader.nWest;
4✔
262
    double dfEast = poDS->hHeader.nEast;
4✔
263
    double dfDLat = poDS->hHeader.nDLat;
4✔
264
    double dfDLon = poDS->hHeader.nDLon;
4✔
265

266
    if (poDS->hHeader.nScale == 1)
4✔
267
    {
268
        dfSouth *= BYN_SCALE;
×
269
        dfNorth *= BYN_SCALE;
×
270
        dfWest *= BYN_SCALE;
×
271
        dfEast *= BYN_SCALE;
×
272
        dfDLat *= BYN_SCALE;
×
273
        dfDLon *= BYN_SCALE;
×
274
    }
275

276
    /******************************/
277
    /* Calculate rows and columns */
278
    /******************************/
279

280
    double dfXSize = -1;
4✔
281
    double dfYSize = -1;
4✔
282

283
    poDS->nRasterXSize = -1;
4✔
284
    poDS->nRasterYSize = -1;
4✔
285

286
    if (dfDLat != 0.0 && dfDLon != 0.0)
4✔
287
    {
288
        dfXSize = ((dfEast - dfWest + 1.0) / dfDLon) + 1.0;
4✔
289
        dfYSize = ((dfNorth - dfSouth + 1.0) / dfDLat) + 1.0;
4✔
290
    }
291

292
    if (dfXSize > 0.0 && dfXSize < std::numeric_limits<double>::max() &&
4✔
293
        dfYSize > 0.0 && dfYSize < std::numeric_limits<double>::max())
8✔
294
    {
295
        poDS->nRasterXSize = static_cast<GInt32>(dfXSize);
4✔
296
        poDS->nRasterYSize = static_cast<GInt32>(dfYSize);
4✔
297
    }
298

299
    if (!GDALCheckDatasetDimensions(poDS->nRasterXSize, poDS->nRasterYSize))
4✔
300
    {
301
        return nullptr;
×
302
    }
303

304
    /*****************************/
305
    /* Build GeoTransform matrix */
306
    /*****************************/
307

308
    poDS->m_gt[0] = (dfWest - (dfDLon / 2.0)) / 3600.0;
4✔
309
    poDS->m_gt[1] = dfDLon / 3600.0;
4✔
310
    poDS->m_gt[2] = 0.0;
4✔
311
    poDS->m_gt[3] = (dfNorth + (dfDLat / 2.0)) / 3600.0;
4✔
312
    poDS->m_gt[4] = 0.0;
4✔
313
    poDS->m_gt[5] = -1 * dfDLat / 3600.0;
4✔
314

315
    /*********************/
316
    /* Set data type     */
317
    /*********************/
318

319
    GDALDataType eDT = GDT_Unknown;
4✔
320

321
    if (poDS->hHeader.nSizeOf == 2)
4✔
322
        eDT = GDT_Int16;
×
323
    else if (poDS->hHeader.nSizeOf == 4)
4✔
324
        eDT = GDT_Int32;
4✔
325
    else
326
    {
327
        return nullptr;
×
328
    }
329

330
    /* -------------------------------------------------------------------- */
331
    /*      Create band information object.                                 */
332
    /* -------------------------------------------------------------------- */
333

334
    const int nDTSize = GDALGetDataTypeSizeBytes(eDT);
4✔
335

336
    int bIsLSB = poDS->hHeader.nByteOrder == 1 ? 1 : 0;
4✔
337

338
    auto poBand = std::make_unique<BYNRasterBand>(
339
        poDS.get(), 1, poDS->fpImage, BYN_HDR_SZ, nDTSize,
4✔
340
        poDS->nRasterXSize * nDTSize, eDT, CPL_IS_LSB == bIsLSB);
12✔
341
    if (!poBand->IsValid())
4✔
342
        return nullptr;
×
343
    poDS->SetBand(1, std::move(poBand));
4✔
344

345
    /* -------------------------------------------------------------------- */
346
    /*      Initialize any PAM information.                                 */
347
    /* -------------------------------------------------------------------- */
348

349
    poDS->SetDescription(poOpenInfo->pszFilename);
4✔
350
    poDS->TryLoadXML();
4✔
351

352
    /* -------------------------------------------------------------------- */
353
    /*      Check for overviews.                                            */
354
    /* -------------------------------------------------------------------- */
355

356
    poDS->oOvManager.Initialize(poDS.get(), poOpenInfo->pszFilename);
4✔
357

358
    return poDS.release();
4✔
359
}
360

361
/************************************************************************/
362
/*                          GetGeoTransform()                           */
363
/************************************************************************/
364

365
CPLErr BYNDataset::GetGeoTransform(GDALGeoTransform &gt) const
×
366
{
367
    gt = m_gt;
×
368
    return CE_None;
×
369
}
370

371
/************************************************************************/
372
/*                          GetSpatialRef()                             */
373
/************************************************************************/
374

375
const OGRSpatialReference *BYNDataset::GetSpatialRef() const
×
376

377
{
378
    if (!m_oSRS.IsEmpty())
×
379
        return &m_oSRS;
×
380

381
    /* Try to use a prefefined EPSG compound CS */
382

383
    if (hHeader.nDatum == 1 && hHeader.nVDatum == 2)
×
384
    {
385
        m_oSRS.importFromEPSG(BYN_DATUM_1_VDATUM_2);
×
386
        return &m_oSRS;
×
387
    }
388

389
    /* Build the GEOGCS based on Datum ( or Ellipsoid )*/
390

391
    bool bNoGeogCS = false;
×
392

393
    if (hHeader.nDatum == 0)
×
394
        m_oSRS.importFromEPSG(BYN_DATUM_0);
×
395
    else if (hHeader.nDatum == 1)
×
396
        m_oSRS.importFromEPSG(BYN_DATUM_1);
×
397
    else
398
    {
399
        /* Build GEOGCS based on Ellipsoid (Table 3) */
400

401
        if (hHeader.nEllipsoid > -1 &&
×
402
            hHeader.nEllipsoid <
×
403
                static_cast<GInt16>(CPL_ARRAYSIZE(EllipsoidTable)))
404
            m_oSRS.SetGeogCS(
×
405
                CPLSPrintf("BYN Ellipsoid(%d)", hHeader.nEllipsoid),
×
406
                "Unspecified", EllipsoidTable[hHeader.nEllipsoid].pszName,
×
407
                EllipsoidTable[hHeader.nEllipsoid].dfSemiMajor,
×
408
                EllipsoidTable[hHeader.nEllipsoid].dfInvFlattening);
×
409
        else
410
            bNoGeogCS = true;
×
411
    }
412

413
    /* Build the VERT_CS based on VDatum */
414

415
    OGRSpatialReference oSRSComp;
×
416
    OGRSpatialReference oSRSVert;
×
417

418
    int nVertCS = 0;
×
419

420
    if (hHeader.nVDatum == 1)
×
421
        nVertCS = BYN_VDATUM_1;
×
422
    else if (hHeader.nVDatum == 2)
×
423
        nVertCS = BYN_VDATUM_2;
×
424
    else if (hHeader.nVDatum == 3)
×
425
        nVertCS = BYN_VDATUM_3;
×
426
    else
427
    {
428
        /* Return GEOGCS ( .err files ) */
429

430
        if (bNoGeogCS)
×
431
            return nullptr;
×
432

433
        return &m_oSRS;
×
434
    }
435

436
    oSRSVert.importFromEPSG(nVertCS);
×
437

438
    /* Create CPMPD_CS with GEOGCS and VERT_CS */
439

440
    if (oSRSComp.SetCompoundCS(CPLSPrintf("BYN Datum(%d) & VDatum(%d)",
×
441
                                          hHeader.nDatum, hHeader.nDatum),
×
442
                               &m_oSRS, &oSRSVert) == CE_None)
×
443
    {
444
        /* Return COMPD_CS with GEOGCS and VERT_CS */
445

446
        m_oSRS = std::move(oSRSComp);
×
447
        m_oSRS.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
×
448
        return &m_oSRS;
×
449
    }
450

451
    return nullptr;
×
452
}
453

454
/*----------------------------------------------------------------------*/
455
/*                           buffer2header()                            */
456
/*----------------------------------------------------------------------*/
457

458
void BYNDataset::buffer2header(const GByte *pabyBuf, BYNHeader *pohHeader)
12✔
459

460
{
461
    memcpy(&pohHeader->nSouth, pabyBuf, 4);
12✔
462
    memcpy(&pohHeader->nNorth, pabyBuf + 4, 4);
12✔
463
    memcpy(&pohHeader->nWest, pabyBuf + 8, 4);
12✔
464
    memcpy(&pohHeader->nEast, pabyBuf + 12, 4);
12✔
465
    memcpy(&pohHeader->nDLat, pabyBuf + 16, 2);
12✔
466
    memcpy(&pohHeader->nDLon, pabyBuf + 18, 2);
12✔
467
    memcpy(&pohHeader->nGlobal, pabyBuf + 20, 2);
12✔
468
    memcpy(&pohHeader->nType, pabyBuf + 22, 2);
12✔
469
    memcpy(&pohHeader->dfFactor, pabyBuf + 24, 8);
12✔
470
    memcpy(&pohHeader->nSizeOf, pabyBuf + 32, 2);
12✔
471
    memcpy(&pohHeader->nVDatum, pabyBuf + 34, 2);
12✔
472
    memcpy(&pohHeader->nDescrip, pabyBuf + 40, 2);
12✔
473
    memcpy(&pohHeader->nSubType, pabyBuf + 42, 2);
12✔
474
    memcpy(&pohHeader->nDatum, pabyBuf + 44, 2);
12✔
475
    memcpy(&pohHeader->nEllipsoid, pabyBuf + 46, 2);
12✔
476
    memcpy(&pohHeader->nByteOrder, pabyBuf + 48, 2);
12✔
477
    memcpy(&pohHeader->nScale, pabyBuf + 50, 2);
12✔
478
    memcpy(&pohHeader->dfWo, pabyBuf + 52, 8);
12✔
479
    memcpy(&pohHeader->dfGM, pabyBuf + 60, 8);
12✔
480
    memcpy(&pohHeader->nTideSys, pabyBuf + 68, 2);
12✔
481
    memcpy(&pohHeader->nRealiz, pabyBuf + 70, 2);
12✔
482
    memcpy(&pohHeader->dEpoch, pabyBuf + 72, 4);
12✔
483
    memcpy(&pohHeader->nPtType, pabyBuf + 76, 2);
12✔
484

485
#if defined(CPL_MSB)
486
    CPL_LSBPTR32(&pohHeader->nSouth);
487
    CPL_LSBPTR32(&pohHeader->nNorth);
488
    CPL_LSBPTR32(&pohHeader->nWest);
489
    CPL_LSBPTR32(&pohHeader->nEast);
490
    CPL_LSBPTR16(&pohHeader->nDLat);
491
    CPL_LSBPTR16(&pohHeader->nDLon);
492
    CPL_LSBPTR16(&pohHeader->nGlobal);
493
    CPL_LSBPTR16(&pohHeader->nType);
494
    CPL_LSBPTR64(&pohHeader->dfFactor);
495
    CPL_LSBPTR16(&pohHeader->nSizeOf);
496
    CPL_LSBPTR16(&pohHeader->nVDatum);
497
    CPL_LSBPTR16(&pohHeader->nDescrip);
498
    CPL_LSBPTR16(&pohHeader->nSubType);
499
    CPL_LSBPTR16(&pohHeader->nDatum);
500
    CPL_LSBPTR16(&pohHeader->nEllipsoid);
501
    CPL_LSBPTR16(&pohHeader->nByteOrder);
502
    CPL_LSBPTR16(&pohHeader->nScale);
503
    CPL_LSBPTR64(&pohHeader->dfWo);
504
    CPL_LSBPTR64(&pohHeader->dfGM);
505
    CPL_LSBPTR16(&pohHeader->nTideSys);
506
    CPL_LSBPTR16(&pohHeader->nRealiz);
507
    CPL_LSBPTR32(&pohHeader->dEpoch);
508
    CPL_LSBPTR16(&pohHeader->nPtType);
509
#endif
510

511
#if DEBUG
512
    CPLDebug("BYN", "South         = %d", pohHeader->nSouth);
12✔
513
    CPLDebug("BYN", "North         = %d", pohHeader->nNorth);
12✔
514
    CPLDebug("BYN", "West          = %d", pohHeader->nWest);
12✔
515
    CPLDebug("BYN", "East          = %d", pohHeader->nEast);
12✔
516
    CPLDebug("BYN", "DLat          = %d", pohHeader->nDLat);
12✔
517
    CPLDebug("BYN", "DLon          = %d", pohHeader->nDLon);
12✔
518
    CPLDebug("BYN", "DGlobal       = %d", pohHeader->nGlobal);
12✔
519
    CPLDebug("BYN", "DType         = %d", pohHeader->nType);
12✔
520
    CPLDebug("BYN", "Factor        = %f", pohHeader->dfFactor);
12✔
521
    CPLDebug("BYN", "SizeOf        = %d", pohHeader->nSizeOf);
12✔
522
    CPLDebug("BYN", "VDatum        = %d", pohHeader->nVDatum);
12✔
523
    CPLDebug("BYN", "Data          = %d", pohHeader->nDescrip);
12✔
524
    CPLDebug("BYN", "SubType       = %d", pohHeader->nSubType);
12✔
525
    CPLDebug("BYN", "Datum         = %d", pohHeader->nDatum);
12✔
526
    CPLDebug("BYN", "Ellipsoid     = %d", pohHeader->nEllipsoid);
12✔
527
    CPLDebug("BYN", "ByteOrder     = %d", pohHeader->nByteOrder);
12✔
528
    CPLDebug("BYN", "Scale         = %d", pohHeader->nScale);
12✔
529
    CPLDebug("BYN", "Wo            = %f", pohHeader->dfWo);
12✔
530
    CPLDebug("BYN", "GM            = %f", pohHeader->dfGM);
12✔
531
    CPLDebug("BYN", "TideSystem    = %d", pohHeader->nTideSys);
12✔
532
    CPLDebug("BYN", "RefRealzation = %d", pohHeader->nRealiz);
12✔
533
    CPLDebug("BYN", "Epoch         = %f", pohHeader->dEpoch);
12✔
534
    CPLDebug("BYN", "PtType        = %d", pohHeader->nPtType);
12✔
535
#endif
536
}
12✔
537

538
/************************************************************************/
539
/*                          GDALRegister_BYN()                          */
540
/************************************************************************/
541

542
void GDALRegister_BYN()
1,911✔
543

544
{
545
    if (GDALGetDriverByName("BYN") != nullptr)
1,911✔
546
        return;
282✔
547

548
    GDALDriver *poDriver = new GDALDriver();
1,629✔
549

550
    poDriver->SetDescription("BYN");
1,629✔
551
    poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
1,629✔
552
    poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
1,629✔
553
                              "Natural Resources Canada's Geoid");
1,629✔
554
    poDriver->SetMetadataItem(GDAL_DMD_EXTENSIONS, "byn err");
1,629✔
555
    poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
1,629✔
556
    poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/byn.html");
1,629✔
557

558
    poDriver->pfnOpen = BYNDataset::Open;
1,629✔
559
    poDriver->pfnIdentify = BYNDataset::Identify;
1,629✔
560

561
    GetGDALDriverManager()->RegisterDriver(poDriver);
1,629✔
562
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc