LCOV - code coverage report
Current view: top level - frmts/fits - fitsdrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 38 38 100.0 %
Date: 2024-05-13 13:33:37 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  FITS Driver
       4             :  * Purpose:  Implement FITS raster read/write support
       5             :  * Author:   Simon Perkins, s.perkins@lanl.gov
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2001, Simon Perkins
       9             :  * Copyright (c) 2008-2020, Even Rouault <even dot rouault at spatialys.com>
      10             :  * Copyright (c) 2018, Chiara Marmo <chiara dot marmo at u-psud dot fr>
      11             :  *
      12             :  * Permission is hereby granted, free of charge, to any person obtaining a
      13             :  * copy of this software and associated documentation files (the "Software"),
      14             :  * to deal in the Software without restriction, including without limitation
      15             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16             :  * and/or sell copies of the Software, and to permit persons to whom the
      17             :  * Software is furnished to do so, subject to the following conditions:
      18             :  *
      19             :  * The above copyright notice and this permission notice shall be included
      20             :  * in all copies or substantial portions of the Software.
      21             :  *
      22             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      23             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      24             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      25             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      26             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      27             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      28             :  * DEALINGS IN THE SOFTWARE.
      29             :  ****************************************************************************/
      30             : 
      31             : #include "fitsdrivercore.h"
      32             : 
      33             : /************************************************************************/
      34             : /*                     FITSDriverIdentify()                             */
      35             : /************************************************************************/
      36             : 
      37       62327 : int FITSDriverIdentify(GDALOpenInfo *poOpenInfo)
      38             : 
      39             : {
      40       62327 :     if (STARTS_WITH(poOpenInfo->pszFilename, "FITS:"))
      41          18 :         return true;
      42             : 
      43       62309 :     const char *fitsID = "SIMPLE  =                    T";  // Spaces important!
      44       62309 :     const size_t fitsIDLen = strlen(fitsID);  // Should be 30 chars long
      45             : 
      46       62309 :     if (static_cast<size_t>(poOpenInfo->nHeaderBytes) < fitsIDLen)
      47       48931 :         return false;
      48       13378 :     if (memcmp(poOpenInfo->pabyHeader, fitsID, fitsIDLen) != 0)
      49       13263 :         return false;
      50         115 :     return true;
      51             : }
      52             : 
      53             : /************************************************************************/
      54             : /*                      FITSDriverSetCommonMetadata()                   */
      55             : /************************************************************************/
      56             : 
      57        1230 : void FITSDriverSetCommonMetadata(GDALDriver *poDriver)
      58             : {
      59        1230 :     poDriver->SetDescription(DRIVER_NAME);
      60        1230 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      61        1230 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
      62        1230 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES");
      63        1230 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES");
      64        1230 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
      65        1230 :                               "Flexible Image Transport System");
      66        1230 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/fits.html");
      67        1230 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONDATATYPES,
      68        1230 :                               "Byte UInt16 Int16 UInt32 Int32 Float32 Float64");
      69        1230 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSIONS, "fits");
      70             : 
      71        1230 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATATYPES,
      72             :                               "Integer Integer64 Real String IntegerList "
      73        1230 :                               "Integer64List RealList");
      74        1230 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATASUBTYPES,
      75        1230 :                               "Boolean Int16 Float32");
      76             : 
      77        1230 :     poDriver->SetMetadataItem(
      78             :         GDAL_DS_LAYER_CREATIONOPTIONLIST,
      79             :         "<LayerCreationOptionList>"
      80             :         "  <Option name='REPEAT_*' type='int' description='Repeat value for "
      81             :         "fields of type List'/>"
      82             :         "  <Option name='COMPUTE_REPEAT' type='string-select' "
      83             :         "description='Determine when the repeat value for fields is computed'>"
      84             :         "    <Value>AT_FIELD_CREATION</Value>"
      85             :         "    <Value>AT_FIRST_FEATURE_CREATION</Value>"
      86             :         "  </Option>"
      87        1230 :         "</LayerCreationOptionList>");
      88             : 
      89        1230 :     poDriver->pfnIdentify = FITSDriverIdentify;
      90        1230 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
      91        1230 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES");
      92        1230 : }
      93             : 
      94             : /************************************************************************/
      95             : /*                     DeclareDeferredFITSPlugin()                      */
      96             : /************************************************************************/
      97             : 
      98             : #ifdef PLUGIN_FILENAME
      99        1522 : void DeclareDeferredFITSPlugin()
     100             : {
     101        1522 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
     102             :     {
     103         301 :         return;
     104             :     }
     105        1221 :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
     106             : #ifdef PLUGIN_INSTALLATION_MESSAGE
     107             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
     108             :                               PLUGIN_INSTALLATION_MESSAGE);
     109             : #endif
     110        1221 :     FITSDriverSetCommonMetadata(poDriver);
     111        1221 :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
     112             : }
     113             : #endif

Generated by: LCOV version 1.14