LCOV - code coverage report
Current view: directory - frmts/pcraster - pcrasterutil.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 18 3 16.7 %
Date: 2010-01-09 Functions: 8 1 12.5 %

       1                 : /******************************************************************************
       2                 :  * $Id: pcrasterutil.h 15451 2008-10-03 10:59:42Z kdejong $
       3                 :  *
       4                 :  * Project:  PCRaster Integration
       5                 :  * Purpose:  PCRaster driver support declarations.
       6                 :  * Author:   Kor de Jong, k.dejong at geog.uu.nl
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2004, Kor de Jong
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : // Library headers.
      31                 : #ifndef INCLUDED_STRING
      32                 : #include <string>
      33                 : #define INCLUDED_STRING
      34                 : #endif
      35                 : 
      36                 : // PCRaster library headers.
      37                 : #ifndef INCLUDED_CSF
      38                 : #include "csf.h"
      39                 : #define INCLUDED_CSF
      40                 : #endif
      41                 : 
      42                 : #ifndef INCLUDED_PCRTYPES
      43                 : #include "pcrtypes.h"
      44                 : #define INCLUDED_PCRTYPES
      45                 : #endif
      46                 : 
      47                 : // Module headers.
      48                 : #ifndef INCLUDED_GDAL_PRIV
      49                 : #include "gdal_priv.h"
      50                 : #define INCLUDED_GDAL_PRIV
      51                 : #endif
      52                 : 
      53                 : 
      54                 : GDALDataType       cellRepresentation2GDALType(CSF_CR cellRepresentation);
      55                 : 
      56                 : CSF_VS             string2ValueScale   (const std::string& string);
      57                 : 
      58                 : std::string        valueScale2String   (CSF_VS valueScale);
      59                 : 
      60                 : std::string        cellRepresentation2String(CSF_CR cellRepresentation);
      61                 : 
      62                 : CSF_VS             GDALType2ValueScale (GDALDataType type);
      63                 : 
      64                 : /*
      65                 : CSF_CR             string2PCRasterCellRepresentation(
      66                 :                                         const std::string& string);
      67                 :                                         */
      68                 : 
      69                 : CSF_CR             GDALType2CellRepresentation(
      70                 :                                         GDALDataType type,
      71                 :                                         bool exact);
      72                 : 
      73                 : void*              createBuffer        (size_t size,
      74                 :                                         CSF_CR type);
      75                 : 
      76                 : void               deleteBuffer        (void* buffer,
      77                 :                                         CSF_CR type);
      78                 : 
      79                 : bool               isContinuous        (CSF_VS valueScale);
      80                 : 
      81                 : double             missingValue        (CSF_CR type);
      82                 : 
      83                 : void               alterFromStdMV      (void* buffer,
      84                 :                                         size_t size,
      85                 :                                         CSF_CR cellRepresentation,
      86                 :                                         double missingValue);
      87                 : 
      88                 : void               alterToStdMV        (void* buffer,
      89                 :                                         size_t size,
      90                 :                                         CSF_CR cellRepresentation,
      91                 :                                         double missingValue);
      92                 : 
      93                 : MAP*               mapOpen             (std::string const& filename,
      94                 :                                         MOPEN_PERM mode);
      95                 : 
      96                 : CSF_VS             fitValueScale       (CSF_VS valueScale,
      97                 :                                         CSF_CR cellRepresentation);
      98                 : 
      99                 : void               castValuesToBooleanRange(
     100                 :                                         void* buffer,
     101                 :                                         size_t size,
     102                 :                                         CSF_CR cellRepresentation);
     103                 : 
     104                 : template<typename T>
     105                 : struct CastToBooleanRange
     106                 : {
     107               0 :   void operator()(T& value) {
     108               0 :     if(!pcr::isMV(value)) {
     109               0 :       if(value != 0) {
     110               0 :         value = T(value > T(0));
     111                 :       }
     112                 :       else {
     113               0 :         pcr::setMV(value);
     114                 :       }
     115                 :     }
     116               0 :   }
     117                 : };
     118                 : 
     119                 : 
     120                 : 
     121                 : template<>
     122                 : struct CastToBooleanRange<UINT1>
     123                 : {
     124             100 :   void operator()(UINT1& value) {
     125             100 :     if(!pcr::isMV(value)) {
     126               0 :       value = UINT1(value > UINT1(0));
     127                 :     }
     128             100 :   }
     129                 : };
     130                 : 
     131                 : 
     132                 : 
     133                 : template<>
     134                 : struct CastToBooleanRange<UINT2>
     135                 : {
     136               0 :   void operator()(UINT2& value) {
     137               0 :     if(!pcr::isMV(value)) {
     138               0 :       value = UINT2(value > UINT2(0));
     139                 :     }
     140               0 :   }
     141                 : };
     142                 : 
     143                 : 
     144                 : 
     145                 : template<>
     146                 : struct CastToBooleanRange<UINT4>
     147                 : {
     148               0 :   void operator()(UINT4& value) {
     149               0 :     if(!pcr::isMV(value)) {
     150               0 :       value = UINT4(value > UINT4(0));
     151                 :     }
     152               0 :   }
     153                 : };

Generated by: LCOV version 1.7