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 : * SPDX-License-Identifier: MIT 12 : ****************************************************************************/ 13 : 14 : #include "ogr_pgeo.h" 15 : #include "cpl_conv.h" 16 : 17 : /************************************************************************/ 18 : /* OGRPGeoDriverIdentify() */ 19 : /************************************************************************/ 20 : 21 46291 : static int OGRPGeoDriverIdentify(GDALOpenInfo *poOpenInfo) 22 : 23 : { 24 46291 : if (STARTS_WITH_CI(poOpenInfo->pszFilename, "PGEO:")) 25 0 : return TRUE; 26 : 27 46291 : if (!EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "mdb")) 28 46291 : return FALSE; 29 : 30 : // Could potentially be a PGeo or generic ODBC database 31 0 : return -1; 32 : } 33 : 34 : /************************************************************************/ 35 : /* OGRPGeoDriverOpen() */ 36 : /************************************************************************/ 37 : 38 0 : static GDALDataset *OGRPGeoDriverOpen(GDALOpenInfo *poOpenInfo) 39 : 40 : { 41 : // The method might return -1 when it is undecided 42 0 : if (OGRPGeoDriverIdentify(poOpenInfo) == FALSE) 43 0 : return nullptr; 44 : 45 : #ifndef _WIN32 46 : // Try to register MDB Tools driver 47 0 : CPLODBCDriverInstaller::InstallMdbToolsDriver(); 48 : #endif /* ndef WIN32 */ 49 : 50 : // Open data source 51 0 : OGRPGeoDataSource *poDS = new OGRPGeoDataSource(); 52 : 53 0 : if (!poDS->Open(poOpenInfo)) 54 : { 55 0 : delete poDS; 56 0 : return nullptr; 57 : } 58 : else 59 0 : return poDS; 60 : } 61 : 62 : /************************************************************************/ 63 : /* RegisterOGRPGeo() */ 64 : /************************************************************************/ 65 : 66 1595 : void RegisterOGRPGeo() 67 : 68 : { 69 1595 : if (GDALGetDriverByName("PGeo") != nullptr) 70 302 : return; 71 : 72 1293 : GDALDriver *poDriver = new GDALDriver; 73 : 74 1293 : poDriver->SetDescription("PGeo"); 75 1293 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 76 1293 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "ESRI Personal GeoDatabase"); 77 1293 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "mdb"); 78 1293 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/pgeo.html"); 79 1293 : poDriver->SetMetadataItem(GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, "YES"); 80 1293 : poDriver->SetMetadataItem(GDAL_DCAP_FIELD_DOMAINS, "YES"); 81 1293 : poDriver->SetMetadataItem(GDAL_DCAP_RELATIONSHIPS, "YES"); 82 1293 : poDriver->SetMetadataItem(GDAL_DCAP_CURVE_GEOMETRIES, "YES"); 83 1293 : poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES"); 84 1293 : poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES"); 85 1293 : poDriver->SetMetadataItem(GDAL_DMD_GEOMETRY_FLAGS, 86 : "EquatesMultiAndSingleLineStringDuringWrite " 87 1293 : "EquatesMultiAndSinglePolygonDuringWrite"); 88 1293 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, 89 1293 : "NATIVE OGRSQL SQLITE"); 90 : 91 1293 : poDriver->SetMetadataItem( 92 : GDAL_DMD_OPENOPTIONLIST, 93 : "<OpenOptionList>" 94 : " <Option name='LIST_ALL_TABLES' type='string-select' scope='vector' " 95 : "description='Whether all tables, including system and internal tables " 96 : "(such as GDB_* tables) should be listed' default='NO'>" 97 : " <Value>YES</Value>" 98 : " <Value>NO</Value>" 99 : " </Option>" 100 1293 : "</OpenOptionList>"); 101 : 102 1293 : poDriver->pfnOpen = OGRPGeoDriverOpen; 103 1293 : poDriver->pfnIdentify = OGRPGeoDriverIdentify; 104 : 105 1293 : GetGDALDriverManager()->RegisterDriver(poDriver); 106 : }