src/terralib/memory/Raster.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/dataaccess/memory/Raster.cpp
22 
23  \brief A raster class for the In-Memory driver.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "../common/StringUtils.h"
29 #include "../core/translator/Translator.h"
30 #include "../geometry/Envelope.h"
31 #include "../raster/Grid.h"
32 #include "../raster/RasterFactory.h"
33 #include "../raster/Utils.h"
34 #include "Band.h"
35 #include "Exception.h"
36 #include "Raster.h"
37 #include "TiledBand.h"
38 
39 // STL
40 #include <cassert>
41 #include <memory>
42 
43 // Boost
44 #include <boost/lexical_cast.hpp>
45 
46 te::mem::Raster::Raster() : m_deleter(nullptr), m_externalBuffer(nullptr)
47 {
48 }
49 
51  : te::rst::Raster(rhs),
52  m_deleter(nullptr),
53  m_externalBuffer(nullptr)
54 {
55  const std::size_t nbands = rhs.m_bands.size();
56 
57  for(std::size_t i = 0; i < nbands; ++i)
58  {
59  const TiledBand* tband = dynamic_cast<const TiledBand*>(rhs.m_bands[i]);
60 
61  if(tband)
62  {
63  TiledBand* ntband = new TiledBand(*tband);
64  ntband->setRaster(this);
65  m_bands.push_back(ntband);
66  }
67  else
68  {
69  const Band* band = static_cast<const Band*>(rhs.m_bands[i]);
70  Band* nband = new Band(*band);
71  nband->setRaster(this);
72  m_bands.push_back(nband);
73  }
74  }
75 }
76 
78 {
79  close();
80 }
81 
82 void te::mem::Raster::open(const std::map<std::string, std::string>& rinfo, te::common::AccessPolicy p)
83 {
84 // assure we are in a closed state
85  close();
86 
87 // open input
88  std::map<std::string, std::string>::const_iterator it = rinfo.find("MEM_SRC_RASTER_DRIVER_TYPE");
89  std::map<std::string, std::string>::const_iterator itend = rinfo.end();
90 
91  std::unique_ptr<te::rst::Raster> iraster;
92 
93 // see if input raster comes from default driver or a specific one
94  if(it != itend)
95  {
96  iraster.reset(te::rst::RasterFactory::open(it->second, rinfo, p));
97  }
98  else
99  {
100  iraster.reset(te::rst::RasterFactory::open(rinfo, p));
101  }
102 
103 // see if we must create a tiled raster or not
104  bool isTiled = false;
105 
106  it = rinfo.find("MEM_TILED_RASTER");
107 
108  if((it != itend) &&
109  (te::common::Convert2UCase(it->second) == "TRUE"))
110  isTiled = true;
111 
112 // determine the block data width, height and the number of data blocks in each dimension
113  int blkw = iraster->getNumberOfColumns();
114  int blkh = iraster->getNumberOfRows();
115  int nblksx = 1;
116  int nblksy = 1;
117 
118  if(isTiled)
119  {
120  it = rinfo.find("MEM_TILE_WIDTH");
121 
122  if(it != itend)
123  {
124  blkw = boost::lexical_cast<int>(it->second);
125 
126  it = rinfo.find("MEM_TILE_HEIGHT");
127 
128  if(it == itend)
129  throw Exception(TE_TR("You must provide the MEM_TILE_HEIGHT parameter"));
130 
131  blkh = boost::lexical_cast<int>(it->second);
132 
133  nblksx = (iraster->getNumberOfColumns() + blkw - 1) / blkw;
134  nblksy = (iraster->getNumberOfRows() + blkh - 1) / blkh;
135  }
136  else
137  {
138  it = rinfo.find("MEM_TILE_HEIGHT");
139 
140  if(it != itend)
141  {
142  throw Exception(TE_TR("You must provide the MEM_TILE_WIDTH parameter"));
143  }
144  else
145  {
146  if((iraster->getBand(0) == nullptr) || (iraster->getBand(0)->getProperty() == nullptr))
147  throw Exception(TE_TR("It is not possible to determine the in-memory raster tile dimension because the input raster doesn't have enough information!"));
148 
149  blkw = iraster->getBand(0)->getProperty()->m_blkw;
150  blkh = iraster->getBand(0)->getProperty()->m_blkh;
151  nblksx = iraster->getBand(0)->getProperty()->m_nblocksx;
152  nblksy = iraster->getBand(0)->getProperty()->m_nblocksy;
153  }
154  }
155  }
156 
157 // clone the grid from the input raster
158  m_grid = new te::rst::Grid(*iraster->getGrid());
159 
160 // create the raster bands
161  const std::size_t nbands = iraster->getNumberOfBands();
162 
163  for(std::size_t b = 0; b < nbands; ++b)
164  {
165  te::rst::Band* iband = iraster->getBand(b);
166  te::rst::BandProperty* ibprop = iband->getProperty();
167 
168  std::unique_ptr<te::rst::BandProperty> bprop(new te::rst::BandProperty(*ibprop));
169  bprop->m_blkh = blkh;
170  bprop->m_blkw = blkw;
171  bprop->m_nblocksx = nblksx;
172  bprop->m_nblocksy = nblksy;
173 
174  if(isTiled)
175  {
176 // things may have changed since we found out it is a tiled raster!
177  m_bands.push_back(new te::mem::TiledBand(this, bprop.release(), b));
178  }
179  else
180  {
181  m_bands.push_back(new te::mem::Band(this, bprop.release(), b));
182  }
183  }
184 
185 // set the access policy
186  m_policy = p;
187 
188 // copy band data from input raster
189  te::rst::Copy(*iraster, *this);
190 }
191 
192 std::map<std::string, std::string> te::mem::Raster::getInfo() const
193 {
194  return std::map<std::string, std::string>();
195 }
196 
198 {
199  return m_bands.size();
200 }
201 
202 int te::mem::Raster::getBandDataType(std::size_t i) const
203 {
204  assert(i < getNumberOfBands());
205 
206  return m_bands[i]->getProperty()->getType();
207 }
208 
209 const te::rst::Band* te::mem::Raster::getBand(std::size_t i) const
210 {
211  return m_bands[i];
212 }
213 
215 {
216  return m_bands[i];
217 }
218 
219 const te::rst::Band& te::mem::Raster::operator[](std::size_t i) const
220 {
221  return *m_bands[i];
222 }
223 
225 {
226  return *m_bands[i];
227 }
228 
230 {
231  return new Raster(*this);
232 }
233 
235 {
237 
238  m_bands.clear();
239 
240  if(m_deleter)
241  {
243  m_externalBuffer = nullptr;
244  m_deleter = nullptr;
245  }
246 
247  delete m_grid;
248  m_grid = nullptr;
249 
250  m_name.clear();
251 }
252 
254  const std::vector<te::rst::BandProperty*> bands,
255  const std::map<std::string, std::string>& rinfo,
256  void* h, void (*deleter)(void*))
257 {
258 // assure we are in a closed state
259  close();
260 
261  std::map<std::string, std::string>::const_iterator it;
262  std::map<std::string, std::string>::const_iterator itend = rinfo.end();
263 
264  m_deleter = deleter;
265 
266 // how to create the raster?
267  if(g != nullptr && !bands.empty())
268  {
269 // define grid information
270  m_grid = g;
271 
272 // define policy
274 
275  if(h)
276  {
277  bool isRaster = true;
278 
279  it = rinfo.find("MEM_IS_DATA_BUFFER");
280 
281  if((it != itend) &&
282  (te::common::Convert2UCase(it->second) == "TRUE"))
283  isRaster = false;
284 
285  if(isRaster)
286  {
287  te::rst::Raster* iraster = static_cast<te::rst::Raster*> (h);
288 
289  if (iraster == nullptr)
290  {
291  delete m_grid;
292  m_grid = nullptr;
293 
295 
296  throw Exception(TE_TR("You must provide a valid input raster in the 'h' parameter"));
297  }
298 
299 // copy raster bands
300  const std::size_t nbands = bands.size();
301 
302  bool isTiled = false;
303 
304  if (bands[0]->m_nblocksx > 1 || bands[0]->m_nblocksy > 1)
305  isTiled = true;
306 
307  for(std::size_t b = 0; b < nbands; ++b)
308  {
309  if(isTiled)
310  m_bands.push_back(new te::mem::TiledBand(this, bands[b], b));
311  else
312  m_bands.push_back(new te::mem::Band(this, bands[b], b));
313  }
314 
315  te::rst::Copy(*iraster, *this);
316  }
317  else
318  {
319 // define policy
321 
322 // create bands
323  for(std::size_t b = 0; b < bands.size(); ++b)
324  {
325  te::rst::BandProperty* ibprop = new te::rst::BandProperty(b, bands[b]->getType());
326 
327  ibprop->m_blkh = m_grid->getNumberOfRows();
328  ibprop->m_blkw = m_grid->getNumberOfColumns();
329  ibprop->m_nblocksx = 1;
330  ibprop->m_nblocksy = 1;
331 
332  unsigned blksize = m_grid->getNumberOfRows() * m_grid->getNumberOfColumns() * te::rst::GetPixelSize(bands[b]->getType());
333 
334  void* externalBuffer = (unsigned char*) h + (b * blksize);
335 
336  m_bands.push_back(new te::mem::Band(this, ibprop, b, externalBuffer));
337  }
338  }
339  }
340  else
341  {
342 // create bands
343  if (bands[0]->m_nblocksx > 1 || bands[0]->m_nblocksy > 1)
344  {
345 // is tiled
346  for(std::size_t b = 0; b < bands.size(); ++b)
347  {
348  if (bands[b]->m_blkw == 0 || bands[b]->m_blkh == 0)
349  {
350  delete m_grid;
351  m_grid = nullptr;
352 
354 
355  throw Exception(TE_TR("You must provide the parameters of block height and width"));
356  }
357 
358  m_bands.push_back(new te::mem::TiledBand(this, bands[b], b));
359  }
360  }
361  else
362  {
363 // is not tiled
364  for(std::size_t b = 0; b < bands.size(); ++b)
365  {
366  bands[b]->m_blkh = m_grid->getNumberOfRows();
367  bands[b]->m_blkw = m_grid->getNumberOfColumns();
368  bands[b]->m_nblocksx = 1;
369  bands[b]->m_nblocksy = 1;
370 
371  m_bands.push_back(new te::mem::Band(this, bands[b], b));
372  }
373  }
374  }
375  }
376  else if(h != nullptr)
377  {
378  bool isRaster = true;
379 
380  it = rinfo.find("MEM_IS_DATA_BUFFER");
381 
382  if((it != itend) &&
383  (te::common::Convert2UCase(it->second) == "TRUE"))
384  isRaster = false;
385 
386  if(isRaster)
387  {
388  te::rst::Raster* iraster = static_cast<te::rst::Raster*> (h);
389 
390  if (iraster == nullptr)
391  throw Exception(TE_TR("You must provide a valid input raster in the 'h' parameter"));
392 
393 // clone the grid from the input raster
394  m_grid = new te::rst::Grid(*iraster->getGrid());
395 
396 // create the raster bands
397  const std::size_t nbands = iraster->getNumberOfBands();
398 
399  bool isTiled = false;
400 
401  if (iraster->getBand(0)->getProperty()->m_nblocksx > 1 || iraster->getBand(0)->getProperty()->m_nblocksy > 1)
402  isTiled = true;
403 
404  for(std::size_t b = 0; b < nbands; ++b)
405  {
406  te::rst::Band* iband = iraster->getBand(b);
407  te::rst::BandProperty* ibprop = iband->getProperty();
408 
409  std::unique_ptr<te::rst::BandProperty> bprop(new te::rst::BandProperty(*ibprop));
410 
411  if(isTiled)
412  m_bands.push_back(new te::mem::TiledBand(this, bprop.release(), b));
413  else
414  m_bands.push_back(new te::mem::Band(this, bprop.release(), b));
415  }
416 
417  te::rst::Copy(*iraster, *this);
418  }
419  else
420  {
421 // h is a buffer
422 
423 // get number of rows
424  it = rinfo.find("MEM_BUFFER_NROWS");
425 
426  if(it == itend)
427  throw Exception(TE_TR("You must provide the MEM_BUFFER_NROWS parameter"));
428 
429  unsigned int nrows = boost::lexical_cast<unsigned>(it->second);
430 
431 // get number of columns
432  it = rinfo.find("MEM_BUFFER_NCOLS");
433 
434  if(it == itend)
435  throw Exception(TE_TR("You must provide the MEM_BUFFER_NCOLS parameter"));
436 
437  unsigned int ncols = boost::lexical_cast<unsigned>(it->second);
438 
439 // get bands data type
440  it = rinfo.find("MEM_BUFFER_DATATYPE");
441 
442  if(it == itend)
443  throw Exception(TE_TR("You must provide the MEM_BUFFER_DATATYPE parameter"));
444 
445  unsigned int dt = boost::lexical_cast<unsigned>(it->second);
446 
447 // get number of bands
448  it = rinfo.find("MEM_BUFFER_NBANDS");
449 
450  if(it == itend)
451  throw Exception(TE_TR("You must provide the MEM_BUFFER_NBANDS parameter"));
452 
453  unsigned int nbands = boost::lexical_cast<unsigned>(it->second);
454 
455 // get the srid
456  it = rinfo.find("MEM_BUFFER_SRID");
457 
458  int srid = -1;
459 
460  if(it != itend)
461  srid = boost::lexical_cast<unsigned>(it->second);
462 
463 // get bouding box
464  double minx = 0.0,
465  miny = 0.0,
466  maxx = nrows - 1,
467  maxy = ncols - 1,
468  resx = 1.0,
469  resy = 1.0;
470 
471 // get min-x bounding box
472  it = rinfo.find("MEM_BUFFER_MIN_X");
473 
474  if(it != itend)
475  {
476  minx = boost::lexical_cast<double>(it->second);
477 
478 // get min-y bounding box
479  it = rinfo.find("MEM_BUFFER_MIN_Y");
480 
481  if(it == itend)
482  throw Exception(TE_TR("You must provide the MEM_BUFFER_MIN_Y parameter"));
483 
484  miny = boost::lexical_cast<double>(it->second);
485 
486 // get max-x bounding box
487  it = rinfo.find("MEM_BUFFER_MAX_X");
488 
489  if(it == itend)
490  throw Exception(TE_TR("You must provide the MEM_BUFFER_MAX_X parameter"));
491 
492  maxx = boost::lexical_cast<double>(it->second);
493 
494 // get max-y bounding box
495  it = rinfo.find("MEM_BUFFER_MAX_Y");
496 
497  if(it == itend)
498  throw Exception(TE_TR("You must provide the MEM_BUFFER_MAX_Y parameter"));
499 
500  maxy = boost::lexical_cast<double>(it->second);
501 
502 // get x resolution
503  it = rinfo.find("MEM_BUFFER_RES_X");
504 
505  if(it == itend)
506  throw Exception(TE_TR("You must provide the MEM_BUFFER_RES_X parameter"));
507 
508  resx = boost::lexical_cast<double>(it->second);
509 
510 // get y resolution
511  it = rinfo.find("MEM_BUFFER_RES_Y");
512 
513  if(it == itend)
514  throw Exception(TE_TR("You must provide the MEM_BUFFER_RES_Y parameter"));
515 
516  resy = boost::lexical_cast<double>(it->second);
517  }
518 
519 // define grid information
520  te::gm::Envelope* mbr = new te::gm::Envelope(minx, miny, maxx, maxy);
521  m_grid = new te::rst::Grid(ncols, nrows, resx, resy, mbr, srid);
522 
523 // define policy
525 
526 // create bands
527  for(std::size_t b = 0; b < nbands; ++b)
528  {
529  te::rst::BandProperty* ibprop = new te::rst::BandProperty(b, dt);
530 
531  ibprop->m_blkh = nrows;
532  ibprop->m_blkw = ncols;
533  ibprop->m_nblocksx = 1;
534  ibprop->m_nblocksy = 1;
535 
536  unsigned blksize = ncols * nrows * te::rst::GetPixelSize(dt);
537 
538  void* externalBuffer = (unsigned char*) h + (b * blksize);
539 
540  m_bands.push_back(new te::mem::Band(this, ibprop, b, externalBuffer));
541  }
542  }
543  }
544 // grid and band paramteres were omitted, and no external buffer was provided
545  else if(!rinfo.empty())
546  {
547  it = rinfo.find("MEM_RASTER_NROWS");
548 
549  if(it != itend)
550  {
551 // mandatory parameters
552 
553 // get number of rows
554  unsigned int nrows = boost::lexical_cast<unsigned>(it->second);
555 
556 // get number of columns
557  it = rinfo.find("MEM_RASTER_NCOLS");
558 
559  if(it == itend)
560  throw Exception(TE_TR("You must provide the MEM_RASTER_NCOLS parameter"));
561 
562  unsigned int ncols = boost::lexical_cast<unsigned>(it->second);
563 
564 // get the raster data type
565  it = rinfo.find("MEM_RASTER_DATATYPE");
566 
567  if(it == itend)
568  throw Exception(TE_TR("You must provide the MEM_RASTER_DATATYPE parameter"));
569 
570  int dt = boost::lexical_cast<int>(it->second);
571 
572 // get number of bands
573  it = rinfo.find("MEM_RASTER_NBANDS");
574 
575  if(it == itend)
576  throw Exception(TE_TR("You must provide the MEM_RASTER_NBANDS parameter"));
577 
578  unsigned int nbands = boost::lexical_cast<unsigned>(it->second);
579 
580 // optional parameters
581 
582 // get srid
583  it = rinfo.find("MEM_RASTER_SRID");
584 
585  int srid = -1;
586 
587  if(it != itend)
588  srid = boost::lexical_cast<int>(it->second);
589 
590 // get bouding box
591  double minx = 0.0,
592  miny = 0.0,
593  maxx = nrows - 1.0,
594  maxy = ncols - 1.0,
595  resx = 1.0,
596  resy = 1.0;
597 
598 // get min-x bounding box
599  it = rinfo.find("MEM_RASTER_MIN_X");
600 
601  if(it != itend)
602  {
603  minx = boost::lexical_cast<double>(it->second);
604 
605 // get min-y bounding box
606  it = rinfo.find("MEM_RASTER_MIN_Y");
607 
608  if(it == itend)
609  throw Exception(TE_TR("You must provide the MEM_RASTER_MIN_Y parameter"));
610 
611  miny = boost::lexical_cast<double>(it->second);
612 
613 // get max-x bounding box
614  it = rinfo.find("MEM_RASTER_MAX_X");
615 
616  if(it == itend)
617  throw Exception(TE_TR("You must provide the MEM_RASTER_MAX_X parameter"));
618 
619  maxx = boost::lexical_cast<double>(it->second);
620 
621 // get max-y bounding box
622  it = rinfo.find("MEM_RASTER_MAX_Y");
623 
624  if(it == itend)
625  throw Exception(TE_TR("You must provide the MEM_RASTER_MAX_Y parameter"));
626 
627  maxy = boost::lexical_cast<double>(it->second);
628 
629 // get x resolution
630  it = rinfo.find("MEM_RASTER_RES_X");
631 
632  if(it == itend)
633  throw Exception(TE_TR("You must provide the MEM_RASTER_RES_X parameter"));
634 
635  resx = boost::lexical_cast<double>(it->second);
636 
637 // get y resolution
638  it = rinfo.find("MEM_RASTER_RES_Y");
639 
640  if(it == itend)
641  throw Exception(TE_TR("You must provide the MEM_RASTER_RES_Y parameter"));
642 
643  resy = boost::lexical_cast<double>(it->second);
644  }
645 
646 // define grid information
647  te::gm::Envelope* mbr = new te::gm::Envelope(minx, miny, maxx, maxy);
648  m_grid = new te::rst::Grid(ncols, nrows, resx, resy, mbr, srid);
649 
650 // define policy
652 
653 // create bands
654 
655 // see if we must create a tiled raster or not
656  bool isTiled = false;
657 
658  it = rinfo.find("MEM_TILED_RASTER");
659 
660  if((it != itend) &&
661  (te::common::Convert2UCase(it->second) == "TRUE"))
662  isTiled = true;
663 
664 // determine the block data width, height and the number of data blocks in each dimension
665  int blkw = ncols;
666  int blkh = nrows;
667  int nblksx = 1;
668  int nblksy = 1;
669 
670  if(isTiled)
671  {
672  it = rinfo.find("MEM_TILE_WIDTH");
673 
674  if(it == itend)
675  throw Exception(TE_TR("You must provide the MEM_TILE_WIDTH parameter"));
676 
677  blkw = boost::lexical_cast<int>(it->second);
678 
679  it = rinfo.find("MEM_TILE_HEIGHT");
680 
681  if(it == itend)
682  throw Exception(TE_TR("You must provide the MEM_TILE_HEIGHT parameter"));
683 
684  blkh = boost::lexical_cast<int>(it->second);
685 
686  nblksx = (ncols + blkw - 1) / blkw;
687  nblksy = (nrows + blkh - 1) / blkh;
688  }
689 
690  for(std::size_t b = 0; b < nbands; ++b)
691  {
692  te::rst::BandProperty* ibprop = new te::rst::BandProperty(b, dt);
693 
694  ibprop->m_blkh = blkh;
695  ibprop->m_blkw = blkw;
696  ibprop->m_nblocksx = nblksx;
697  ibprop->m_nblocksy = nblksy;
698 
699  if(isTiled)
700  m_bands.push_back(new te::mem::TiledBand(this, ibprop, b));
701  else
702  m_bands.push_back(new te::mem::Band(this, ibprop, b));
703  }
704  }
705  }
706  else
707  {
708  throw Exception(TE_TR("You must provide enough parameters"));
709  }
710 }
unsigned int getNumberOfRows() const
Returns the grid number of rows.
unsigned int band
A raster class for memory.
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
~Raster()
Virtual destructor.
A raster band description.
Definition: BandProperty.h:61
Base exception class for plugin module.
A tiled band implementation for the In-Memory Raster.
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
void setRaster(Raster *r)
Definition: TiledBand.cpp:240
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
An exception class for the TerraLib In-Memory Data Access driver.
TERASTEREXPORT void Copy(const Raster &rin, Raster &rout)
Copies the pixel values from one raster to another.
std::vector< te::rst::Band * > m_bands
The list of data bands.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:168
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
std::string m_name
The raster name.
Grid * m_grid
The spatial support for raster data.
AccessPolicy
Supported data access policies (can be used as bitfield).
int b
Definition: TsRtree.cpp:32
A raster class for memory.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
BandProperty * getProperty()
Returns the band property.
URI C++ Library.
Definition: Attributes.h:37
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
static te::dt::TimeDuration dt(20, 30, 50, 11)
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
te::dt::AbstractData * clone() const
It returns a clone of this object.
list bands
Definition: compose.py:2
void(* m_deleter)(void *)
A pointer to a deleter function, if the buffer needs to be deleted by this object.
te::gm::Polygon * p
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
A raster band description.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
Grid * getGrid()
It returns the raster grid.
TERASTEREXPORT int GetPixelSize(int datatype)
Returns the byte size of a given datatype.
Band implementation for the In-Memory Raster.
const te::rst::Band & operator[](std::size_t i) const
Access band in i position.
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
void create(te::rst::Grid *g, const std::vector< te::rst::BandProperty * > bands, const std::map< std::string, std::string > &rinfo, void *h, void(*deleter)(void *))
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
A rectified grid is the spatial support for raster data.
Definition: raster/Grid.h:68
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
te::common::AccessPolicy m_policy
The access policy, can be te::common::{NoAccess, RAccess, RWAccess, WAccess}.
int getBandDataType(std::size_t i) const
Returns the data type in a particular band (or dimension).
static Raster * open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
It opens a raster with the given parameters and default raster driver.
void * m_externalBuffer
An external buffer.