LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/pgeo - ogrpgeodriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 28 39 71.8 %
Date: 2024-05-04 12:52:34 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  OpenGIS Simple Features Reference Implementation
       4             :  * Purpose:  Implements Personal Geodatabase driver.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
       9             :  * Copyright (c) 2008-2013, Even Rouault <even dot rouault at spatialys.com>
      10             :  *
      11             :  * Permission is hereby granted, free of charge, to any person obtaining a
      12             :  * copy of this software and associated documentation files (the "Software"),
      13             :  * to deal in the Software without restriction, including without limitation
      14             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15             :  * and/or sell copies of the Software, and to permit persons to whom the
      16             :  * Software is furnished to do so, subject to the following conditions:
      17             :  *
      18             :  * The above copyright notice and this permission notice shall be included
      19             :  * in all copies or substantial portions of the Software.
      20             :  *
      21             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27             :  * DEALINGS IN THE SOFTWARE.
      28             :  ****************************************************************************/
      29             : 
      30             : #include "ogr_pgeo.h"
      31             : #include "cpl_conv.h"
      32             : 
      33             : /************************************************************************/
      34             : /*                     OGRPGeoDriverIdentify()                          */
      35             : /************************************************************************/
      36             : 
      37       43223 : static int OGRPGeoDriverIdentify(GDALOpenInfo *poOpenInfo)
      38             : 
      39             : {
      40       43223 :     if (STARTS_WITH_CI(poOpenInfo->pszFilename, "PGEO:"))
      41           0 :         return TRUE;
      42             : 
      43       43223 :     if (!EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "mdb"))
      44       43223 :         return FALSE;
      45             : 
      46             :     // Could potentially be a PGeo or generic ODBC database
      47           0 :     return -1;
      48             : }
      49             : 
      50             : /************************************************************************/
      51             : /*                                OGRPGeoDriverOpen()                   */
      52             : /************************************************************************/
      53             : 
      54           0 : static GDALDataset *OGRPGeoDriverOpen(GDALOpenInfo *poOpenInfo)
      55             : 
      56             : {
      57             :     // The method might return -1 when it is undecided
      58           0 :     if (OGRPGeoDriverIdentify(poOpenInfo) == FALSE)
      59           0 :         return nullptr;
      60             : 
      61             : #ifndef _WIN32
      62             :     // Try to register MDB Tools driver
      63           0 :     CPLODBCDriverInstaller::InstallMdbToolsDriver();
      64             : #endif /* ndef WIN32 */
      65             : 
      66             :     // Open data source
      67           0 :     OGRPGeoDataSource *poDS = new OGRPGeoDataSource();
      68             : 
      69           0 :     if (!poDS->Open(poOpenInfo))
      70             :     {
      71           0 :         delete poDS;
      72           0 :         return nullptr;
      73             :     }
      74             :     else
      75           0 :         return poDS;
      76             : }
      77             : 
      78             : /************************************************************************/
      79             : /*                           RegisterOGRPGeo()                          */
      80             : /************************************************************************/
      81             : 
      82        1520 : void RegisterOGRPGeo()
      83             : 
      84             : {
      85        1520 :     if (GDALGetDriverByName("PGeo") != nullptr)
      86         301 :         return;
      87             : 
      88        1219 :     GDALDriver *poDriver = new GDALDriver;
      89             : 
      90        1219 :     poDriver->SetDescription("PGeo");
      91        1219 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
      92        1219 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "ESRI Personal GeoDatabase");
      93        1219 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "mdb");
      94        1219 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/pgeo.html");
      95        1219 :     poDriver->SetMetadataItem(GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, "YES");
      96        1219 :     poDriver->SetMetadataItem(GDAL_DCAP_FIELD_DOMAINS, "YES");
      97        1219 :     poDriver->SetMetadataItem(GDAL_DCAP_RELATIONSHIPS, "YES");
      98        1219 :     poDriver->SetMetadataItem(GDAL_DCAP_CURVE_GEOMETRIES, "YES");
      99        1219 :     poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES");
     100        1219 :     poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES");
     101        1219 :     poDriver->SetMetadataItem(GDAL_DMD_GEOMETRY_FLAGS,
     102             :                               "EquatesMultiAndSingleLineStringDuringWrite "
     103        1219 :                               "EquatesMultiAndSinglePolygonDuringWrite");
     104        1219 :     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS,
     105        1219 :                               "NATIVE OGRSQL SQLITE");
     106             : 
     107        1219 :     poDriver->SetMetadataItem(
     108             :         GDAL_DMD_OPENOPTIONLIST,
     109             :         "<OpenOptionList>"
     110             :         "  <Option name='LIST_ALL_TABLES' type='string-select' scope='vector' "
     111             :         "description='Whether all tables, including system and internal tables "
     112             :         "(such as GDB_* tables) should be listed' default='NO'>"
     113             :         "    <Value>YES</Value>"
     114             :         "    <Value>NO</Value>"
     115             :         "  </Option>"
     116        1219 :         "</OpenOptionList>");
     117             : 
     118        1219 :     poDriver->pfnOpen = OGRPGeoDriverOpen;
     119        1219 :     poDriver->pfnIdentify = OGRPGeoDriverIdentify;
     120             : 
     121        1219 :     GetGDALDriverManager()->RegisterDriver(poDriver);
     122             : }

Generated by: LCOV version 1.14