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

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  MapServer
       4             :  * Purpose:  Commandline App to build tile index for raster files.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2001, Frank Warmerdam, DM Solutions Group Inc
       9             :  * Copyright (c) 2007-2013, Even Rouault <even dot rouault at spatialys.com>
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #include "cpl_string.h"
      15             : #include "cpl_error.h"
      16             : #include "commonutils.h"
      17             : #include "gdal_version.h"
      18             : #include "gdal_utils_priv.h"
      19             : #include "gdal_priv.h"
      20             : 
      21             : /************************************************************************/
      22             : /*                               Usage()                                */
      23             : /************************************************************************/
      24             : 
      25           0 : static void Usage()
      26             : 
      27             : {
      28           0 :     fprintf(stderr, "%s\n", GDALTileIndexAppGetParserUsage().c_str());
      29           0 :     exit(1);
      30             : }
      31             : 
      32             : /************************************************************************/
      33             : /*                                main()                                */
      34             : /************************************************************************/
      35             : 
      36           7 : MAIN_START(argc, argv)
      37             : {
      38             : 
      39           7 :     EarlySetConfigOptions(argc, argv);
      40             : 
      41             :     /* -------------------------------------------------------------------- */
      42             :     /*      Register standard GDAL drivers, and process generic GDAL        */
      43             :     /*      command options.                                                */
      44             :     /* -------------------------------------------------------------------- */
      45           7 :     GDALAllRegister();
      46           7 :     argc = GDALGeneralCmdLineProcessor(argc, &argv, 0);
      47           7 :     if (argc < 1)
      48           0 :         exit(-argc);
      49             : 
      50          13 :     GDALTileIndexOptionsForBinary sOptionsForBinary;
      51             :     std::unique_ptr<GDALTileIndexOptions, decltype(&GDALTileIndexOptionsFree)>
      52             :         psOptions{GDALTileIndexOptionsNew(argv + 1, &sOptionsForBinary),
      53           7 :                   GDALTileIndexOptionsFree};
      54           6 :     CSLDestroy(argv);
      55             : 
      56           6 :     if (!psOptions)
      57             :     {
      58           0 :         Usage();
      59             :     }
      60             : 
      61           6 :     int bUsageError = FALSE;
      62           6 :     GDALDatasetH hOutDS = GDALTileIndex(
      63             :         sOptionsForBinary.osDest.c_str(), sOptionsForBinary.aosSrcFiles.size(),
      64           6 :         sOptionsForBinary.aosSrcFiles.List(), psOptions.get(), &bUsageError);
      65             : 
      66           6 :     int nRetCode = (hOutDS) ? 0 : 1;
      67             : 
      68           6 :     CPLErrorReset();
      69             :     // The flush to disk is only done at that stage, so check if any error has
      70             :     // happened
      71           6 :     if (GDALClose(hOutDS) != CE_None)
      72           0 :         nRetCode = 1;
      73           6 :     if (CPLGetLastErrorType() != CE_None)
      74           0 :         nRetCode = 1;
      75             : 
      76           6 :     GDALDumpOpenDatasets(stderr);
      77             : 
      78           6 :     GDALDestroyDriverManager();
      79             : 
      80           6 :     OGRCleanupAll();
      81             : 
      82           6 :     return nRetCode;
      83             : }
      84             : 
      85           0 : MAIN_END

Generated by: LCOV version 1.14