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