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 : * 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 "ogrsf_frmts.h" 31 : 32 : #include "ogrsosidrivercore.h" 33 : 34 : /************************************************************************/ 35 : /* OGRSOSIDriverIdentify() */ 36 : /************************************************************************/ 37 : 38 42320 : int OGRSOSIDriverIdentify(GDALOpenInfo *poOpenInfo) 39 : 40 : { 41 42320 : if (poOpenInfo->fpL == nullptr || 42 2245 : strstr((const char *)poOpenInfo->pabyHeader, ".HODE") == nullptr) 43 42313 : return FALSE; 44 : 45 : // TODO: add better identification 46 7 : return -1; 47 : } 48 : 49 : /************************************************************************/ 50 : /* OGRSOSIDriverSetCommonMetadata() */ 51 : /************************************************************************/ 52 : 53 1229 : void OGRSOSIDriverSetCommonMetadata(GDALDriver *poDriver) 54 : { 55 1229 : poDriver->SetDescription(DRIVER_NAME); 56 1229 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 57 : // GDAL_DMD_CREATIONFIELDDATATYPES should also be defined if CreateField is 58 : // supported poDriver->SetMetadataItem( GDAL_DCAP_CREATE_FIELD, "YES" ); 59 1229 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Norwegian SOSI Standard"); 60 1229 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/sosi.html"); 61 1229 : poDriver->SetMetadataItem( 62 : GDAL_DMD_OPENOPTIONLIST, 63 : "<OpenOptionList>" 64 : "<Option name='appendFieldsMap' type='string' description='Default is " 65 : "that all rows for equal field names will be appended in a feature, " 66 : "but with this parameter you select what field this should be valid " 67 : "for. With appendFieldsMap=f1&f2, Append will be done for field f1 " 68 : "and f2 using a comma as delimiter.'/>" 69 1229 : "</OpenOptionList>"); 70 1229 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE"); 71 : 72 1229 : poDriver->pfnIdentify = OGRSOSIDriverIdentify; 73 1229 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 74 1229 : } 75 : 76 : /************************************************************************/ 77 : /* DeclareDeferredOGRSOSIPlugin() */ 78 : /************************************************************************/ 79 : 80 : #ifdef PLUGIN_FILENAME 81 1523 : void DeclareDeferredOGRSOSIPlugin() 82 : { 83 1523 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 84 : { 85 301 : return; 86 : } 87 1222 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 88 : #ifdef PLUGIN_INSTALLATION_MESSAGE 89 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 90 : PLUGIN_INSTALLATION_MESSAGE); 91 : #endif 92 1222 : OGRSOSIDriverSetCommonMetadata(poDriver); 93 1222 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 94 : } 95 : #endif