LCOV - code coverage report
Current view: top level - frmts/kea - keadrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 27 27 100.0 %
Date: 2024-04-27 17:22:41 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  keadrivercore.cpp
       3             :  *
       4             :  *  Copyright 2012 LibKEA. All rights reserved.
       5             :  *
       6             :  *  Permission is hereby granted, free of charge, to any person
       7             :  *  obtaining a copy of this software and associated documentation
       8             :  *  files (the "Software"), to deal in the Software without restriction,
       9             :  *  including without limitation the rights to use, copy, modify,
      10             :  *  merge, publish, distribute, sublicense, and/or sell copies of the
      11             :  *  Software, and to permit persons to whom the Software is furnished
      12             :  *  to do so, subject to the following conditions:
      13             :  *
      14             :  *  The above copyright notice and this permission notice shall be
      15             :  *  included in all copies or substantial portions of the Software.
      16             :  *
      17             :  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      18             :  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
      19             :  *  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      20             :  *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
      21             :  *  ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
      22             :  *  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
      23             :  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      24             :  *
      25             :  */
      26             : 
      27             : #include "keadrivercore.h"
      28             : #include "libkea_headers.h"
      29             : 
      30             : /************************************************************************/
      31             : /*                     KEADriverIdentify()                              */
      32             : /************************************************************************/
      33             : 
      34       48704 : int KEADriverIdentify(GDALOpenInfo *poOpenInfo)
      35             : 
      36             : {
      37             :     /* -------------------------------------------------------------------- */
      38             :     /*      Is it an HDF5 file?                                             */
      39             :     /* -------------------------------------------------------------------- */
      40             :     static const char achSignature[] = "\211HDF\r\n\032\n";
      41             : 
      42       48704 :     if (poOpenInfo->pabyHeader == nullptr ||
      43        3423 :         memcmp(poOpenInfo->pabyHeader, achSignature, 8) != 0)
      44             :     {
      45       48326 :         return 0;
      46             :     }
      47             : 
      48         378 :     return EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "KEA");
      49             : }
      50             : 
      51             : /************************************************************************/
      52             : /*                      KEADriverSetCommonMetadata()                    */
      53             : /************************************************************************/
      54             : 
      55        1221 : void KEADriverSetCommonMetadata(GDALDriver *poDriver)
      56             : {
      57        1221 :     poDriver->SetDescription(DRIVER_NAME);
      58        1221 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      59        1221 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "KEA Image Format (.kea)");
      60        1221 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "kea");
      61        1221 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/kea.html");
      62        1221 :     poDriver->SetMetadataItem(
      63             :         GDAL_DMD_CREATIONDATATYPES,
      64             :         "Byte Int8 Int16 UInt16 Int32 UInt32 Int64 UInt64 "
      65        1221 :         "Float32 Float64");
      66        1221 :     poDriver->SetMetadataItem(
      67             :         GDAL_DMD_CREATIONOPTIONLIST,
      68             :         CPLSPrintf(
      69             :             "<CreationOptionList> "
      70             :             "<Option name='IMAGEBLOCKSIZE' type='int' description='The size of "
      71             :             "each block for image data' default='%d'/> "
      72             :             "<Option name='ATTBLOCKSIZE' type='int' description='The size of "
      73             :             "each block for attribute data' default='%d'/> "
      74             :             "<Option name='MDC_NELMTS' type='int' description='Number of "
      75             :             "elements in the meta data cache' default='%d'/> "
      76             :             "<Option name='RDCC_NELMTS' type='int' description='Number of "
      77             :             "elements in the raw data chunk cache' default='%d'/> "
      78             :             "<Option name='RDCC_NBYTES' type='int' description='Total size of "
      79             :             "the raw data chunk cache, in bytes' default='%d'/> "
      80             :             "<Option name='RDCC_W0' type='float' min='0' max='1' "
      81             :             "description='Preemption policy' default='%.2f'/> "
      82             :             "<Option name='SIEVE_BUF' type='int' description='Sets the maximum "
      83             :             "size of the data sieve buffer' default='%d'/> "
      84             :             "<Option name='META_BLOCKSIZE' type='int' description='Sets the "
      85             :             "minimum size of metadata block allocations' default='%d'/> "
      86             :             "<Option name='DEFLATE' type='int' description='0 (no compression) "
      87             :             "to 9 (max compression)' default='%d'/> "
      88             :             "<Option name='THEMATIC' type='boolean' description='If YES then "
      89             :             "all bands are set to thematic' default='NO'/> "
      90             :             "</CreationOptionList>",
      91             :             static_cast<int>(kealib::KEA_IMAGE_CHUNK_SIZE),
      92             :             static_cast<int>(kealib::KEA_ATT_CHUNK_SIZE),
      93             :             static_cast<int>(kealib::KEA_MDC_NELMTS),
      94             :             static_cast<int>(kealib::KEA_RDCC_NELMTS),
      95             :             static_cast<int>(kealib::KEA_RDCC_NBYTES), kealib::KEA_RDCC_W0,
      96             :             static_cast<int>(kealib::KEA_SIEVE_BUF),
      97        1221 :             static_cast<int>(kealib::KEA_META_BLOCKSIZE), kealib::KEA_DEFLATE));
      98        1221 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
      99             : 
     100        1221 :     poDriver->pfnIdentify = KEADriverIdentify;
     101        1221 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
     102        1221 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES");
     103        1221 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES");
     104        1221 : }
     105             : 
     106             : /************************************************************************/
     107             : /*                     DeclareDeferredKEAPlugin()                       */
     108             : /************************************************************************/
     109             : 
     110             : #ifdef PLUGIN_FILENAME
     111        1509 : void DeclareDeferredKEAPlugin()
     112             : {
     113        1509 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
     114             :     {
     115         295 :         return;
     116             :     }
     117        1214 :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
     118             : #ifdef PLUGIN_INSTALLATION_MESSAGE
     119             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
     120             :                               PLUGIN_INSTALLATION_MESSAGE);
     121             : #endif
     122        1214 :     KEADriverSetCommonMetadata(poDriver);
     123        1214 :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
     124             : }
     125             : #endif

Generated by: LCOV version 1.14