LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/ogdi - ogrogdidriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 16 27 59.3 %
Date: 2024-11-25 13:07:18 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  OGDI Bridge
       4             :  * Purpose:  Implements OGROGDIDriver class.
       5             :  * Author:   Daniel Morissette, danmo@videotron.ca
       6             :  *           (Based on some code contributed by Frank Warmerdam :)
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2000, Daniel Morissette
      10             :  *
      11             :  * SPDX-License-Identifier: MIT
      12             :  ****************************************************************************/
      13             : 
      14             : #include "ogrogdi.h"
      15             : #include "ogrogdidrivercore.h"
      16             : 
      17             : #include "cpl_conv.h"
      18             : 
      19             : /************************************************************************/
      20             : /*                         MyOGDIReportErrorFunction()                  */
      21             : /************************************************************************/
      22             : 
      23             : #if OGDI_RELEASEDATE >= 20160705
      24           0 : static int MyOGDIReportErrorFunction(int errorcode, const char *error_message)
      25             : {
      26           0 :     CPLError(CE_Failure, CPLE_AppDefined, "OGDI error %d: %s", errorcode,
      27             :              error_message);
      28           0 :     return FALSE;  // go on
      29             : }
      30             : #endif
      31             : 
      32             : /************************************************************************/
      33             : /*                                Open()                                */
      34             : /************************************************************************/
      35             : 
      36           4 : static GDALDataset *OGROGDIDriverOpen(GDALOpenInfo *poOpenInfo)
      37             : 
      38             : {
      39           4 :     const char *pszFilename = poOpenInfo->pszFilename;
      40           4 :     if (!STARTS_WITH_CI(pszFilename, "gltp:"))
      41           0 :         return nullptr;
      42             : 
      43             : #if OGDI_RELEASEDATE >= 20160705
      44             :     // Available only in post OGDI 3.2.0beta2
      45             :     // and only called if env variable OGDI_STOP_ON_ERROR is set to NO
      46           4 :     ecs_SetReportErrorFunction(MyOGDIReportErrorFunction);
      47             : #endif
      48             : 
      49           4 :     OGROGDIDataSource *poDS = new OGROGDIDataSource();
      50             : 
      51           4 :     if (!poDS->Open(pszFilename))
      52             :     {
      53           0 :         delete poDS;
      54           0 :         poDS = nullptr;
      55             :     }
      56             : 
      57           4 :     const bool bUpdate = (poOpenInfo->nOpenFlags & GDAL_OF_UPDATE) != 0;
      58           4 :     if (poDS != nullptr && bUpdate)
      59             :     {
      60           0 :         CPLError(CE_Failure, CPLE_OpenFailed,
      61             :                  "OGDI Driver doesn't support update.");
      62           0 :         delete poDS;
      63           0 :         poDS = nullptr;
      64             :     }
      65             : 
      66           4 :     return poDS;
      67             : }
      68             : 
      69             : /************************************************************************/
      70             : /*                          RegisterOGROGDI()                           */
      71             : /************************************************************************/
      72             : 
      73          10 : void RegisterOGROGDI()
      74             : 
      75             : {
      76          10 :     if (!GDAL_CHECK_VERSION("OGR/OGDI driver"))
      77           0 :         return;
      78             : 
      79          10 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      80           0 :         return;
      81             : 
      82          10 :     GDALDriver *poDriver = new GDALDriver();
      83          10 :     OGROGDIDriverSetCommonMetadata(poDriver);
      84             : 
      85          10 :     poDriver->pfnOpen = OGROGDIDriverOpen;
      86             : 
      87          10 :     GetGDALDriverManager()->RegisterDriver(poDriver);
      88             : }

Generated by: LCOV version 1.14