LCOV - code coverage report
Current view: top level - apps - gdalalg_vector.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 23 23 100.0 %
Date: 2025-05-15 13:16:46 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "vector" subcommand
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "gdalalgorithm.h"
      14             : 
      15             : #include "gdalalg_vector_info.h"
      16             : #include "gdalalg_vector_clip.h"
      17             : #include "gdalalg_vector_concat.h"
      18             : #include "gdalalg_vector_convert.h"
      19             : #include "gdalalg_vector_edit.h"
      20             : #include "gdalalg_vector_geom.h"
      21             : #include "gdalalg_vector_grid.h"
      22             : #include "gdalalg_vector_pipeline.h"
      23             : #include "gdalalg_vector_rasterize.h"
      24             : #include "gdalalg_vector_filter.h"
      25             : #include "gdalalg_vector_reproject.h"
      26             : #include "gdalalg_vector_select.h"
      27             : #include "gdalalg_vector_sql.h"
      28             : 
      29             : #include "gdal_priv.h"
      30             : 
      31             : #ifndef _
      32             : #define _(x) (x)
      33             : #endif
      34             : 
      35             : /************************************************************************/
      36             : /*                         GDALVectorAlgorithm                          */
      37             : /************************************************************************/
      38             : 
      39             : class GDALVectorAlgorithm final : public GDALAlgorithm
      40             : {
      41             :   public:
      42             :     static constexpr const char *NAME = "vector";
      43             :     static constexpr const char *DESCRIPTION = "Vector commands.";
      44             :     static constexpr const char *HELP_URL = "/programs/gdal_vector.html";
      45             : 
      46         409 :     GDALVectorAlgorithm() : GDALAlgorithm(NAME, DESCRIPTION, HELP_URL)
      47             :     {
      48             :         AddArg("drivers", 0,
      49             :                _("Display vector driver list as JSON document and exit"),
      50         409 :                &m_drivers);
      51             : 
      52         409 :         AddOutputStringArg(&m_output);
      53             : 
      54         409 :         RegisterSubAlgorithm<GDALVectorInfoAlgorithm>();
      55         409 :         RegisterSubAlgorithm<GDALVectorClipAlgorithmStandalone>();
      56         409 :         RegisterSubAlgorithm<GDALVectorConcatAlgorithmStandalone>();
      57         409 :         RegisterSubAlgorithm<GDALVectorConvertAlgorithm>();
      58         409 :         RegisterSubAlgorithm<GDALVectorEditAlgorithmStandalone>();
      59         409 :         RegisterSubAlgorithm<GDALVectorGridAlgorithm>();
      60         409 :         RegisterSubAlgorithm<GDALVectorRasterizeAlgorithm>();
      61         409 :         RegisterSubAlgorithm<GDALVectorPipelineAlgorithm>();
      62         409 :         RegisterSubAlgorithm<GDALVectorFilterAlgorithmStandalone>();
      63         409 :         RegisterSubAlgorithm<GDALVectorGeomAlgorithmStandalone>();
      64         409 :         RegisterSubAlgorithm<GDALVectorReprojectAlgorithmStandalone>();
      65         409 :         RegisterSubAlgorithm<GDALVectorSelectAlgorithmStandalone>();
      66         409 :         RegisterSubAlgorithm<GDALVectorSQLAlgorithmStandalone>();
      67         409 :     }
      68             : 
      69             :   private:
      70             :     std::string m_output{};
      71             :     bool m_drivers = false;
      72             : 
      73           2 :     bool RunImpl(GDALProgressFunc, void *) override
      74             :     {
      75           2 :         if (m_drivers)
      76             :         {
      77           1 :             m_output = GDALPrintDriverList(GDAL_OF_VECTOR, true);
      78           1 :             return true;
      79             :         }
      80             :         else
      81             :         {
      82           1 :             CPLError(
      83             :                 CE_Failure, CPLE_AppDefined,
      84             :                 "The Run() method should not be called directly on the \"gdal "
      85             :                 "vector\" program.");
      86           1 :             return false;
      87             :         }
      88             :     }
      89             : };
      90             : 
      91             : GDAL_STATIC_REGISTER_ALG(GDALVectorAlgorithm);

Generated by: LCOV version 1.14