Line data Source code
1 : /* 2 : * keadrivercore.cpp 3 : * 4 : * Copyright 2012 LibKEA. All rights reserved. 5 : * 6 : * SPDX-License-Identifier: MIT 7 : * 8 : */ 9 : 10 : #include "keadrivercore.h" 11 : #include "libkea_headers.h" 12 : 13 : /************************************************************************/ 14 : /* KEADriverIdentify() */ 15 : /************************************************************************/ 16 : 17 51392 : int KEADriverIdentify(GDALOpenInfo *poOpenInfo) 18 : 19 : { 20 : /* -------------------------------------------------------------------- */ 21 : /* Is it an HDF5 file? */ 22 : /* -------------------------------------------------------------------- */ 23 : static const char achSignature[] = "\211HDF\r\n\032\n"; 24 : 25 51392 : if (poOpenInfo->pabyHeader == nullptr || 26 3641 : memcmp(poOpenInfo->pabyHeader, achSignature, 8) != 0) 27 : { 28 51005 : return 0; 29 : } 30 : 31 387 : return EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "KEA"); 32 : } 33 : 34 : /************************************************************************/ 35 : /* KEADriverSetCommonMetadata() */ 36 : /************************************************************************/ 37 : 38 1302 : void KEADriverSetCommonMetadata(GDALDriver *poDriver) 39 : { 40 1302 : poDriver->SetDescription(DRIVER_NAME); 41 1302 : poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES"); 42 1302 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "KEA Image Format (.kea)"); 43 1302 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "kea"); 44 1302 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/kea.html"); 45 1302 : poDriver->SetMetadataItem( 46 : GDAL_DMD_CREATIONDATATYPES, 47 : "Byte Int8 Int16 UInt16 Int32 UInt32 Int64 UInt64 " 48 1302 : "Float32 Float64"); 49 1302 : poDriver->SetMetadataItem( 50 : GDAL_DMD_CREATIONOPTIONLIST, 51 : CPLSPrintf( 52 : "<CreationOptionList> " 53 : "<Option name='IMAGEBLOCKSIZE' type='int' description='The size of " 54 : "each block for image data' default='%d'/> " 55 : "<Option name='ATTBLOCKSIZE' type='int' description='The size of " 56 : "each block for attribute data' default='%d'/> " 57 : "<Option name='MDC_NELMTS' type='int' description='Number of " 58 : "elements in the meta data cache' default='%d'/> " 59 : "<Option name='RDCC_NELMTS' type='int' description='Number of " 60 : "elements in the raw data chunk cache' default='%d'/> " 61 : "<Option name='RDCC_NBYTES' type='int' description='Total size of " 62 : "the raw data chunk cache, in bytes' default='%d'/> " 63 : "<Option name='RDCC_W0' type='float' min='0' max='1' " 64 : "description='Preemption policy' default='%.2f'/> " 65 : "<Option name='SIEVE_BUF' type='int' description='Sets the maximum " 66 : "size of the data sieve buffer' default='%d'/> " 67 : "<Option name='META_BLOCKSIZE' type='int' description='Sets the " 68 : "minimum size of metadata block allocations' default='%d'/> " 69 : "<Option name='DEFLATE' type='int' description='0 (no compression) " 70 : "to 9 (max compression)' default='%d'/> " 71 : "<Option name='THEMATIC' type='boolean' description='If YES then " 72 : "all bands are set to thematic' default='NO'/> " 73 : "</CreationOptionList>", 74 : static_cast<int>(kealib::KEA_IMAGE_CHUNK_SIZE), 75 : static_cast<int>(kealib::KEA_ATT_CHUNK_SIZE), 76 : static_cast<int>(kealib::KEA_MDC_NELMTS), 77 : static_cast<int>(kealib::KEA_RDCC_NELMTS), 78 : static_cast<int>(kealib::KEA_RDCC_NBYTES), kealib::KEA_RDCC_W0, 79 : static_cast<int>(kealib::KEA_SIEVE_BUF), 80 1302 : static_cast<int>(kealib::KEA_META_BLOCKSIZE), kealib::KEA_DEFLATE)); 81 1302 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 82 : 83 1302 : poDriver->pfnIdentify = KEADriverIdentify; 84 1302 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 85 1302 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES"); 86 1302 : poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES"); 87 1302 : } 88 : 89 : /************************************************************************/ 90 : /* DeclareDeferredKEAPlugin() */ 91 : /************************************************************************/ 92 : 93 : #ifdef PLUGIN_FILENAME 94 1595 : void DeclareDeferredKEAPlugin() 95 : { 96 1595 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 97 : { 98 302 : return; 99 : } 100 1293 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 101 : #ifdef PLUGIN_INSTALLATION_MESSAGE 102 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 103 : PLUGIN_INSTALLATION_MESSAGE); 104 : #endif 105 1293 : KEADriverSetCommonMetadata(poDriver); 106 1293 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 107 : } 108 : #endif