LCOV - code coverage report
Current view: top level - frmts/pcraster - pcrasterdrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 24 24 100.0 %
Date: 2024-05-01 14:25:35 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  PCRaster Integration
       4             :  * Purpose:  PCRaster driver support functions.
       5             :  * Author:   Kor de Jong, Oliver Schmitz
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) PCRaster owners
       9             :  *
      10             :  * Permission is hereby granted, free of charge, to any person obtaining a
      11             :  * copy of this software and associated documentation files (the "Software"),
      12             :  * to deal in the Software without restriction, including without limitation
      13             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14             :  * and/or sell copies of the Software, and to permit persons to whom the
      15             :  * Software is furnished to do so, subject to the following conditions:
      16             :  *
      17             :  * The above copyright notice and this permission notice shall be included
      18             :  * in all copies or substantial portions of the Software.
      19             :  *
      20             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26             :  * DEALINGS IN THE SOFTWARE.
      27             :  ****************************************************************************/
      28             : 
      29             : #include "pcrasterdrivercore.h"
      30             : 
      31             : /* value for first 27 bytes of MAIN_HEADER.signature */
      32             : #ifndef CSF_SIG
      33             : #define CSF_SIG "RUU CROSS SYSTEM MAP FORMAT"
      34             : #define CSF_SIZE_SIG (sizeof(CSF_SIG) - 1)
      35             : #endif
      36             : 
      37             : /************************************************************************/
      38             : /*                     PCRasterDriverIdentify()                         */
      39             : /************************************************************************/
      40             : 
      41       52720 : int PCRasterDriverIdentify(GDALOpenInfo *poOpenInfo)
      42             : 
      43             : {
      44       58977 :     return (poOpenInfo->fpL &&
      45       58667 :             poOpenInfo->nHeaderBytes >= static_cast<int>(CSF_SIZE_SIG) &&
      46        5947 :             strncmp(reinterpret_cast<char *>(poOpenInfo->pabyHeader), CSF_SIG,
      47       52720 :                     CSF_SIZE_SIG) == 0);
      48             : }
      49             : 
      50             : #undef CSF_SIG
      51             : #undef CSF_SIZE_SIG
      52             : 
      53             : /************************************************************************/
      54             : /*                    PCRasterDriverSetCommonMetadata()                 */
      55             : /************************************************************************/
      56             : 
      57        1224 : void PCRasterDriverSetCommonMetadata(GDALDriver *poDriver)
      58             : {
      59        1224 :     poDriver->SetDescription(DRIVER_NAME);
      60        1224 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      61             : 
      62        1224 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "PCRaster Raster File");
      63        1224 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONDATATYPES, "Byte Int32 Float32");
      64        1224 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC,
      65        1224 :                               "drivers/raster/pcraster.html");
      66        1224 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "map");
      67             : 
      68        1224 :     poDriver->pfnIdentify = PCRasterDriverIdentify;
      69        1224 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
      70        1224 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES");
      71        1224 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES");
      72        1224 : }
      73             : 
      74             : /************************************************************************/
      75             : /*                  DeclareDeferredPCRasterPlugin()                     */
      76             : /************************************************************************/
      77             : 
      78             : #ifdef PLUGIN_FILENAME
      79        1512 : void DeclareDeferredPCRasterPlugin()
      80             : {
      81        1512 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      82             :     {
      83         295 :         return;
      84             :     }
      85        1217 :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
      86             : #ifdef PLUGIN_INSTALLATION_MESSAGE
      87             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
      88             :                               PLUGIN_INSTALLATION_MESSAGE);
      89             : #endif
      90        1217 :     PCRasterDriverSetCommonMetadata(poDriver);
      91        1217 :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
      92             : }
      93             : #endif

Generated by: LCOV version 1.14