LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/pds - ogrpdsdriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 21 23 91.3 %
Date: 2024-11-21 22:18:42 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  PDS Translator
       4             :  * Purpose:  Implements OGRPDSDriver.
       5             :  * Author:   Even Rouault, even dot rouault at spatialys.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2010, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "cpl_conv.h"
      14             : #include "ogr_pds.h"
      15             : 
      16             : extern "C" void RegisterOGRPDS();
      17             : 
      18             : using namespace OGRPDS;
      19             : 
      20             : /************************************************************************/
      21             : /*                                Open()                                */
      22             : /************************************************************************/
      23             : 
      24       24695 : static GDALDataset *OGRPDSDriverOpen(GDALOpenInfo *poOpenInfo)
      25             : 
      26             : {
      27       24695 :     if (poOpenInfo->eAccess == GA_Update || poOpenInfo->fpL == nullptr)
      28       22320 :         return nullptr;
      29             : 
      30        2375 :     if (strstr((const char *)poOpenInfo->pabyHeader, "PDS_VERSION_ID") ==
      31             :         nullptr)
      32        2373 :         return nullptr;
      33             : 
      34           2 :     OGRPDSDataSource *poDS = new OGRPDSDataSource();
      35             : 
      36           2 :     if (!poDS->Open(poOpenInfo->pszFilename))
      37             :     {
      38           0 :         delete poDS;
      39           0 :         poDS = nullptr;
      40             :     }
      41             : 
      42           2 :     return poDS;
      43             : }
      44             : 
      45             : /************************************************************************/
      46             : /*                           RegisterOGRPDS()                           */
      47             : /************************************************************************/
      48             : 
      49        1595 : void RegisterOGRPDS()
      50             : 
      51             : {
      52        1595 :     if (GDALGetDriverByName("OGR_PDS") != nullptr)
      53         302 :         return;
      54             : 
      55        1293 :     GDALDriver *poDriver = new GDALDriver();
      56             : 
      57        1293 :     poDriver->SetDescription("OGR_PDS");
      58        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
      59        1293 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
      60        1293 :                               "Planetary Data Systems TABLE");
      61        1293 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/pds.html");
      62        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
      63        1293 :     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE");
      64             : 
      65        1293 :     poDriver->pfnOpen = OGRPDSDriverOpen;
      66             : 
      67        1293 :     GetGDALDriverManager()->RegisterDriver(poDriver);
      68             : }

Generated by: LCOV version 1.14