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

OSGeo / gdal / 13700616263

06 Mar 2025 02:10PM UTC coverage: 70.331% (-0.02%) from 70.35%
13700616263

Pull #11923

github

web-flow
Merge 6a40f0624 into 6d20ab96f
Pull Request #11923: [cli][gdal_contour] Port gdal_contour to cli

355 of 433 new or added lines in 7 files covered. (81.99%)

20395 existing lines in 43 files now uncovered.

553123 of 786461 relevant lines covered (70.33%)

221121.31 hits per line

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

91.43
/apps/gdal_contour.cpp
1
/******************************************************************************
2
 *
3
 * Project:  Contour Generator
4
 * Purpose:  Contour Generator mainline.
5
 * Author:   Frank Warmerdam <warmerdam@pobox.com>
6
 *
7
 ******************************************************************************
8
 * Copyright (c) 2003, Applied Coherent Technology (www.actgate.com).
9
 * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
10
 * Copyright (c) 2018, Oslandia <infos at oslandia dot com>
11
 *
12
 * SPDX-License-Identifier: MIT
13
 ****************************************************************************/
14

15
#include "cpl_conv.h"
16
#include "cpl_string.h"
17
#include "gdal_version.h"
18
#include "gdal.h"
19
#include "gdal_alg.h"
20
#include "gdalargumentparser.h"
21
#include "ogr_api.h"
22
#include "ogr_srs_api.h"
23
#include "commonutils.h"
24
#include "gdal_utils.h"
25
#include "gdal_utils_priv.h"
26

27
/************************************************************************/
28
/*                               Usage()                                */
29
/************************************************************************/
30

31
static void Usage()
1✔
32

33
{
34
    fprintf(stderr, "%s\n", GDALContourGetParserUsage().c_str());
1✔
35
    exit(1);
1✔
36
}
37

38
/************************************************************************/
39
/*                                main()                                */
40
/************************************************************************/
41

42
MAIN_START(argc, argv)
21✔
43
{
44

45
    /* Check strict compilation and runtime library version as we use C++ API */
46
    if (!GDAL_CHECK_VERSION(argv[0]))
21✔
NEW
47
        exit(1);
×
48

49
    EarlySetConfigOptions(argc, argv);
21✔
50

51
    /* -------------------------------------------------------------------- */
52
    /*      Register standard GDAL drivers, and process generic GDAL        */
53
    /*      command options.                                                */
54
    /* -------------------------------------------------------------------- */
55
    GDALAllRegister();
21✔
56
    argc = GDALGeneralCmdLineProcessor(argc, &argv, 0);
21✔
57
    if (argc < 1)
21✔
58
        exit(-argc);
1✔
59

60
    /* -------------------------------------------------------------------- */
61
    /*      Generic arg processing.                                         */
62
    /* -------------------------------------------------------------------- */
63

64
    GDALContourOptionsForBinary sOptionsForBinary;
39✔
65
    std::unique_ptr<GDALContourOptions, decltype(&GDALContourOptionsFree)>
66
        psOptions{GDALContourOptionsNew(argv + 1, &sOptionsForBinary),
67
                  GDALContourOptionsFree};
20✔
68

69
    CSLDestroy(argv);
20✔
70

71
    if (!psOptions)
20✔
72
    {
73
        Usage();
1✔
74
    }
75

76
    GDALProgressFunc pfnProgress = nullptr;
19✔
77

78
    if (!sOptionsForBinary.bQuiet)
19✔
79
        pfnProgress = GDALTermProgress;
19✔
80

81
    char **papszStringOptions = nullptr;
19✔
82

83
    GDALDatasetH hSrcDS{nullptr};
19✔
84
    GDALRasterBandH hBand{nullptr};
19✔
85
    GDALDatasetH hDstDS{nullptr};
19✔
86
    OGRLayerH hLayer{nullptr};
19✔
87
    CPLErr eErr =
88
        GDALContourProcessOptions(psOptions.get(), &papszStringOptions, &hSrcDS,
19✔
89
                                  &hBand, &hDstDS, &hLayer);
90

91
    if (eErr == CE_None)
19✔
92
    {
93
        eErr = GDALContourGenerateEx(hBand, hLayer, papszStringOptions,
19✔
94
                                     pfnProgress, nullptr);
95
    }
96

97
    if (GDALClose(hSrcDS) != CE_None)
19✔
UNCOV
98
        eErr = CE_Failure;
×
99

100
    GDALClose(hDstDS);
19✔
101

102
    CSLDestroy(papszStringOptions);
19✔
103
    GDALDestroyDriverManager();
19✔
104
    OGRCleanupAll();
19✔
105

106
    return (eErr == CE_None) ? 0 : 1;
19✔
107
}
108

109
MAIN_END
×
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