Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: OGR 4 : * Purpose: OGRAVCBinDriver implementation (Arc/Info Binary Coverages) 5 : * Author: Frank Warmerdam, warmerdam@pobox.com 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2002, Frank Warmerdam <warmerdam@pobox.com> 9 : * 10 : * Permission is hereby granted, free of charge, to any person obtaining a 11 : * copy of this software and associated documentation files (the "Software"), 12 : * to deal in the Software without restriction, including without limitation 13 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 : * and/or sell copies of the Software, and to permit persons to whom the 15 : * Software is furnished to do so, subject to the following conditions: 16 : * 17 : * The above copyright notice and this permission notice shall be included 18 : * in all copies or substantial portions of the Software. 19 : * 20 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 : * DEALINGS IN THE SOFTWARE. 27 : ****************************************************************************/ 28 : 29 : #include "ogr_avc.h" 30 : 31 : /************************************************************************/ 32 : /* Open() */ 33 : /************************************************************************/ 34 : 35 20665 : static GDALDataset *OGRAVCBinDriverOpen(GDALOpenInfo *poOpenInfo) 36 : 37 : { 38 20665 : if (poOpenInfo->eAccess == GA_Update) 39 166 : return nullptr; 40 20499 : if (!poOpenInfo->bStatOK) 41 19609 : return nullptr; 42 890 : if (poOpenInfo->fpL != nullptr) 43 : { 44 484 : char **papszSiblingFiles = poOpenInfo->GetSiblingFiles(); 45 484 : if (papszSiblingFiles != nullptr) 46 : { 47 475 : bool bFoundCandidateFile = false; 48 19220 : for (int i = 0; papszSiblingFiles[i] != nullptr; i++) 49 : { 50 18745 : if (EQUAL(CPLGetExtension(papszSiblingFiles[i]), "ADF")) 51 : { 52 0 : bFoundCandidateFile = true; 53 0 : break; 54 : } 55 : } 56 475 : if (!bFoundCandidateFile) 57 475 : return nullptr; 58 : } 59 : } 60 : 61 415 : OGRAVCBinDataSource *poDS = new OGRAVCBinDataSource(); 62 : 63 415 : if (poDS->Open(poOpenInfo->pszFilename, TRUE) && poDS->GetLayerCount() > 0) 64 : { 65 3 : return poDS; 66 : } 67 412 : delete poDS; 68 : 69 412 : return nullptr; 70 : } 71 : 72 : /************************************************************************/ 73 : /* RegisterOGRAVC() */ 74 : /************************************************************************/ 75 : 76 1520 : void RegisterOGRAVCBin() 77 : 78 : { 79 1520 : if (GDALGetDriverByName("AVCBin") != nullptr) 80 301 : return; 81 : 82 1219 : GDALDriver *poDriver = new GDALDriver(); 83 : 84 1219 : poDriver->SetDescription("AVCBin"); 85 1219 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 86 1219 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Arc/Info Binary Coverage"); 87 1219 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/avcbin.html"); 88 1219 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 89 1219 : poDriver->SetMetadataItem(GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, "YES"); 90 1219 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE"); 91 : 92 1219 : poDriver->pfnOpen = OGRAVCBinDriverOpen; 93 : 94 1219 : GetGDALDriverManager()->RegisterDriver(poDriver); 95 : }