LCOV - code coverage report
Current view: top level - apps - gdal_grid_bin.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 25 34 73.5 %
Date: 2024-11-21 22:18:42 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL Utilities
       4             :  * Purpose:  GDAL scattered data gridding (interpolation) tool
       5             :  * Authors:  Even Rouault, <even dot rouault at spatialys dot com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2015, Even Rouault <even dot rouault at spatialys dot com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "cpl_string.h"
      14             : #include "gdal_version.h"
      15             : #include "commonutils.h"
      16             : #include "gdal_utils_priv.h"
      17             : 
      18             : /************************************************************************/
      19             : /*                               Usage()                                */
      20             : /************************************************************************/
      21             : 
      22           0 : static void Usage()
      23             : 
      24             : {
      25           0 :     fprintf(stderr, "%s\n", GDALGridGetParserUsage().c_str());
      26           0 :     exit(1);
      27             : }
      28             : 
      29             : /************************************************************************/
      30             : /*                                main()                                */
      31             : /************************************************************************/
      32             : 
      33          55 : MAIN_START(argc, argv)
      34             : {
      35             :     /* Check strict compilation and runtime library version as we use C++ API */
      36          55 :     if (!GDAL_CHECK_VERSION(argv[0]))
      37           0 :         exit(1);
      38             : 
      39          55 :     EarlySetConfigOptions(argc, argv);
      40             : 
      41             :     /* -------------------------------------------------------------------- */
      42             :     /*      Generic arg processing.                                         */
      43             :     /* -------------------------------------------------------------------- */
      44          55 :     GDALAllRegister();
      45          55 :     argc = GDALGeneralCmdLineProcessor(argc, &argv, 0);
      46          55 :     if (argc < 1)
      47           0 :         exit(-argc);
      48             : 
      49          55 :     GDALGridOptionsForBinary sOptionsForBinary;
      50             :     /* coverity[tainted_data] */
      51             :     GDALGridOptions *psOptions =
      52          55 :         GDALGridOptionsNew(argv + 1, &sOptionsForBinary);
      53          54 :     CSLDestroy(argv);
      54             : 
      55          54 :     if (psOptions == nullptr)
      56             :     {
      57           0 :         Usage();
      58             :     }
      59             : 
      60          54 :     if (!(sOptionsForBinary.bQuiet))
      61             :     {
      62          54 :         GDALGridOptionsSetProgress(psOptions, GDALTermProgress, nullptr);
      63             :     }
      64             : 
      65             :     /* -------------------------------------------------------------------- */
      66             :     /*      Open input file.                                                */
      67             :     /* -------------------------------------------------------------------- */
      68          54 :     GDALDatasetH hInDS = GDALOpenEx(sOptionsForBinary.osSource.c_str(),
      69             :                                     GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR,
      70             :                                     /*papszAllowedDrivers=*/nullptr,
      71          54 :                                     sOptionsForBinary.aosOpenOptions.List(),
      72             :                                     /*papszSiblingFiles=*/nullptr);
      73          54 :     if (hInDS == nullptr)
      74           0 :         exit(1);
      75             : 
      76          54 :     int bUsageError = FALSE;
      77          54 :     GDALDatasetH hOutDS = GDALGrid(sOptionsForBinary.osDest.c_str(), hInDS,
      78             :                                    psOptions, &bUsageError);
      79          54 :     if (bUsageError == TRUE)
      80           0 :         Usage();
      81          54 :     int nRetCode = hOutDS ? 0 : 1;
      82             : 
      83          54 :     GDALClose(hInDS);
      84          54 :     GDALClose(hOutDS);
      85          54 :     GDALGridOptionsFree(psOptions);
      86             : 
      87          54 :     OGRCleanupAll();
      88          54 :     GDALDestroyDriverManager();
      89             : 
      90          54 :     return nRetCode;
      91             : }
      92             : 
      93           0 : MAIN_END

Generated by: LCOV version 1.14