LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/elastic - ogrelasticdriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 22 24 91.7 %
Date: 2024-11-21 22:18:42 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  Elasticsearch Translator
       4             :  * Purpose:
       5             :  * Author:
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2011, Adam Estrada
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "ogr_elastic.h"
      14             : #include "cpl_conv.h"
      15             : #include "ogrelasticdrivercore.h"
      16             : 
      17             : /************************************************************************/
      18             : /*                  OGRElasticsearchDriverOpen()                        */
      19             : /************************************************************************/
      20             : 
      21          30 : static GDALDataset *OGRElasticsearchDriverOpen(GDALOpenInfo *poOpenInfo)
      22             : 
      23             : {
      24          30 :     if (!OGRElasticsearchDriverIdentify(poOpenInfo))
      25           0 :         return nullptr;
      26             : 
      27          30 :     OGRElasticDataSource *poDS = new OGRElasticDataSource();
      28          30 :     if (!poDS->Open(poOpenInfo))
      29             :     {
      30           6 :         delete poDS;
      31           6 :         poDS = nullptr;
      32             :     }
      33             : 
      34          30 :     return poDS;
      35             : }
      36             : 
      37             : /************************************************************************/
      38             : /*                     OGRElasticsearchDriverCreate()                   */
      39             : /************************************************************************/
      40             : static GDALDataset *
      41          10 : OGRElasticsearchDriverCreate(const char *pszName, CPL_UNUSED int nXSize,
      42             :                              CPL_UNUSED int nYSize, CPL_UNUSED int nBands,
      43             :                              CPL_UNUSED GDALDataType eDT, char **papszOptions)
      44             : {
      45          10 :     OGRElasticDataSource *poDS = new OGRElasticDataSource();
      46             : 
      47          10 :     if (!poDS->Create(pszName, papszOptions))
      48             :     {
      49           2 :         delete poDS;
      50           2 :         poDS = nullptr;
      51             :     }
      52             : 
      53          10 :     return poDS;
      54             : }
      55             : 
      56             : /************************************************************************/
      57             : /*                          RegisterOGRElastic()                        */
      58             : /************************************************************************/
      59             : 
      60        1595 : void RegisterOGRElastic()
      61             : {
      62        1595 :     if (!GDAL_CHECK_VERSION("OGR/Elastic Search driver"))
      63           0 :         return;
      64             : 
      65        1595 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      66         302 :         return;
      67             : 
      68        1293 :     GDALDriver *poDriver = new GDALDriver();
      69        1293 :     OGRElasticsearchDriverSetCommonMetadata(poDriver);
      70        1293 :     poDriver->pfnOpen = OGRElasticsearchDriverOpen;
      71        1293 :     poDriver->pfnCreate = OGRElasticsearchDriverCreate;
      72             : 
      73        1293 :     GetGDALDriverManager()->RegisterDriver(poDriver);
      74             : }

Generated by: LCOV version 1.14