Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: SOSI Translator 4 : * Purpose: Implements OGRSOSIDriver. 5 : * Author: Thomas Hirsch, <thomas.hirsch statkart no> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2010, Thomas Hirsch 9 : * Copyright (c) 2010, Even Rouault <even dot rouault at spatialys.com> 10 : * 11 : * SPDX-License-Identifier: MIT 12 : ****************************************************************************/ 13 : 14 : #include "ogrsf_frmts.h" 15 : 16 : #include "ogrsosidrivercore.h" 17 : 18 : /************************************************************************/ 19 : /* OGRSOSIDriverIdentify() */ 20 : /************************************************************************/ 21 : 22 45230 : int OGRSOSIDriverIdentify(GDALOpenInfo *poOpenInfo) 23 : 24 : { 25 45230 : if (poOpenInfo->fpL == nullptr || 26 2551 : strstr((const char *)poOpenInfo->pabyHeader, ".HODE") == nullptr) 27 45223 : return FALSE; 28 : 29 : // TODO: add better identification 30 7 : return -1; 31 : } 32 : 33 : /************************************************************************/ 34 : /* OGRSOSIDriverSetCommonMetadata() */ 35 : /************************************************************************/ 36 : 37 1302 : void OGRSOSIDriverSetCommonMetadata(GDALDriver *poDriver) 38 : { 39 1302 : poDriver->SetDescription(DRIVER_NAME); 40 1302 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 41 : // GDAL_DMD_CREATIONFIELDDATATYPES should also be defined if CreateField is 42 : // supported poDriver->SetMetadataItem( GDAL_DCAP_CREATE_FIELD, "YES" ); 43 1302 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Norwegian SOSI Standard"); 44 1302 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/sosi.html"); 45 1302 : poDriver->SetMetadataItem( 46 : GDAL_DMD_OPENOPTIONLIST, 47 : "<OpenOptionList>" 48 : "<Option name='appendFieldsMap' type='string' description='Default is " 49 : "that all rows for equal field names will be appended in a feature, " 50 : "but with this parameter you select what field this should be valid " 51 : "for. With appendFieldsMap=f1&f2, Append will be done for field f1 " 52 : "and f2 using a comma as delimiter.'/>" 53 1302 : "</OpenOptionList>"); 54 1302 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE"); 55 : 56 1302 : poDriver->pfnIdentify = OGRSOSIDriverIdentify; 57 1302 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 58 1302 : } 59 : 60 : /************************************************************************/ 61 : /* DeclareDeferredOGRSOSIPlugin() */ 62 : /************************************************************************/ 63 : 64 : #ifdef PLUGIN_FILENAME 65 1595 : void DeclareDeferredOGRSOSIPlugin() 66 : { 67 1595 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 68 : { 69 302 : return; 70 : } 71 1293 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 72 : #ifdef PLUGIN_INSTALLATION_MESSAGE 73 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 74 : PLUGIN_INSTALLATION_MESSAGE); 75 : #endif 76 1293 : OGRSOSIDriverSetCommonMetadata(poDriver); 77 1293 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 78 : } 79 : #endif