All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IdlRaster.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/idl/IdlRaster.cpp
22 
23  \brief A adaptor to an external existent raster in a idl array form.
24 */
25 
26 #include "Exception.h"
27 #include "IdlRaster.h"
28 #include "IdlBand.h"
29 #include "Functions.h"
30 
31 #include "../common/Translator.h"
32 #include "../raster/Utils.h"
33 
35 {
36  throw te::idl::Exception( "Not implemented" );
37 }
38 
40 : te::rst::Raster( grid, p )
41 {
42  throw te::idl::Exception( "Not implemented" );
43 }
44 
46 : te::rst::Raster( rhs )
47 {
48  throw te::idl::Exception( "Not implemented" );
49 }
50 
51 te::idl::IdlRaster::IdlRaster( const IDL_VPTR& idlValuePointer,
52  const bool takeBufferOwnership )
53  : m_takeBufferOwnership( takeBufferOwnership )
54 {
55  if( ! ( idlValuePointer->flags & IDL_V_ARR) )
56  {
57  throw te::idl::Exception( "Invalid IDL value pointer" );
58  }
59  else
60  {
61  unsigned int nLines = 0;
62  unsigned int nCols = 0;
63  unsigned int nBands = 0;
64 
65  if( idlValuePointer->value.arr->n_dim == 2 )
66  {
67  nLines = (unsigned int)idlValuePointer->value.arr->dim[ 1 ];
68  nCols = (unsigned int)idlValuePointer->value.arr->dim[ 0 ];
69  nBands = 1;
70  }
71  else if( idlValuePointer->value.arr->n_dim == 3 )
72  {
73  nLines = (unsigned int)idlValuePointer->value.arr->dim[ 2 ];
74  nCols = (unsigned int)idlValuePointer->value.arr->dim[ 1 ];
75  nBands = (unsigned int)idlValuePointer->value.arr->dim[ 0 ];
76  }
77  else
78  {
79  throw te::idl::Exception( "Invalid IDL value pointer" );
80  }
81 
82  m_dataType = te::idl::idl2TerralibType( idlValuePointer->type );
83  m_allBandsDataPtr = (unsigned char*)idlValuePointer->value.arr->data;
84 
85  m_grid = new te::rst::Grid( nCols, nLines );
86 
88 
89  for( unsigned int bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
90  {
91  m_bands.push_back( new te::idl::IdlBand( this, m_allBandsDataPtr,
92  bandIdx, m_dataType, nBands, nLines, nCols ) );
93  }
94  }
95 }
96 
98 {
99  if( m_takeBufferOwnership ) delete[] m_allBandsDataPtr;
100 
101  std::vector< te::idl::IdlBand* >::iterator bandsIt = m_bands.begin();
102  std::vector< te::idl::IdlBand* >::iterator bandsItEnd = m_bands.end();
103 
104  while( bandsIt != bandsItEnd )
105  {
106  delete (*bandsIt);
107  ++bandsIt;
108  }
109 }
110 
111 void te::idl::IdlRaster::open(const std::map<std::string, std::string>& rinfo,
113 {
114  throw te::idl::Exception( "Not implemented" );
115 }
116 
117 std::map<std::string, std::string> te::idl::IdlRaster::getInfo() const
118 {
119  throw te::idl::Exception( "Not implemented" );
120 };
121 
122 
124 {
125  throw te::idl::Exception( "Not implemented" );
126 }
127 
A adaptor to an external existent raster in a idl array form.
A adaptor to an external existent raster in a idl array form.
int m_dataType
Data type used by all bands.
Definition: IdlRaster.h:126
IDL module functions.
std::vector< te::idl::IdlBand * > m_bands
Internal raster bands.
Definition: IdlRaster.h:128
Grid * m_grid
The spatial support for raster data.
Definition: Raster.h:681
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
Definition: IdlRaster.cpp:111
An abstract class for raster data strucutures.
Definition: Raster.h:71
A adaptor to an external existent raster in a idl array form.
Definition: IdlBand.h:51
unsigned char * m_allBandsDataPtr
Data buffer pointer.
Definition: IdlRaster.h:122
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
Exception class.
te::dt::AbstractData * clone() const
It returns a clone of this object.
Definition: IdlRaster.cpp:123
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
Definition: IdlRaster.cpp:117
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
te::common::AccessPolicy m_policy
The access policy, can be te::common::{NoAccess, RAccess, RWAccess, WAccess}.
Definition: Raster.h:682
int idl2TerralibType(const UCHAR &idlType)
Convert IDL data types to Terralib data types.
Definition: Functions.cpp:38