Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: EDIGEO Translator 4 : * Purpose: Implements OGREDIGEODriver. 5 : * Author: Even Rouault, even dot rouault at spatialys.com 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2011, Even Rouault <even dot rouault at spatialys.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_edigeo.h" 30 : #include "cpl_conv.h" 31 : 32 : extern "C" void RegisterOGREDIGEO(); 33 : 34 : // g++ -fPIC -g -Wall ogr/ogrsf_frmts/edigeo/*.cpp -shared -o ogr_EDIGEO.so 35 : // -Iport -Igcore -Iogr -Iogr/ogrsf_frmts -Iogr/ogrsf_frmts/generic 36 : // -Iogr/ogrsf_frmts/edigeo -L. -lgdal 37 : 38 : /************************************************************************/ 39 : /* OGREDIGEODriverIdentify() */ 40 : /************************************************************************/ 41 : 42 42189 : static int OGREDIGEODriverIdentify(GDALOpenInfo *poOpenInfo) 43 : 44 : { 45 44397 : return poOpenInfo->fpL != nullptr && 46 44397 : EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "thf"); 47 : } 48 : 49 : /************************************************************************/ 50 : /* Open() */ 51 : /************************************************************************/ 52 : 53 0 : static GDALDataset *OGREDIGEODriverOpen(GDALOpenInfo *poOpenInfo) 54 : 55 : { 56 0 : if (poOpenInfo->eAccess == GA_Update || 57 0 : !OGREDIGEODriverIdentify(poOpenInfo)) 58 0 : return nullptr; 59 : 60 0 : OGREDIGEODataSource *poDS = new OGREDIGEODataSource(); 61 : 62 0 : if (!poDS->Open(poOpenInfo->pszFilename)) 63 : { 64 0 : delete poDS; 65 0 : poDS = nullptr; 66 : } 67 : 68 0 : return poDS; 69 : } 70 : 71 : /************************************************************************/ 72 : /* RegisterOGREDIGEO() */ 73 : /************************************************************************/ 74 : 75 1512 : void RegisterOGREDIGEO() 76 : 77 : { 78 1512 : if (GDALGetDriverByName("EDIGEO") != nullptr) 79 295 : return; 80 : 81 1217 : GDALDriver *poDriver = new GDALDriver(); 82 : 83 1217 : poDriver->SetDescription("EDIGEO"); 84 1217 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 85 1217 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, 86 1217 : "French EDIGEO exchange format"); 87 1217 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "thf"); 88 1217 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/edigeo.html"); 89 : 90 1217 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 91 1217 : poDriver->SetMetadataItem(GDAL_DCAP_FEATURE_STYLES, "YES"); 92 1217 : poDriver->SetMetadataItem(GDAL_DCAP_FEATURE_STYLES_READ, "YES"); 93 1217 : poDriver->SetMetadataItem(GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, "YES"); 94 1217 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE"); 95 : 96 1217 : poDriver->pfnOpen = OGREDIGEODriverOpen; 97 1217 : poDriver->pfnIdentify = OGREDIGEODriverIdentify; 98 : 99 1217 : GetGDALDriverManager()->RegisterDriver(poDriver); 100 : }