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