OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
GDALGrid.cc
Go to the documentation of this file.
1 // This file is part of the GDAL OPeNDAP Adapter
2 
3 // Copyright (c) 2004 OPeNDAP, Inc.
4 // Author: Frank Warmerdam <warmerdam@pobox.com>
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
21 
22 #include "config.h"
23 //#define DODS_DEBUG 1
24 
25 #include <string>
26 
27 #include <gdal.h>
28 #include <cpl_conv.h>
29 
30 #include <BESDebug.h>
31 
32 #include "GDALTypes.h"
33 
34 using namespace libdap;
35 
36 // From gdal_dds.cc
37 void read_data_array(GDALArray *array, GDALRasterBandH hBand, GDALDataType eBufType);
38 void read_map_array(Array *map, GDALRasterBandH hBand, string filename);
39 
40 /************************************************************************/
41 /* ==================================================================== */
42 /* GDALGrid */
43 /* ==================================================================== */
44 /************************************************************************/
45 
46 void GDALGrid::m_duplicate(const GDALGrid &g)
47 {
48  filename = g.filename;
49  hBand = g.hBand;
50  eBufType = g.eBufType;
51 }
52 
53 // protected
54 
55 BaseType *
57 {
58  return new GDALGrid(*this);
59 }
60 
61 // public
62 
63 GDALGrid::GDALGrid(const string &filenameIn, const string &name, GDALRasterBandH hBandIn, GDALDataType eBufTypeIn) :
64  Grid(name)
65 {
66  filename = filenameIn; // This is used to open the file in the read() method for GDALGrid
67  hBand = hBandIn;
68  eBufType = eBufTypeIn;
69 }
70 
71 GDALGrid::GDALGrid(const GDALGrid &rhs) : Grid(rhs)
72 {
73  m_duplicate(rhs);
74 }
75 
77 {
78  if (this == &rhs) return *this;
79 
80  m_duplicate(rhs);
81 
82  return *this;
83 }
84 
86 {
87 }
88 
90 {
91  BESDEBUG("gdal", "Entering GDALGrid::read()" << endl);
92 
93  if (read_p()) // nothing to do
94  return true;
95 
96  /* -------------------------------------------------------------------- */
97  /* Collect the x and y sampling values from the constraint. */
98  /* -------------------------------------------------------------------- */
99  GDALArray *array = static_cast<GDALArray*>(array_var());
100  read_data_array(array, hBand, eBufType);
101  array->set_read_p(true);
102 
103  Map_iter miter = map_begin();
104  array = static_cast<GDALArray*>((*miter));
105  read_map_array(array, hBand, filename);
106  array->set_read_p(true);
107 
108  ++miter;
109  array = static_cast<GDALArray*>(*miter);
110  read_map_array(array, hBand, filename);
111  array->set_read_p(true);
112 
113  return true;
114 }
virtual BaseType * ptr_duplicate()
Definition: GDALGrid.cc:56
static class NCMLUtil overview
void read_data_array(GDALArray *array, GDALRasterBandH hBand, GDALDataType eBufType)
Read the data array of a DAP2 Grid.
Definition: gdal_dds.cc:191
GDALGrid & operator=(const GDALGrid &rhs)
Definition: GDALGrid.cc:76
GDALGrid(const GDALGrid &rhs)
Definition: GDALGrid.cc:71
void read_map_array(Array *map, GDALRasterBandH hBand, string filename)
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
Definition: BESDebug.h:64
virtual ~GDALGrid()
Definition: GDALGrid.cc:85
virtual bool read()
Definition: GDALGrid.cc:89