Sophie

Sophie

distrib > Mandriva > 9.0 > i586 > by-pkgid > d67485fb8ce60f8952179bbde3b5d022 > files > 107

libgdal0-devel-1.1.7-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>gdalrasterband.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.3-20001105 on Thu Mar 28 09:47:30 2002 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>gdalrasterband.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * $Id: gdalrasterband_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Project:  GDAL Core</font>
00005 <font class="comment"> * Purpose:  Base class for format specific band class implementation.  This</font>
00006 <font class="comment"> *           base class provides default implementation for many methods.</font>
00007 <font class="comment"> * Author:   Frank Warmerdam, warmerda@home.com</font>
00008 <font class="comment"> *</font>
00009 <font class="comment"> ******************************************************************************</font>
00010 <font class="comment"> * Copyright (c) 1998, Frank Warmerdam</font>
00011 <font class="comment"> *</font>
00012 <font class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</font>
00013 <font class="comment"> * copy of this software and associated documentation files (the "Software"),</font>
00014 <font class="comment"> * to deal in the Software without restriction, including without limitation</font>
00015 <font class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</font>
00016 <font class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</font>
00017 <font class="comment"> * Software is furnished to do so, subject to the following conditions:</font>
00018 <font class="comment"> *</font>
00019 <font class="comment"> * The above copyright notice and this permission notice shall be included</font>
00020 <font class="comment"> * in all copies or substantial portions of the Software.</font>
00021 <font class="comment"> *</font>
00022 <font class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</font>
00023 <font class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</font>
00024 <font class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</font>
00025 <font class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</font>
00026 <font class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</font>
00027 <font class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</font>
00028 <font class="comment"> * DEALINGS IN THE SOFTWARE.</font>
00029 <font class="comment"> ******************************************************************************</font>
00030 <font class="comment"> * $Log: gdalrasterband_cpp-source.html,v $
00030 <font class="comment"> * Revision 1.10  2002/04/16 13:11:48  warmerda
00030 <font class="comment"> * updated
00030 <font class="comment"> *</font>
00031 <font class="comment"> * Revision 1.27  2002/03/01 14:29:09  warmerda</font>
00032 <font class="comment"> * added GetBand() method on GDALRasterBand</font>
00033 <font class="comment"> *</font>
00034 <font class="comment"> * Revision 1.26  2001/12/07 15:29:45  warmerda</font>
00035 <font class="comment"> * added InitBlockInfo() in GetHistogram()</font>
00036 <font class="comment"> *</font>
00037 <font class="comment"> * Revision 1.25  2001/10/18 14:35:22  warmerda</font>
00038 <font class="comment"> * avoid conflicts between parameters and member data</font>
00039 <font class="comment"> *</font>
00040 <font class="comment"> * Revision 1.24  2001/10/17 16:20:45  warmerda</font>
00041 <font class="comment"> * make histograming work with complex data (r(treat as magnitude)</font>
00042 <font class="comment"> *</font>
00043 <font class="comment"> * Revision 1.23  2001/07/18 04:04:30  warmerda</font>
00044 <font class="comment"> * added CPL_CVSID</font>
00045 <font class="comment"> *</font>
00046 <font class="comment"> * Revision 1.22  2001/07/05 13:13:40  warmerda</font>
00047 <font class="comment"> * added UnitType from C support</font>
00048 <font class="comment"> *</font>
00049 <font class="comment"> * Revision 1.21  2000/10/06 15:25:48  warmerda</font>
00050 <font class="comment"> * added setnodata, and some other methods</font>
00051 <font class="comment"> *</font>
00052 <font class="comment"> * Revision 1.20  2000/08/25 14:26:51  warmerda</font>
00053 <font class="comment"> * added GDALHasArbitraryOverviews</font>
00054 <font class="comment"> *</font>
00055 <font class="comment"> * Revision 1.19  2000/08/16 15:50:52  warmerda</font>
00056 <font class="comment"> * fixed some bugs with floating (datasetless) bands</font>
00057 <font class="comment"> *</font>
00058 <font class="comment"> * Revision 1.18  2000/07/12 00:19:29  warmerda</font>
00059 <font class="comment"> * Removed extra line feed.</font>
00060 <font class="comment"> *</font>
00061 <font class="comment"> * Revision 1.17  2000/06/05 17:24:05  warmerda</font>
00062 <font class="comment"> * added real complex support</font>
00063 <font class="comment"> *</font>
00064 <font class="comment"> * Revision 1.16  2000/04/21 21:56:59  warmerda</font>
00065 <font class="comment"> * moved metadata to GDALMajorObject</font>
00066 <font class="comment"> *</font>
00067 <font class="comment"> * Revision 1.15  2000/03/31 13:42:27  warmerda</font>
00068 <font class="comment"> * added metadata support</font>
00069 <font class="comment"> *</font>
00070 <font class="comment"> * Revision 1.14  2000/03/24 00:09:05  warmerda</font>
00071 <font class="comment"> * rewrote cache management</font>
00072 <font class="comment"> *</font>
00073 <font class="comment"> * Revision 1.13  2000/03/10 13:54:37  warmerda</font>
00074 <font class="comment"> * fixed use of overviews in gethistogram</font>
00075 <font class="comment"> *</font>
00076 <font class="comment"> * Revision 1.12  2000/03/09 23:22:03  warmerda</font>
00077 <font class="comment"> * added GetHistogram</font>
00078 <font class="comment"> *</font>
00079 <font class="comment"> * Revision 1.11  2000/03/08 19:59:16  warmerda</font>
00080 <font class="comment"> * added GDALFlushRasterCache</font>
00081 <font class="comment"> *</font>
00082 <font class="comment"> * Revision 1.10  2000/03/06 21:50:37  warmerda</font>
00083 <font class="comment"> * added min/max support</font>
00084 <font class="comment"> *</font>
00085 <font class="comment"> * Revision 1.9  2000/03/06 02:22:01  warmerda</font>
00086 <font class="comment"> * added overviews, colour tables, and many other methods</font>
00087 <font class="comment"> *</font>
00088 <font class="comment"> * Revision 1.8  2000/02/28 16:34:28  warmerda</font>
00089 <font class="comment"> * added arg window check in RasterIO()</font>
00090 <font class="comment"> *</font>
00091 <font class="comment"> * Revision 1.7  1999/11/17 16:18:10  warmerda</font>
00092 <font class="comment"> * fixed example code</font>
00093 <font class="comment"> *</font>
00094 <font class="comment"> * Revision 1.6  1999/10/21 13:24:37  warmerda</font>
00095 <font class="comment"> * Fixed some build breaking variable name differences.</font>
00096 <font class="comment"> *</font>
00097 <font class="comment"> * Revision 1.5  1999/10/01 14:44:02  warmerda</font>
00098 <font class="comment"> * added documentation</font>
00099 <font class="comment"> *</font>
00100 <font class="comment"> * Revision 1.4  1998/12/31 18:54:25  warmerda</font>
00101 <font class="comment"> * Implement initial GDALRasterBlock support, and block cache</font>
00102 <font class="comment"> *</font>
00103 <font class="comment"> * Revision 1.3  1998/12/06 22:17:09  warmerda</font>
00104 <font class="comment"> * Fill out rasterio support.</font>
00105 <font class="comment"> *</font>
00106 <font class="comment"> * Revision 1.2  1998/12/06 02:52:08  warmerda</font>
00107 <font class="comment"> * Added new methods, and C cover functions.</font>
00108 <font class="comment"> *</font>
00109 <font class="comment"> * Revision 1.1  1998/12/03 18:32:01  warmerda</font>
00110 <font class="comment"> * New</font>
00111 <font class="comment"> */</font>
00112 
00113 <font class="preprocessor">#include "gdal_priv.h"</font>
00114 <font class="preprocessor">#include "cpl_string.h"</font>
00115 
00116 CPL_CVSID(<font class="stringliteral">"$Id: gdalrasterband_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $"</font>);
00117 
00118 <font class="comment">/************************************************************************/</font>
00119 <font class="comment">/*                           GDALRasterBand()                           */</font>
00120 <font class="comment">/************************************************************************/</font>
00121 
<a name="l00124"></a><a class="code" href="class_GDALRasterBand.html#a0">00124</a> <a class="code" href="class_GDALRasterBand.html#a0">GDALRasterBand::GDALRasterBand</a>()<font class="keyword"></font>
00125 <font class="keyword"></font>
00126 <font class="keyword"></font>{
00127     poDS = NULL;
00128     nBand = 0;
00129 
00130     eAccess = GA_ReadOnly;
00131     nBlockXSize = nBlockYSize = -1;
00132     eDataType = GDT_Byte;
00133 
00134     nBlocksPerRow = 0;
00135     nBlocksPerColumn = 0;
00136 
00137     papoBlocks = NULL;
00138 }
00139 
00140 <font class="comment">/************************************************************************/</font>
00141 <font class="comment">/*                          ~GDALRasterBand()                           */</font>
00142 <font class="comment">/************************************************************************/</font>
00143 
<a name="l00147"></a><a class="code" href="class_GDALRasterBand.html#a1">00147</a> <a class="code" href="class_GDALRasterBand.html#a1">GDALRasterBand::~GDALRasterBand</a>()<font class="keyword"></font>
00148 <font class="keyword"></font>
00149 <font class="keyword"></font>{
00150     <a class="code" href="class_GDALRasterBand.html#a12">FlushCache</a>();
00151     
00152     CPLFree( papoBlocks );
00153 }
00154 
00155 <font class="comment">/************************************************************************/</font>
00156 <font class="comment">/*                              RasterIO()                              */</font>
00157 <font class="comment">/************************************************************************/</font>
00158 
<a name="l00224"></a><a class="code" href="class_GDALRasterBand.html#a8">00224</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a8">GDALRasterBand::RasterIO</a>( GDALRWFlag eRWFlag,
00225                                  <font class="keywordtype">int</font> nXOff, <font class="keywordtype">int</font> nYOff, <font class="keywordtype">int</font> nXSize, <font class="keywordtype">int</font> nYSize,
00226                                  <font class="keywordtype">void</font> * pData, <font class="keywordtype">int</font> nBufXSize, <font class="keywordtype">int</font> nBufYSize,
00227                                  GDALDataType eBufType,
00228                                  <font class="keywordtype">int</font> nPixelSpace,
00229                                  <font class="keywordtype">int</font> nLineSpace )<font class="keyword"></font>
00230 <font class="keyword"></font>
00231 <font class="keyword"></font>{
00232 <font class="comment">/* -------------------------------------------------------------------- */</font>
00233 <font class="comment">/*      If pixel and line spaceing are defaulted assign reasonable      */</font>
00234 <font class="comment">/*      value assuming a packed buffer.                                 */</font>
00235 <font class="comment">/* -------------------------------------------------------------------- */</font>
00236     <font class="keywordflow">if</font>( nPixelSpace == 0 )
00237         nPixelSpace = GDALGetDataTypeSize( eBufType ) / 8;
00238     
00239     <font class="keywordflow">if</font>( nLineSpace == 0 )
00240         nLineSpace = nPixelSpace * nBufXSize;
00241     
00242 <font class="comment">/* -------------------------------------------------------------------- */</font>
00243 <font class="comment">/*      Do some validation of parameters.                               */</font>
00244 <font class="comment">/* -------------------------------------------------------------------- */</font>
00245     <font class="keywordflow">if</font>( nXOff &lt; 0 || nXOff + nXSize &gt; nRasterXSize
00246         || nYOff &lt; 0 || nYOff + nYSize &gt; nRasterYSize )
00247     {
00248         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_IllegalArg,
00249                   <font class="stringliteral">"Access window out of range in RasterIO().  Requested\n"</font>
00250                   <font class="stringliteral">"(%d,%d) of size %dx%d on raster of %dx%d."</font>,
00251                   nXOff, nYOff, nXSize, nYSize, nRasterXSize, nRasterYSize );
00252         <font class="keywordflow">return</font> CE_Failure;
00253     }
00254 
00255 <font class="comment">/* -------------------------------------------------------------------- */</font>
00256 <font class="comment">/*      Some size values are "noop".  Lets just return to avoid         */</font>
00257 <font class="comment">/*      stressing lower level functions.                                */</font>
00258 <font class="comment">/* -------------------------------------------------------------------- */</font>
00259     <font class="keywordflow">if</font>( nXSize &lt; 1 || nYSize &lt; 1 || nBufXSize &lt; 1 || nBufYSize &lt; 1 )
00260     {
00261         <a class="code" href="cpl_error_h.html#a29">CPLDebug</a>( <font class="stringliteral">"GDAL"</font>, 
00262                   <font class="stringliteral">"RasterIO() skipped for odd window or buffer size.\n"</font>
00263                   <font class="stringliteral">"  Window = (%d,%d)x%dx%d\n"</font>
00264                   <font class="stringliteral">"  Buffer = %dx%d\n"</font>,
00265                   nXOff, nYOff, nXSize, nYSize, 
00266                   nBufXSize, nBufYSize );
00267 
00268         <font class="keywordflow">return</font> CE_None;
00269     }
00270     
00271 <font class="comment">/* -------------------------------------------------------------------- */</font>
00272 <font class="comment">/*      Call the format specific function.                              */</font>
00273 <font class="comment">/* -------------------------------------------------------------------- */</font>
00274     <font class="keywordflow">return</font>( IRasterIO( eRWFlag, nXOff, nYOff, nXSize, nYSize,
00275                        pData, nBufXSize, nBufYSize, eBufType,
00276                        nPixelSpace, nLineSpace ) );
00277 }
00278 
00279 <font class="comment">/************************************************************************/</font>
00280 <font class="comment">/*                            GDALRasterIO()                            */</font>
00281 <font class="comment">/************************************************************************/</font>
00282 
00283 CPLErr GDALRasterIO( GDALRasterBandH hBand, GDALRWFlag eRWFlag,
00284                      <font class="keywordtype">int</font> nXOff, <font class="keywordtype">int</font> nYOff,
00285                      <font class="keywordtype">int</font> nXSize, <font class="keywordtype">int</font> nYSize,
00286                      <font class="keywordtype">void</font> * pData,
00287                      <font class="keywordtype">int</font> nBufXSize, <font class="keywordtype">int</font> nBufYSize,
00288                      GDALDataType eBufType,
00289                      <font class="keywordtype">int</font> nPixelSpace,
00290                      <font class="keywordtype">int</font> nLineSpace )<font class="keyword"></font>
00291 <font class="keyword"></font>
00292 <font class="keyword"></font>{
00293     <a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a>      *poBand = (<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand;
00294 
00295     <font class="keywordflow">return</font>( poBand-&gt;<a class="code" href="class_GDALRasterBand.html#a8">RasterIO</a>( eRWFlag, nXOff, nYOff, nXSize, nYSize,
00296                               pData, nBufXSize, nBufYSize, eBufType,
00297                               nPixelSpace, nLineSpace ) );
00298 }
00299                      
00300 <font class="comment">/************************************************************************/</font>
00301 <font class="comment">/*                             ReadBlock()                              */</font>
00302 <font class="comment">/************************************************************************/</font>
00303 
<a name="l00386"></a><a class="code" href="class_GDALRasterBand.html#a9">00386</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a9">GDALRasterBand::ReadBlock</a>( <font class="keywordtype">int</font> nXBlockOff, <font class="keywordtype">int</font> nYBlockOff,
00387                                    <font class="keywordtype">void</font> * pImage )<font class="keyword"></font>
00388 <font class="keyword"></font>
00389 <font class="keyword"></font>{
00390 <font class="comment">/* -------------------------------------------------------------------- */</font>
00391 <font class="comment">/*      Validate arguments.                                             */</font>
00392 <font class="comment">/* -------------------------------------------------------------------- */</font>
00393     CPLAssert( pImage != NULL );
00394     
00395     <font class="keywordflow">if</font>( nXBlockOff &lt; 0
00396         || nXBlockOff*nBlockXSize &gt;= nRasterXSize )
00397     {
00398         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_IllegalArg,
00399                   <font class="stringliteral">"Illegal nXBlockOff value (%d) in "</font>
00400                         <font class="stringliteral">"GDALRasterBand::ReadBlock()\n"</font>,
00401                   nXBlockOff );
00402 
00403         <font class="keywordflow">return</font>( CE_Failure );
00404     }
00405 
00406     <font class="keywordflow">if</font>( nYBlockOff &lt; 0
00407         || nYBlockOff*nBlockYSize &gt;= nRasterYSize )
00408     {
00409         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_IllegalArg,
00410                   <font class="stringliteral">"Illegal nYBlockOff value (%d) in "</font>
00411                         <font class="stringliteral">"GDALRasterBand::ReadBlock()\n"</font>,
00412                   nYBlockOff );
00413 
00414         <font class="keywordflow">return</font>( CE_Failure );
00415     }
00416     
00417 <font class="comment">/* -------------------------------------------------------------------- */</font>
00418 <font class="comment">/*      Invoke underlying implementation method.                        */</font>
00419 <font class="comment">/* -------------------------------------------------------------------- */</font>
00420     <font class="keywordflow">return</font>( IReadBlock( nXBlockOff, nYBlockOff, pImage ) );
00421 }
00422 
00423 <font class="comment">/************************************************************************/</font>
00424 <font class="comment">/*                           GDALReadBlock()                            */</font>
00425 <font class="comment">/************************************************************************/</font>
00426 
00427 CPLErr GDALReadBlock( GDALRasterBandH hBand, <font class="keywordtype">int</font> nXOff, <font class="keywordtype">int</font> nYOff,
00428                       <font class="keywordtype">void</font> * pData )<font class="keyword"></font>
00429 <font class="keyword"></font>
00430 <font class="keyword"></font>{
00431     <a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a>      *poBand = (<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand;
00432 
00433     <font class="keywordflow">return</font>( poBand-&gt;<a class="code" href="class_GDALRasterBand.html#a9">ReadBlock</a>( nXOff, nYOff, pData ) );
00434 }
00435 
00436 <font class="comment">/************************************************************************/</font>
00437 <font class="comment">/*                            IWriteBlock()                             */</font>
00438 <font class="comment">/*                                                                      */</font>
00439 <font class="comment">/*      Default internal implementation ... to be overriden by          */</font>
00440 <font class="comment">/*      subclasses that support writing.                                */</font>
00441 <font class="comment">/************************************************************************/</font>
00442 
00443 CPLErr GDALRasterBand::IWriteBlock( <font class="keywordtype">int</font>, <font class="keywordtype">int</font>, <font class="keywordtype">void</font> * )<font class="keyword"></font>
00444 <font class="keyword"></font>
00445 <font class="keyword"></font>{
00446     <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_NotSupported,
00447               <font class="stringliteral">"WriteBlock() not supported for this dataset."</font> );
00448     
00449     <font class="keywordflow">return</font>( CE_Failure );
00450 }
00451 
00452 <font class="comment">/************************************************************************/</font>
00453 <font class="comment">/*                             WriteBlock()                             */</font>
00454 <font class="comment">/************************************************************************/</font>
00455 
<a name="l00486"></a><a class="code" href="class_GDALRasterBand.html#a10">00486</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a10">GDALRasterBand::WriteBlock</a>( <font class="keywordtype">int</font> nXBlockOff, <font class="keywordtype">int</font> nYBlockOff,
00487                                    <font class="keywordtype">void</font> * pImage )<font class="keyword"></font>
00488 <font class="keyword"></font>
00489 <font class="keyword"></font>{
00490 <font class="comment">/* -------------------------------------------------------------------- */</font>
00491 <font class="comment">/*      Validate arguments.                                             */</font>
00492 <font class="comment">/* -------------------------------------------------------------------- */</font>
00493     CPLAssert( pImage != NULL );
00494     
00495     <font class="keywordflow">if</font>( nXBlockOff &lt; 0
00496         || nXBlockOff*nBlockXSize &gt;= <a class="code" href="class_GDALRasterBand.html#a2">GetXSize</a>() )
00497     {
00498         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_IllegalArg,
00499                   <font class="stringliteral">"Illegal nXBlockOff value (%d) in "</font>
00500                         <font class="stringliteral">"GDALRasterBand::WriteBlock()\n"</font>,
00501                   nXBlockOff );
00502 
00503         <font class="keywordflow">return</font>( CE_Failure );
00504     }
00505 
00506     <font class="keywordflow">if</font>( nYBlockOff &lt; 0
00507         || nYBlockOff*nBlockYSize &gt;= <a class="code" href="class_GDALRasterBand.html#a3">GetYSize</a>() )
00508     {
00509         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_IllegalArg,
00510                   <font class="stringliteral">"Illegal nYBlockOff value (%d) in "</font>
00511                         <font class="stringliteral">"GDALRasterBand::WriteBlock()\n"</font>,
00512                   nYBlockOff );
00513 
00514         <font class="keywordflow">return</font>( CE_Failure );
00515     }
00516 
00517     <font class="keywordflow">if</font>( eAccess == GA_ReadOnly )
00518     {
00519         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_NoWriteAccess,
00520                   <font class="stringliteral">"Attempt to write to read only dataset in"</font>
00521                   <font class="stringliteral">"GDALRasterBand::WriteBlock().\n"</font> );
00522 
00523         <font class="keywordflow">return</font>( CE_Failure );
00524     }
00525     
00526 <font class="comment">/* -------------------------------------------------------------------- */</font>
00527 <font class="comment">/*      Invoke underlying implementation method.                        */</font>
00528 <font class="comment">/* -------------------------------------------------------------------- */</font>
00529     <font class="keywordflow">return</font>( IWriteBlock( nXBlockOff, nYBlockOff, pImage ) );
00530 }
00531 
00532 <font class="comment">/************************************************************************/</font>
00533 <font class="comment">/*                           GDALWriteBlock()                           */</font>
00534 <font class="comment">/************************************************************************/</font>
00535 
00536 CPLErr GDALWriteBlock( GDALRasterBandH hBand, <font class="keywordtype">int</font> nXOff, <font class="keywordtype">int</font> nYOff,
00537                        <font class="keywordtype">void</font> * pData )<font class="keyword"></font>
00538 <font class="keyword"></font>
00539 <font class="keyword"></font>{
00540     <a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a>      *poBand = (<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand;
00541 
00542     <font class="keywordflow">return</font>( poBand-&gt;<a class="code" href="class_GDALRasterBand.html#a10">WriteBlock</a>( nXOff, nYOff, pData ) );
00543 }
00544 
00545 
00546 <font class="comment">/************************************************************************/</font>
00547 <font class="comment">/*                         GetRasterDataType()                          */</font>
00548 <font class="comment">/************************************************************************/</font>
00549 
<a name="l00557"></a><a class="code" href="class_GDALRasterBand.html#a5">00557</a> GDALDataType <a class="code" href="class_GDALRasterBand.html#a5">GDALRasterBand::GetRasterDataType</a>()<font class="keyword"></font>
00558 <font class="keyword"></font>
00559 <font class="keyword"></font>{
00560     <font class="keywordflow">return</font> eDataType;
00561 }
00562 
00563 <font class="comment">/************************************************************************/</font>
00564 <font class="comment">/*                       GDALGetRasterDataType()                        */</font>
00565 <font class="comment">/************************************************************************/</font>
00566 
00567 GDALDataType GDALGetRasterDataType( GDALRasterBandH hBand )<font class="keyword"></font>
00568 <font class="keyword"></font>
00569 <font class="keyword"></font>{
00570     <font class="keywordflow">return</font>( ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetRasterDataType() );
00571 }
00572 
00573 <font class="comment">/************************************************************************/</font>
00574 <font class="comment">/*                            GetBlockSize()                            */</font>
00575 <font class="comment">/************************************************************************/</font>
00576 
<a name="l00597"></a><a class="code" href="class_GDALRasterBand.html#a6">00597</a> <font class="keywordtype">void</font> <a class="code" href="class_GDALRasterBand.html#a6">GDALRasterBand::GetBlockSize</a>( <font class="keywordtype">int</font> * pnXSize, <font class="keywordtype">int</font> *pnYSize )<font class="keyword"></font>
00598 <font class="keyword"></font>
00599 <font class="keyword"></font>{
00600     CPLAssert( nBlockXSize &gt; 0 &amp;&amp; nBlockYSize &gt; 0 );
00601     
00602     <font class="keywordflow">if</font>( pnXSize != NULL )
00603         *pnXSize = nBlockXSize;
00604     <font class="keywordflow">if</font>( pnYSize != NULL )
00605         *pnYSize = nBlockYSize;
00606 }
00607 
00608 <font class="comment">/************************************************************************/</font>
00609 <font class="comment">/*                          GDALGetBlockSize()                          */</font>
00610 <font class="comment">/************************************************************************/</font>
00611 
00612 <font class="keywordtype">void</font> GDALGetBlockSize( GDALRasterBandH hBand, <font class="keywordtype">int</font> * pnXSize, <font class="keywordtype">int</font> * pnYSize )<font class="keyword"></font>
00613 <font class="keyword"></font>
00614 <font class="keyword"></font>{
00615     <a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a>      *poBand = (<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand;
00616 
00617     poBand-&gt;<a class="code" href="class_GDALRasterBand.html#a6">GetBlockSize</a>( pnXSize, pnYSize );
00618 }
00619 
00620 <font class="comment">/************************************************************************/</font>
00621 <font class="comment">/*                           InitBlockInfo()                            */</font>
00622 <font class="comment">/************************************************************************/</font>
00623 
00624 <font class="keywordtype">void</font> GDALRasterBand::InitBlockInfo()<font class="keyword"></font>
00625 <font class="keyword"></font>
00626 <font class="keyword"></font>{
00627     <font class="keywordflow">if</font>( papoBlocks != NULL )
00628         <font class="keywordflow">return</font>;
00629 
00630     CPLAssert( nBlockXSize &gt; 0 &amp;&amp; nBlockYSize &gt; 0 );
00631     
00632     nBlocksPerRow = (nRasterXSize+nBlockXSize-1) / nBlockXSize;
00633     nBlocksPerColumn = (nRasterYSize+nBlockYSize-1) / nBlockYSize;
00634     
00635     papoBlocks = (<a class="code" href="class_GDALRasterBlock.html">GDALRasterBlock</a> **)
00636         <a class="code" href="cpl_conv_h.html#a4">CPLCalloc</a>( <font class="keyword">sizeof</font>(<font class="keywordtype">void</font>*), nBlocksPerRow * nBlocksPerColumn );
00637 }
00638 
00639 
00640 <font class="comment">/************************************************************************/</font>
00641 <font class="comment">/*                             AdoptBlock()                             */</font>
00642 <font class="comment">/*                                                                      */</font>
00643 <font class="comment">/*      Add a block to the raster band's block matrix.  If this         */</font>
00644 <font class="comment">/*      exceeds our maximum blocks for this layer, flush the oldest     */</font>
00645 <font class="comment">/*      block out.                                                      */</font>
00646 <font class="comment">/*                                                                      */</font>
00647 <font class="comment">/*      This method is protected.                                       */</font>
00648 <font class="comment">/************************************************************************/</font>
00649 
00650 CPLErr GDALRasterBand::AdoptBlock( <font class="keywordtype">int</font> nBlockXOff, <font class="keywordtype">int</font> nBlockYOff,
00651                                    <a class="code" href="class_GDALRasterBlock.html">GDALRasterBlock</a> * poBlock )<font class="keyword"></font>
00652 <font class="keyword"></font>
00653 <font class="keyword"></font>{
00654     <font class="keywordtype">int</font>         nBlockIndex;
00655     
00656     InitBlockInfo();
00657     
00658     CPLAssert( nBlockXOff &gt;= 0 &amp;&amp; nBlockXOff &lt; nBlocksPerRow );
00659     CPLAssert( nBlockYOff &gt;= 0 &amp;&amp; nBlockYOff &lt; nBlocksPerColumn );
00660 
00661     nBlockIndex = nBlockXOff + nBlockYOff * nBlocksPerRow;
00662     <font class="keywordflow">if</font>( papoBlocks[nBlockIndex] == poBlock )
00663         <font class="keywordflow">return</font>( CE_None );
00664 
00665     <font class="keywordflow">if</font>( papoBlocks[nBlockIndex] != NULL )
00666         FlushBlock( nBlockXOff, nBlockYOff );
00667 
00668     papoBlocks[nBlockIndex] = poBlock;
00669     poBlock-&gt;Touch();
00670 
00671     <font class="keywordflow">return</font>( CE_None );
00672 }
00673 
00674 <font class="comment">/************************************************************************/</font>
00675 <font class="comment">/*                             FlushCache()                             */</font>
00676 <font class="comment">/************************************************************************/</font>
00677 
<a name="l00689"></a><a class="code" href="class_GDALRasterBand.html#a12">00689</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a12">GDALRasterBand::FlushCache</a>()<font class="keyword"></font>
00690 <font class="keyword"></font>
00691 <font class="keyword"></font>{
00692     <font class="keywordflow">for</font>( <font class="keywordtype">int</font> iY = 0; iY &lt; nBlocksPerColumn; iY++ )
00693     {
00694         <font class="keywordflow">for</font>( <font class="keywordtype">int</font> iX = 0; iX &lt; nBlocksPerRow; iX++ )
00695         {
00696             <font class="keywordflow">if</font>( papoBlocks[iX + iY*nBlocksPerRow] != NULL )
00697             {
00698                 CPLErr    eErr;
00699 
00700                 eErr = FlushBlock( iX, iY );
00701 
00702                 <font class="keywordflow">if</font>( eErr != CE_None )
00703                     <font class="keywordflow">return</font> eErr;
00704             }
00705         }
00706     }
00707 
00708     <font class="keywordflow">return</font>( CE_None );
00709 }
00710 
00711 <font class="comment">/************************************************************************/</font>
00712 <font class="comment">/*                        GDALFlushRasterCache()                        */</font>
00713 <font class="comment">/************************************************************************/</font>
00714 
00715 CPLErr GDALFlushRasterCache( GDALRasterBandH hBand )<font class="keyword"></font>
00716 <font class="keyword"></font>
00717 <font class="keyword"></font>{
00718     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;FlushCache();
00719 }
00720 
00721 <font class="comment">/************************************************************************/</font>
00722 <font class="comment">/*                             FlushBlock()                             */</font>
00723 <font class="comment">/*                                                                      */</font>
00724 <font class="comment">/*      Flush a block out of the block cache.  If it has been           */</font>
00725 <font class="comment">/*      modified write it to disk.  If no specific tile is              */</font>
00726 <font class="comment">/*      indicated, write the oldest tile.                               */</font>
00727 <font class="comment">/*                                                                      */</font>
00728 <font class="comment">/*      Protected method.                                               */</font>
00729 <font class="comment">/************************************************************************/</font>
00730 
00731 CPLErr GDALRasterBand::FlushBlock( <font class="keywordtype">int</font> nBlockXOff, <font class="keywordtype">int</font> nBlockYOff )<font class="keyword"></font>
00732 <font class="keyword"></font>
00733 <font class="keyword"></font>{
00734     <font class="keywordtype">int</font>         nBlockIndex;
00735     <a class="code" href="class_GDALRasterBlock.html">GDALRasterBlock</a> *poBlock;
00736     CPLErr      eErr = CE_None;
00737         
00738     InitBlockInfo();
00739     
00740 <font class="comment">/* -------------------------------------------------------------------- */</font>
00741 <font class="comment">/*      Validate                                                        */</font>
00742 <font class="comment">/* -------------------------------------------------------------------- */</font>
00743     CPLAssert( nBlockXOff &gt;= 0 &amp;&amp; nBlockXOff &lt; nBlocksPerRow );
00744     CPLAssert( nBlockYOff &gt;= 0 &amp;&amp; nBlockYOff &lt; nBlocksPerColumn );
00745 
00746     nBlockIndex = nBlockXOff + nBlockYOff * nBlocksPerRow;
00747     poBlock = papoBlocks[nBlockIndex];
00748     <font class="keywordflow">if</font>( poBlock == NULL )
00749         <font class="keywordflow">return</font>( CE_None );
00750 
00751 <font class="comment">/* -------------------------------------------------------------------- */</font>
00752 <font class="comment">/*      Remove, and update count.                                       */</font>
00753 <font class="comment">/* -------------------------------------------------------------------- */</font>
00754     papoBlocks[nBlockIndex] = NULL;
00755 
00756 <font class="comment">/* -------------------------------------------------------------------- */</font>
00757 <font class="comment">/*      Is the target block dirty?  If so we need to write it.          */</font>
00758 <font class="comment">/* -------------------------------------------------------------------- */</font>
00759     <font class="keywordflow">if</font>( poBlock-&gt;GetDirty() )
00760         poBlock-&gt;Write();
00761 
00762 <font class="comment">/* -------------------------------------------------------------------- */</font>
00763 <font class="comment">/*      Deallocate the block;                                           */</font>
00764 <font class="comment">/* -------------------------------------------------------------------- */</font>
00765     <font class="keyword">delete</font> poBlock;
00766 
00767     <font class="keywordflow">return</font>( eErr );
00768 }
00769 
00770 
00771 <font class="comment">/************************************************************************/</font>
00772 <font class="comment">/*                            GetBlockRef()                             */</font>
00773 <font class="comment">/************************************************************************/</font>
00774 
<a name="l00790"></a><a class="code" href="class_GDALRasterBand.html#a11">00790</a> <a class="code" href="class_GDALRasterBlock.html">GDALRasterBlock</a> * <a class="code" href="class_GDALRasterBand.html#a11">GDALRasterBand::GetBlockRef</a>( <font class="keywordtype">int</font> nXBlockOff,
00791                                                <font class="keywordtype">int</font> nYBlockOff )<font class="keyword"></font>
00792 <font class="keyword"></font>
00793 <font class="keyword"></font>{
00794     <font class="keywordtype">int</font>         nBlockIndex;
00795 
00796     InitBlockInfo();
00797     
00798 <font class="comment">/* -------------------------------------------------------------------- */</font>
00799 <font class="comment">/*      Validate the request                                            */</font>
00800 <font class="comment">/* -------------------------------------------------------------------- */</font>
00801     <font class="keywordflow">if</font>( nXBlockOff &lt; 0 || nXBlockOff &gt;= nBlocksPerRow )
00802     {
00803         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_IllegalArg,
00804                   <font class="stringliteral">"Illegal nBlockXOff value (%d) in "</font>
00805                         <font class="stringliteral">"GDALRasterBand::GetBlockRef()\n"</font>,
00806                   nXBlockOff );
00807 
00808         <font class="keywordflow">return</font>( NULL );
00809     }
00810 
00811     <font class="keywordflow">if</font>( nYBlockOff &lt; 0 || nYBlockOff &gt;= nBlocksPerColumn )
00812     {
00813         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_IllegalArg,
00814                   <font class="stringliteral">"Illegal nBlockYOff value (%d) in "</font>
00815                         <font class="stringliteral">"GDALRasterBand::GetBlockRef()\n"</font>,
00816                   nYBlockOff );
00817 
00818         <font class="keywordflow">return</font>( NULL );
00819     }
00820 
00821 <font class="comment">/* -------------------------------------------------------------------- */</font>
00822 <font class="comment">/*      If the block isn't already in the cache, we will need to        */</font>
00823 <font class="comment">/*      create it, read into it, and adopt it.  Adopting it may         */</font>
00824 <font class="comment">/*      flush an old tile from the cache.                               */</font>
00825 <font class="comment">/* -------------------------------------------------------------------- */</font>
00826     nBlockIndex = nXBlockOff + nYBlockOff * nBlocksPerRow;
00827     
00828     <font class="keywordflow">if</font>( papoBlocks[nBlockIndex] == NULL )
00829     {
00830         <a class="code" href="class_GDALRasterBlock.html">GDALRasterBlock</a> *poBlock;
00831         
00832         poBlock = <font class="keyword">new</font> GDALRasterBlock( <font class="keyword">this</font>, nXBlockOff, nYBlockOff );
00833 
00834         <font class="comment">/* allocate data space */</font>
00835         <font class="keywordflow">if</font>( poBlock-&gt;Internalize() != CE_None )
00836         {
00837             <font class="keyword">delete</font> poBlock;
00838 
00839             <font class="keywordflow">return</font>( NULL );
00840         }
00841 
00842         <font class="keywordflow">if</font>( IReadBlock(nXBlockOff,nYBlockOff,poBlock-&gt;GetDataRef()) != CE_None)
00843         {
00844             <font class="keyword">delete</font> poBlock;
00845             <font class="keywordflow">return</font>( NULL );
00846         }
00847 
00848         AdoptBlock( nXBlockOff, nYBlockOff, poBlock );
00849     }
00850 
00851 <font class="comment">/* -------------------------------------------------------------------- */</font>
00852 <font class="comment">/*      Every read access updates the last touched time.                */</font>
00853 <font class="comment">/* -------------------------------------------------------------------- */</font>
00854     <font class="keywordflow">if</font>( papoBlocks[nBlockIndex] != NULL )
00855         papoBlocks[nBlockIndex]-&gt;<a class="code" href="class_GDALRasterBlock.html#a3">Touch</a>();
00856 
00857     <font class="keywordflow">return</font>( papoBlocks[nBlockIndex] );
00858 }
00859 
00860 <font class="comment">/************************************************************************/</font>
00861 <font class="comment">/*                             GetAccess()                              */</font>
00862 <font class="comment">/************************************************************************/</font>
00863 
<a name="l00870"></a><a class="code" href="class_GDALRasterBand.html#a7">00870</a> GDALAccess <a class="code" href="class_GDALRasterBand.html#a7">GDALRasterBand::GetAccess</a>()<font class="keyword"></font>
00871 <font class="keyword"></font>
00872 <font class="keyword"></font>{
00873     <font class="keywordflow">return</font> eAccess;
00874 }
00875 
00876 <font class="comment">/************************************************************************/</font>
00877 <font class="comment">/*                          GetCategoryNames()                          */</font>
00878 <font class="comment">/************************************************************************/</font>
00879 
<a name="l00895"></a><a class="code" href="class_GDALRasterBand.html#a15">00895</a> <font class="keywordtype">char</font> **<a class="code" href="class_GDALRasterBand.html#a15">GDALRasterBand::GetCategoryNames</a>()<font class="keyword"></font>
00896 <font class="keyword"></font>
00897 <font class="keyword"></font>{
00898     <font class="keywordflow">return</font> NULL;
00899 }
00900 
00901 <font class="comment">/************************************************************************/</font>
00902 <font class="comment">/*                     GDALGetRasterCategoryNames()                     */</font>
00903 <font class="comment">/************************************************************************/</font>
00904 
00905 <font class="keywordtype">char</font> **GDALGetRasterCategoryNames( GDALRasterBandH hBand )<font class="keyword"></font>
00906 <font class="keyword"></font>
00907 <font class="keyword"></font>{
00908     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetCategoryNames();
00909 }
00910 
00911 <font class="comment">/************************************************************************/</font>
00912 <font class="comment">/*                          SetCategoryNames()                          */</font>
00913 <font class="comment">/************************************************************************/</font>
00914 
<a name="l00930"></a><a class="code" href="class_GDALRasterBand.html#a24">00930</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a24">GDALRasterBand::SetCategoryNames</a>( <font class="keywordtype">char</font> ** )<font class="keyword"></font>
00931 <font class="keyword"></font>
00932 <font class="keyword"></font>{
00933     <font class="keywordflow">return</font> CE_Failure;
00934 }
00935 
00936 <font class="comment">/************************************************************************/</font>
00937 <font class="comment">/*                        GDALSetCategoryNames()                        */</font>
00938 <font class="comment">/************************************************************************/</font>
00939 
00940 CPLErr GDALSetRasterCategoryNames( GDALRasterBandH hBand, <font class="keywordtype">char</font> ** papszNames )<font class="keyword"></font>
00941 <font class="keyword"></font>
00942 <font class="keyword"></font>{
00943     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;SetCategoryNames( papszNames );
00944 }
00945 
00946 <font class="comment">/************************************************************************/</font>
00947 <font class="comment">/*                           GetNoDataValue()                           */</font>
00948 <font class="comment">/************************************************************************/</font>
00949 
<a name="l00966"></a><a class="code" href="class_GDALRasterBand.html#a16">00966</a> <font class="keywordtype">double</font> <a class="code" href="class_GDALRasterBand.html#a16">GDALRasterBand::GetNoDataValue</a>( <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
00967 <font class="keyword"></font>
00968 <font class="keyword"></font>{
00969     <font class="keywordflow">if</font>( pbSuccess != NULL )
00970         *pbSuccess = FALSE;
00971     
00972     <font class="keywordflow">return</font> -1e10;
00973 }
00974 
00975 <font class="comment">/************************************************************************/</font>
00976 <font class="comment">/*                      GDALGetRasterNoDataValue()                      */</font>
00977 <font class="comment">/************************************************************************/</font>
00978 
00979 <font class="keywordtype">double</font> GDALGetRasterNoDataValue( GDALRasterBandH hBand, <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
00980 <font class="keyword"></font>
00981 <font class="keyword"></font>{
00982     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetNoDataValue( pbSuccess );
00983 }
00984 
00985 <font class="comment">/************************************************************************/</font>
00986 <font class="comment">/*                           SetNoDataValue()                           */</font>
00987 <font class="comment">/************************************************************************/</font>
00988 
<a name="l01004"></a><a class="code" href="class_GDALRasterBand.html#a25">01004</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a25">GDALRasterBand::SetNoDataValue</a>( <font class="keywordtype">double</font> )<font class="keyword"></font>
01005 <font class="keyword"></font>
01006 <font class="keyword"></font>{
01007     <font class="keywordflow">return</font> CE_Failure;
01008 }
01009 
01010 <font class="comment">/************************************************************************/</font>
01011 <font class="comment">/*                         GDALSetRasterNoDataValue()                   */</font>
01012 <font class="comment">/************************************************************************/</font>
01013 
01014 CPLErr GDALSetRasterNoDataValue( GDALRasterBandH hBand, <font class="keywordtype">double</font> dfValue )<font class="keyword"></font>
01015 <font class="keyword"></font>
01016 <font class="keyword"></font>{
01017     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;SetNoDataValue( dfValue );
01018 }
01019 
01020 <font class="comment">/************************************************************************/</font>
01021 <font class="comment">/*                             GetMaximum()                             */</font>
01022 <font class="comment">/************************************************************************/</font>
01023 
<a name="l01038"></a><a class="code" href="class_GDALRasterBand.html#a18">01038</a> <font class="keywordtype">double</font> <a class="code" href="class_GDALRasterBand.html#a18">GDALRasterBand::GetMaximum</a>( <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
01039 <font class="keyword"></font>
01040 <font class="keyword"></font>{
01041     <font class="keywordflow">if</font>( pbSuccess != NULL )
01042         *pbSuccess = FALSE;
01043 
01044     <font class="keywordflow">switch</font>( eDataType )
01045     {
01046       <font class="keywordflow">case</font> GDT_Byte:
01047         <font class="keywordflow">return</font> 255;
01048 
01049       <font class="keywordflow">case</font> GDT_UInt16:
01050         <font class="keywordflow">return</font> 65535;
01051 
01052       <font class="keywordflow">case</font> GDT_Int16:
01053       <font class="keywordflow">case</font> GDT_CInt16:
01054         <font class="keywordflow">return</font> 32767;
01055 
01056       <font class="keywordflow">case</font> GDT_Int32:
01057       <font class="keywordflow">case</font> GDT_CInt32:
01058         <font class="keywordflow">return</font> 2147483647.0;
01059 
01060       <font class="keywordflow">case</font> GDT_UInt32:
01061         <font class="keywordflow">return</font> 4294967295.0;
01062 
01063       <font class="keywordflow">case</font> GDT_Float32:
01064       <font class="keywordflow">case</font> GDT_CFloat32:
01065         <font class="keywordflow">return</font> 4294967295.0; <font class="comment">/* not actually accurate */</font>
01066 
01067       <font class="keywordflow">case</font> GDT_Float64:
01068       <font class="keywordflow">case</font> GDT_CFloat64:
01069         <font class="keywordflow">return</font> 4294967295.0; <font class="comment">/* not actually accurate */</font>
01070 
01071       <font class="keywordflow">default</font>:
01072         <font class="keywordflow">return</font> 4294967295.0; <font class="comment">/* not actually accurate */</font>
01073     }
01074 }
01075 
01076 <font class="comment">/************************************************************************/</font>
01077 <font class="comment">/*                        GDALGetRasterMaximum()                        */</font>
01078 <font class="comment">/************************************************************************/</font>
01079 
01080 <font class="keywordtype">double</font> GDALGetRasterMaximum( GDALRasterBandH hBand, <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
01081 <font class="keyword"></font>
01082 <font class="keyword"></font>{
01083     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetMaximum( pbSuccess );
01084 }
01085 
01086 <font class="comment">/************************************************************************/</font>
01087 <font class="comment">/*                             GetMinimum()                             */</font>
01088 <font class="comment">/************************************************************************/</font>
01089 
<a name="l01104"></a><a class="code" href="class_GDALRasterBand.html#a17">01104</a> <font class="keywordtype">double</font> <a class="code" href="class_GDALRasterBand.html#a17">GDALRasterBand::GetMinimum</a>( <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
01105 <font class="keyword"></font>
01106 <font class="keyword"></font>{
01107     <font class="keywordflow">if</font>( pbSuccess != NULL )
01108         *pbSuccess = FALSE;
01109 
01110     <font class="keywordflow">switch</font>( eDataType )
01111     {
01112       <font class="keywordflow">case</font> GDT_Byte:
01113         <font class="keywordflow">return</font> 0;
01114 
01115       <font class="keywordflow">case</font> GDT_UInt16:
01116         <font class="keywordflow">return</font> 0;
01117 
01118       <font class="keywordflow">case</font> GDT_Int16:
01119         <font class="keywordflow">return</font> -32768;
01120 
01121       <font class="keywordflow">case</font> GDT_Int32:
01122         <font class="keywordflow">return</font> -2147483648.0;
01123 
01124       <font class="keywordflow">case</font> GDT_UInt32:
01125         <font class="keywordflow">return</font> 0;
01126 
01127       <font class="keywordflow">case</font> GDT_Float32:
01128         <font class="keywordflow">return</font> -4294967295.0; <font class="comment">/* not actually accurate */</font>
01129 
01130       <font class="keywordflow">case</font> GDT_Float64:
01131         <font class="keywordflow">return</font> -4294967295.0; <font class="comment">/* not actually accurate */</font>
01132 
01133       <font class="keywordflow">default</font>:
01134         <font class="keywordflow">return</font> -4294967295.0; <font class="comment">/* not actually accurate */</font>
01135     }
01136 }
01137 
01138 <font class="comment">/************************************************************************/</font>
01139 <font class="comment">/*                        GDALGetRasterMinimum()                        */</font>
01140 <font class="comment">/************************************************************************/</font>
01141 
01142 <font class="keywordtype">double</font> GDALGetRasterMinimum( GDALRasterBandH hBand, <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
01143 <font class="keyword"></font>
01144 <font class="keyword"></font>{
01145     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetMinimum( pbSuccess );
01146 }
01147 
01148 <font class="comment">/************************************************************************/</font>
01149 <font class="comment">/*                       GetColorInterpretation()                       */</font>
01150 <font class="comment">/************************************************************************/</font>
01151 
<a name="l01164"></a><a class="code" href="class_GDALRasterBand.html#a22">01164</a> GDALColorInterp <a class="code" href="class_GDALRasterBand.html#a22">GDALRasterBand::GetColorInterpretation</a>()<font class="keyword"></font>
01165 <font class="keyword"></font>
01166 <font class="keyword"></font>{
01167     <font class="keywordflow">return</font> GCI_Undefined;
01168 }
01169 
01170 <font class="comment">/************************************************************************/</font>
01171 <font class="comment">/*                  GDALGetRasterColorInterpretation()                  */</font>
01172 <font class="comment">/************************************************************************/</font>
01173 
01174 GDALColorInterp GDALGetRasterColorInterpretation( GDALRasterBandH hBand )<font class="keyword"></font>
01175 <font class="keyword"></font>
01176 <font class="keyword"></font>{
01177     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetColorInterpretation();
01178 }
01179 
01180 <font class="comment">/************************************************************************/</font>
01181 <font class="comment">/*                           GetColorTable()                            */</font>
01182 <font class="comment">/************************************************************************/</font>
01183 
<a name="l01196"></a><a class="code" href="class_GDALRasterBand.html#a23">01196</a> GDALColorTable *<a class="code" href="class_GDALRasterBand.html#a23">GDALRasterBand::GetColorTable</a>()<font class="keyword"></font>
01197 <font class="keyword"></font>
01198 <font class="keyword"></font>{
01199     <font class="keywordflow">return</font> NULL;
01200 }
01201 
01202 <font class="comment">/************************************************************************/</font>
01203 <font class="comment">/*                      GDALGetRasterColorTable()                       */</font>
01204 <font class="comment">/************************************************************************/</font>
01205 
01206 GDALColorTableH GDALGetRasterColorTable( GDALRasterBandH hBand )<font class="keyword"></font>
01207 <font class="keyword"></font>
01208 <font class="keyword"></font>{
01209     <font class="keywordflow">return</font> (GDALColorTableH) ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetColorTable();
01210 }
01211 
01212 <font class="comment">/************************************************************************/</font>
01213 <font class="comment">/*                           SetColorTable()                            */</font>
01214 <font class="comment">/************************************************************************/</font>
01215 
<a name="l01231"></a><a class="code" href="class_GDALRasterBand.html#a26">01231</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a26">GDALRasterBand::SetColorTable</a>( GDALColorTable * poCT )<font class="keyword"></font>
01232 <font class="keyword"></font>
01233 <font class="keyword"></font>{
01234     <font class="keywordflow">return</font> CE_Failure;
01235 }
01236 
01237 <font class="comment">/************************************************************************/</font>
01238 <font class="comment">/*                      GDALSetRasterColorTable()                       */</font>
01239 <font class="comment">/************************************************************************/</font>
01240 
01241 CPLErr GDALSetRasterColorTable( GDALRasterBandH hBand, GDALColorTableH hCT )<font class="keyword"></font>
01242 <font class="keyword"></font>
01243 <font class="keyword"></font>{
01244     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;SetColorTable( (GDALColorTable *) hCT );
01245 }
01246 
01247 <font class="comment">/************************************************************************/</font>
01248 <font class="comment">/*                       HasArbitraryOverviews()                        */</font>
01249 <font class="comment">/************************************************************************/</font>
01250 
<a name="l01266"></a><a class="code" href="class_GDALRasterBand.html#a27">01266</a> <font class="keywordtype">int</font> <a class="code" href="class_GDALRasterBand.html#a27">GDALRasterBand::HasArbitraryOverviews</a>()<font class="keyword"></font>
01267 <font class="keyword"></font>
01268 <font class="keyword"></font>{
01269     <font class="keywordflow">return</font> FALSE;
01270 }
01271 
01272 <font class="comment">/************************************************************************/</font>
01273 <font class="comment">/*                     GDALHasArbitraryOverviews()                      */</font>
01274 <font class="comment">/************************************************************************/</font>
01275 
01276 <font class="keywordtype">int</font> GDALHasArbitraryOverviews( GDALRasterBandH hBand )<font class="keyword"></font>
01277 <font class="keyword"></font>
01278 <font class="keyword"></font>{
01279     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;HasArbitraryOverviews();
01280 }
01281 
01282 <font class="comment">/************************************************************************/</font>
01283 <font class="comment">/*                          GetOverviewCount()                          */</font>
01284 <font class="comment">/************************************************************************/</font>
01285 
<a name="l01294"></a><a class="code" href="class_GDALRasterBand.html#a28">01294</a> <font class="keywordtype">int</font> <a class="code" href="class_GDALRasterBand.html#a28">GDALRasterBand::GetOverviewCount</a>()<font class="keyword"></font>
01295 <font class="keyword"></font>
01296 <font class="keyword"></font>{
01297     <font class="keywordflow">if</font>( poDS != NULL &amp;&amp; poDS-&gt;oOvManager.IsInitialized() )
01298         <font class="keywordflow">return</font> poDS-&gt;oOvManager.<a class="code" href="class_GDALRasterBand.html#a28">GetOverviewCount</a>( nBand );
01299     <font class="keywordflow">else</font>
01300         <font class="keywordflow">return</font> 0;
01301 }
01302 
01303 <font class="comment">/************************************************************************/</font>
01304 <font class="comment">/*                        GDALGetOverviewCount()                        */</font>
01305 <font class="comment">/************************************************************************/</font>
01306 
01307 <font class="keywordtype">int</font> GDALGetOverviewCount( GDALRasterBandH hBand )<font class="keyword"></font>
01308 <font class="keyword"></font>
01309 <font class="keyword"></font>{
01310     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetOverviewCount();
01311 }
01312 
01313 
01314 <font class="comment">/************************************************************************/</font>
01315 <font class="comment">/*                            GetOverview()                             */</font>
01316 <font class="comment">/************************************************************************/</font>
01317 
<a name="l01328"></a><a class="code" href="class_GDALRasterBand.html#a29">01328</a> <a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> * <a class="code" href="class_GDALRasterBand.html#a29">GDALRasterBand::GetOverview</a>( <font class="keywordtype">int</font> i )<font class="keyword"></font>
01329 <font class="keyword"></font>
01330 <font class="keyword"></font>{
01331     <font class="keywordflow">if</font>( poDS != NULL &amp;&amp; poDS-&gt;oOvManager.IsInitialized() )
01332         <font class="keywordflow">return</font> poDS-&gt;oOvManager.<a class="code" href="class_GDALRasterBand.html#a29">GetOverview</a>( nBand, i );
01333     <font class="keywordflow">else</font>
01334         <font class="keywordflow">return</font> NULL;
01335 }
01336 
01337 <font class="comment">/************************************************************************/</font>
01338 <font class="comment">/*                          GDALGetOverview()                           */</font>
01339 <font class="comment">/************************************************************************/</font>
01340 
01341 GDALRasterBandH GDALGetOverview( GDALRasterBandH hBand, <font class="keywordtype">int</font> i )<font class="keyword"></font>
01342 <font class="keyword"></font>
01343 <font class="keyword"></font>{
01344     <font class="keywordflow">return</font> (GDALRasterBandH) ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;<a class="code" href="class_GDALRasterBand.html#a29">GetOverview</a>(i);
01345 }
01346 
01347 <font class="comment">/************************************************************************/</font>
01348 <font class="comment">/*                           BuildOverviews()                           */</font>
01349 <font class="comment">/************************************************************************/</font>
01350 
<a name="l01367"></a><a class="code" href="class_GDALRasterBand.html#a30">01367</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a30">GDALRasterBand::BuildOverviews</a>( <font class="keyword">const</font> <font class="keywordtype">char</font> *pszResampling, 
01368                                        <font class="keywordtype">int</font> nOverviews, <font class="keywordtype">int</font> *panOverviewList, 
01369                                        GDALProgressFunc pfnProgress, 
01370                                        <font class="keywordtype">void</font> * pProgressData )<font class="keyword"></font>
01371 <font class="keyword"></font>
01372 <font class="keyword"></font>{
01373     <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_NotSupported,
01374               <font class="stringliteral">"BuildOverviews() not supported for this dataset."</font> );
01375     
01376     <font class="keywordflow">return</font>( CE_Failure );
01377 }
01378 
01379 <font class="comment">/************************************************************************/</font>
01380 <font class="comment">/*                             GetOffset()                              */</font>
01381 <font class="comment">/************************************************************************/</font>
01382 
<a name="l01402"></a><a class="code" href="class_GDALRasterBand.html#a19">01402</a> <font class="keywordtype">double</font> <a class="code" href="class_GDALRasterBand.html#a19">GDALRasterBand::GetOffset</a>( <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
01403 <font class="keyword"></font>
01404 <font class="keyword"></font>{
01405     <font class="keywordflow">if</font>( pbSuccess != NULL )
01406         *pbSuccess = FALSE;
01407 
01408     <font class="keywordflow">return</font> 0.0;
01409 }
01410 
01411 <font class="comment">/************************************************************************/</font>
01412 <font class="comment">/*                              GetScale()                              */</font>
01413 <font class="comment">/************************************************************************/</font>
01414 
<a name="l01434"></a><a class="code" href="class_GDALRasterBand.html#a20">01434</a> <font class="keywordtype">double</font> <a class="code" href="class_GDALRasterBand.html#a20">GDALRasterBand::GetScale</a>( <font class="keywordtype">int</font> *pbSuccess )<font class="keyword"></font>
01435 <font class="keyword"></font>
01436 <font class="keyword"></font>{
01437     <font class="keywordflow">if</font>( pbSuccess != NULL )
01438         *pbSuccess = FALSE;
01439 
01440     <font class="keywordflow">return</font> 1.0;
01441 }
01442 
01443 <font class="comment">/************************************************************************/</font>
01444 <font class="comment">/*                           GetDescription()                           */</font>
01445 <font class="comment">/************************************************************************/</font>
01446 
<a name="l01453"></a><a class="code" href="class_GDALRasterBand.html#a14">01453</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_GDALRasterBand.html#a14">GDALRasterBand::GetDescription</a>()<font class="keyword"></font>
01454 <font class="keyword"></font>
01455 <font class="keyword"></font>{
01456     <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
01457 }
01458 
01459 
01460 <font class="comment">/************************************************************************/</font>
01461 <font class="comment">/*                            GetUnitType()                             */</font>
01462 <font class="comment">/************************************************************************/</font>
01463 
<a name="l01477"></a><a class="code" href="class_GDALRasterBand.html#a21">01477</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_GDALRasterBand.html#a21">GDALRasterBand::GetUnitType</a>()<font class="keyword"></font>
01478 <font class="keyword"></font>
01479 <font class="keyword"></font>{
01480     <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
01481 }
01482 
01483 <font class="comment">/************************************************************************/</font>
01484 <font class="comment">/*                       GDALGetRasterUnitType()                        */</font>
01485 <font class="comment">/************************************************************************/</font>
01486 
01487 <font class="keyword">const</font> <font class="keywordtype">char</font> *GDALGetRasterUnitType( GDALRasterBandH hBand )<font class="keyword"></font>
01488 <font class="keyword"></font>
01489 <font class="keyword"></font>{
01490     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetUnitType();
01491 }
01492 
01493 <font class="comment">/************************************************************************/</font>
01494 <font class="comment">/*                              GetXSize()                              */</font>
01495 <font class="comment">/************************************************************************/</font>
01496 
<a name="l01505"></a><a class="code" href="class_GDALRasterBand.html#a2">01505</a> <font class="keywordtype">int</font> <a class="code" href="class_GDALRasterBand.html#a2">GDALRasterBand::GetXSize</a>()<font class="keyword"></font>
01506 <font class="keyword"></font>
01507 <font class="keyword"></font>{
01508     <font class="keywordflow">return</font> nRasterXSize;
01509 }
01510 
01511 <font class="comment">/************************************************************************/</font>
01512 <font class="comment">/*                       GDALGetRasterBandXSize()                       */</font>
01513 <font class="comment">/************************************************************************/</font>
01514 
01515 <font class="keywordtype">int</font> GDALGetRasterBandXSize( GDALRasterBandH hBand )<font class="keyword"></font>
01516 <font class="keyword"></font>
01517 <font class="keyword"></font>{
01518     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetXSize();
01519 }
01520 
01521 <font class="comment">/************************************************************************/</font>
01522 <font class="comment">/*                              GetYSize()                              */</font>
01523 <font class="comment">/************************************************************************/</font>
01524 
<a name="l01533"></a><a class="code" href="class_GDALRasterBand.html#a3">01533</a> <font class="keywordtype">int</font> <a class="code" href="class_GDALRasterBand.html#a3">GDALRasterBand::GetYSize</a>()<font class="keyword"></font>
01534 <font class="keyword"></font>
01535 <font class="keyword"></font>{
01536     <font class="keywordflow">return</font> nRasterYSize;
01537 }
01538 
01539 <font class="comment">/************************************************************************/</font>
01540 <font class="comment">/*                       GDALGetRasterBandYSize()                       */</font>
01541 <font class="comment">/************************************************************************/</font>
01542 
01543 <font class="keywordtype">int</font> GDALGetRasterBandYSize( GDALRasterBandH hBand )<font class="keyword"></font>
01544 <font class="keyword"></font>
01545 <font class="keyword"></font>{
01546     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;GetYSize();
01547 }
01548 
01549 <font class="comment">/************************************************************************/</font>
01550 <font class="comment">/*                              GetBand()                               */</font>
01551 <font class="comment">/************************************************************************/</font>
01552 
01553 <font class="keywordtype">int</font> GDALRasterBand::GetBand()<font class="keyword"></font>
01554 <font class="keyword"></font>
01555 <font class="keyword"></font>{
01556     <font class="keywordflow">return</font> nBand;
01557 }
01558 
01559 <font class="comment">/************************************************************************/</font>
01560 <font class="comment">/*                            GetHistogram()                            */</font>
01561 <font class="comment">/************************************************************************/</font>
01562 
<a name="l01599"></a><a class="code" href="class_GDALRasterBand.html#a31">01599</a> CPLErr <a class="code" href="class_GDALRasterBand.html#a31">GDALRasterBand::GetHistogram</a>( <font class="keywordtype">double</font> dfMin, <font class="keywordtype">double</font> dfMax, 
01600                                      <font class="keywordtype">int</font> nBuckets, <font class="keywordtype">int</font> *panHistogram, 
01601                                      <font class="keywordtype">int</font> bIncludeOutOfRange, <font class="keywordtype">int</font> bApproxOK,
01602                                      GDALProgressFunc pfnProgress, 
01603                                      <font class="keywordtype">void</font> *pProgressData )<font class="keyword"></font>
01604 <font class="keyword"></font>
01605 <font class="keyword"></font>{
01606     CPLAssert( pfnProgress != NULL );
01607 
01608 <font class="comment">/* -------------------------------------------------------------------- */</font>
01609 <font class="comment">/*      If we have overviews, use them for the histogram.               */</font>
01610 <font class="comment">/* -------------------------------------------------------------------- */</font>
01611     <font class="keywordflow">if</font>( bApproxOK &amp;&amp; <a class="code" href="class_GDALRasterBand.html#a28">GetOverviewCount</a>() &gt; 0 )
01612     {
01613         <font class="keywordtype">double</font> dfBestPixels = <a class="code" href="class_GDALRasterBand.html#a2">GetXSize</a>() * <a class="code" href="class_GDALRasterBand.html#a3">GetYSize</a>();
01614         <a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *poBestOverview = NULL;
01615         
01616         <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i &lt; <a class="code" href="class_GDALRasterBand.html#a28">GetOverviewCount</a>(); i++ )
01617         {
01618             <a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *poOverview = <a class="code" href="class_GDALRasterBand.html#a29">GetOverview</a>(i);
01619             <font class="keywordtype">double</font>         dfPixels;
01620 
01621             dfPixels = poOverview-&gt;<a class="code" href="class_GDALRasterBand.html#a2">GetXSize</a>() * poOverview-&gt;<a class="code" href="class_GDALRasterBand.html#a3">GetYSize</a>();
01622             <font class="keywordflow">if</font>( dfPixels &lt; dfBestPixels )
01623             {
01624                 dfBestPixels = dfPixels;
01625                 poBestOverview = poOverview;
01626             }
01627             
01628             <font class="keywordflow">if</font>( poBestOverview != NULL )
01629                 <font class="keywordflow">return</font> poBestOverview-&gt;
01630                     <a class="code" href="class_GDALRasterBand.html#a31">GetHistogram</a>( dfMin, dfMax, nBuckets, panHistogram, 
01631                                   bIncludeOutOfRange, bApproxOK, 
01632                                   pfnProgress, pProgressData );
01633         }
01634     }
01635 
01636 <font class="comment">/* -------------------------------------------------------------------- */</font>
01637 <font class="comment">/*      Figure out the ratio of blocks we will read to get an           */</font>
01638 <font class="comment">/*      approximate value.                                              */</font>
01639 <font class="comment">/* -------------------------------------------------------------------- */</font>
01640     <font class="keywordtype">int</font>         nSampleRate;
01641     <font class="keywordtype">double</font>      dfScale;
01642 
01643     InitBlockInfo();
01644     
01645     <font class="keywordflow">if</font>( bApproxOK )
01646         nSampleRate = 
01647             (<font class="keywordtype">int</font>) MAX(1,sqrt((<font class="keywordtype">double</font>) nBlocksPerRow * nBlocksPerColumn));
01648     <font class="keywordflow">else</font>
01649         nSampleRate = 1;
01650     
01651     dfScale = nBuckets / (dfMax - dfMin);
01652 
01653 <font class="comment">/* -------------------------------------------------------------------- */</font>
01654 <font class="comment">/*      Read the blocks, and add to histogram.                          */</font>
01655 <font class="comment">/* -------------------------------------------------------------------- */</font>
01656     memset( panHistogram, 0, <font class="keyword">sizeof</font>(<font class="keywordtype">int</font>) * nBuckets );
01657     <font class="keywordflow">for</font>( <font class="keywordtype">int</font> iSampleBlock = 0; 
01658          iSampleBlock &lt; nBlocksPerRow * nBlocksPerColumn;
01659          iSampleBlock += nSampleRate )
01660     {
01661         <font class="keywordtype">double</font> dfValue = 0.0, dfReal, dfImag;
01662         <font class="keywordtype">int</font>  iXBlock, iYBlock, nXCheck, nYCheck;
01663         <a class="code" href="class_GDALRasterBlock.html">GDALRasterBlock</a> *poBlock;
01664 
01665         <font class="keywordflow">if</font>( !pfnProgress( iSampleBlock/(<font class="keywordtype">double</font>)nBlocksPerRow*nBlocksPerColumn,
01666                           NULL, pProgressData ) )
01667             <font class="keywordflow">return</font> CE_Failure;
01668 
01669         iYBlock = iSampleBlock / nBlocksPerRow;
01670         iXBlock = iSampleBlock - nBlocksPerRow * iYBlock;
01671         
01672         poBlock = <a class="code" href="class_GDALRasterBand.html#a11">GetBlockRef</a>( iXBlock, iYBlock );
01673         <font class="keywordflow">if</font>( poBlock == NULL )
01674             <font class="keywordflow">return</font> CE_Failure;
01675         
01676         <font class="keywordflow">if</font>( (iXBlock+1) * nBlockXSize &gt; <a class="code" href="class_GDALRasterBand.html#a2">GetXSize</a>() )
01677             nXCheck = <a class="code" href="class_GDALRasterBand.html#a2">GetXSize</a>() - iXBlock * nBlockXSize;
01678         <font class="keywordflow">else</font>
01679             nXCheck = nBlockXSize;
01680 
01681         <font class="keywordflow">if</font>( (iYBlock+1) * nBlockYSize &gt; <a class="code" href="class_GDALRasterBand.html#a3">GetYSize</a>() )
01682             nYCheck = <a class="code" href="class_GDALRasterBand.html#a3">GetYSize</a>() - iYBlock * nBlockYSize;
01683         <font class="keywordflow">else</font>
01684             nYCheck = nBlockYSize;
01685 
01686         <font class="comment">/* this is a special case for a common situation */</font>
01687         <font class="keywordflow">if</font>( poBlock-&gt;GetDataType() == GDT_Byte
01688             &amp;&amp; dfScale == 1.0 &amp;&amp; (dfMin &gt;= -0.5 &amp;&amp; dfMin &lt;= 0.5)
01689             &amp;&amp; nYCheck == nBlockYSize &amp;&amp; nXCheck == nBlockXSize
01690             &amp;&amp; nBuckets == 256 )
01691         {
01692             <font class="keywordtype">int</font>    nPixels = nXCheck * nYCheck;
01693             GByte  *pabyData = (GByte *) poBlock-&gt;GetDataRef();
01694             
01695             <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i &lt; nPixels; i++ )
01696                 panHistogram[pabyData[i]]++;
01697             
01698             <font class="keywordflow">continue</font>; <font class="comment">/* to next sample block */</font>
01699         }
01700 
01701         <font class="comment">/* this isn't the fastest way to do this, but is easier for now */</font>
01702         <font class="keywordflow">for</font>( <font class="keywordtype">int</font> iY = 0; iY &lt; nYCheck; iY++ )
01703         {
01704             <font class="keywordflow">for</font>( <font class="keywordtype">int</font> iX = 0; iX &lt; nXCheck; iX++ )
01705             {
01706                 <font class="keywordtype">int</font>    iOffset = iX + iY * nBlockXSize;
01707                 <font class="keywordtype">int</font>    nIndex;
01708 
01709                 <font class="keywordflow">switch</font>( poBlock-&gt;GetDataType() )
01710                 {
01711                   <font class="keywordflow">case</font> GDT_Byte:
01712                     dfValue = ((GByte *) poBlock-&gt;GetDataRef())[iOffset];
01713                     <font class="keywordflow">break</font>;
01714 
01715                   <font class="keywordflow">case</font> GDT_UInt16:
01716                     dfValue = ((GUInt16 *) poBlock-&gt;GetDataRef())[iOffset];
01717                     <font class="keywordflow">break</font>;
01718                   <font class="keywordflow">case</font> GDT_Int16:
01719                     dfValue = ((GInt16 *) poBlock-&gt;GetDataRef())[iOffset];
01720                     <font class="keywordflow">break</font>;
01721                   <font class="keywordflow">case</font> GDT_UInt32:
01722                     dfValue = ((GUInt32 *) poBlock-&gt;GetDataRef())[iOffset];
01723                     <font class="keywordflow">break</font>;
01724                   <font class="keywordflow">case</font> GDT_Int32:
01725                     dfValue = ((GInt32 *) poBlock-&gt;GetDataRef())[iOffset];
01726                     <font class="keywordflow">break</font>;
01727                   <font class="keywordflow">case</font> GDT_Float32:
01728                     dfValue = ((<font class="keywordtype">float</font> *) poBlock-&gt;GetDataRef())[iOffset];
01729                     <font class="keywordflow">break</font>;
01730                   <font class="keywordflow">case</font> GDT_Float64:
01731                     dfValue = ((<font class="keywordtype">double</font> *) poBlock-&gt;GetDataRef())[iOffset];
01732                     <font class="keywordflow">break</font>;
01733                   <font class="keywordflow">case</font> GDT_CInt16:
01734                     dfReal = ((GInt16 *) poBlock-&gt;GetDataRef())[iOffset*2];
01735                     dfImag = ((GInt16 *) poBlock-&gt;GetDataRef())[iOffset*2+1];
01736                     dfValue = sqrt( dfReal * dfReal + dfImag * dfImag );
01737                     <font class="keywordflow">break</font>;
01738                   <font class="keywordflow">case</font> GDT_CInt32:
01739                     dfReal = ((GInt32 *) poBlock-&gt;GetDataRef())[iOffset*2];
01740                     dfImag = ((GInt32 *) poBlock-&gt;GetDataRef())[iOffset*2+1];
01741                     dfValue = sqrt( dfReal * dfReal + dfImag * dfImag );
01742                     <font class="keywordflow">break</font>;
01743                   <font class="keywordflow">case</font> GDT_CFloat32:
01744                     dfReal = ((<font class="keywordtype">float</font> *) poBlock-&gt;GetDataRef())[iOffset*2];
01745                     dfImag = ((<font class="keywordtype">float</font> *) poBlock-&gt;GetDataRef())[iOffset*2+1];
01746                     dfValue = sqrt( dfReal * dfReal + dfImag * dfImag );
01747                     <font class="keywordflow">break</font>;
01748                   <font class="keywordflow">case</font> GDT_CFloat64:
01749                     dfReal = ((<font class="keywordtype">double</font> *) poBlock-&gt;GetDataRef())[iOffset*2];
01750                     dfImag = ((<font class="keywordtype">double</font> *) poBlock-&gt;GetDataRef())[iOffset*2+1];
01751                     dfValue = sqrt( dfReal * dfReal + dfImag * dfImag );
01752                     <font class="keywordflow">break</font>;
01753                   <font class="keywordflow">default</font>:
01754                     CPLAssert( FALSE );
01755                     <font class="keywordflow">return</font> CE_Failure;
01756                 }
01757                 
01758                 nIndex = (<font class="keywordtype">int</font>) floor((dfValue - dfMin) * dfScale);
01759 
01760                 <font class="keywordflow">if</font>( nIndex &lt; 0 )
01761                 {
01762                     <font class="keywordflow">if</font>( bIncludeOutOfRange )
01763                         panHistogram[0]++;
01764                 }
01765                 <font class="keywordflow">else</font> <font class="keywordflow">if</font>( nIndex &gt;= nBuckets )
01766                 {
01767                     <font class="keywordflow">if</font>( bIncludeOutOfRange )
01768                         panHistogram[nBuckets-1]++;
01769                 }
01770                 <font class="keywordflow">else</font>
01771                 {
01772                     panHistogram[nIndex]++;
01773                 }
01774             }
01775         }
01776     }
01777 
01778     pfnProgress( 1.0, NULL, pProgressData );
01779 
01780     <font class="keywordflow">return</font> CE_None;
01781 }
01782 
01783 <font class="comment">/************************************************************************/</font>
01784 <font class="comment">/*                       GDALGetRasterHistogram()                       */</font>
01785 <font class="comment">/************************************************************************/</font>
01786 
01787 CPLErr GDALGetRasterHistogram( GDALRasterBandH hBand, 
01788                                <font class="keywordtype">double</font> dfMin, <font class="keywordtype">double</font> dfMax, 
01789                                <font class="keywordtype">int</font> nBuckets, <font class="keywordtype">int</font> *panHistogram, 
01790                                <font class="keywordtype">int</font> bIncludeOutOfRange, <font class="keywordtype">int</font> bApproxOK,
01791                                GDALProgressFunc pfnProgress, 
01792                                <font class="keywordtype">void</font> *pProgressData )<font class="keyword"></font>
01793 <font class="keyword"></font>
01794 <font class="keyword"></font>{
01795     <font class="keywordflow">return</font> ((<a class="code" href="class_GDALRasterBand.html">GDALRasterBand</a> *) hBand)-&gt;
01796         GetHistogram( dfMin, dfMax, nBuckets, panHistogram, 
01797                       bIncludeOutOfRange, bApproxOK,
01798                       pfnProgress, pProgressData );
01799 }
</div></pre><hr><address><small>Generated at Thu Mar 28 09:47:30 2002 for GDAL by
<a href="http://www.stack.nl/~dimitri/doxygen/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.3-20001105 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2000</small></address>
</body>
</html>