Orfeo Toolbox  4.0
otbGISTableToVectorDataFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbGISTableToVectorDataFilter_txx
19 #define __otbGISTableToVectorDataFilter_txx
20 
22 //#include "itkNumericTraits.h"
23 //#include "itkProgressReporter.h"
24 //#include "itkImageRegionConstIteratorWithIndex.h"
25 //#include "otbGISTable.h"
26 
27 namespace otb {
28 
29 template<class TGISTable, class TVectorData>
32 { /*
33  m_BackgroundValue = NumericTraits<OutputImagePixelType>::NonpositiveMin(); */
34  m_Reader = VectorDataFileReaderType::New();
35 }
36 
37 template<class TGISTable, class TVectorData>
38 void
41 {
42 // Process object is not const-correct so the const_cast is required here
44  const_cast<InputGISTableType *>(input));
45 }
46 
47 template<class TGISTable, class TVectorData>
48 void
50 ::SetInput(unsigned int idx, const InputGISTableType *input)
51 {
52  // Process object is not const-correct so the const_cast is required here
54  const_cast<InputGISTableType *>(input));
55 }
56 
57 template<class TGISTable, class TVectorData>
61 {
62  if (this->GetNumberOfInputs() < 1)
63  {
64  return 0;
65  }
66 
67  return static_cast<const TGISTable *>
69 }
70 
71 template<class TGISTable, class TVectorData>
74 ::GetInput(unsigned int idx)
75 {
76  return static_cast<const TGISTable *>
77  (this->itk::ProcessObject::GetInput(idx));
78 }
79 
80 template<class TGISTable, class TVectorData>
81 void
84 { /*
85  // call the superclass' implementation of this method
86  Superclass::GenerateInputRequestedRegion();
87 
88  // We need all the input.
89  InputImagePointer input = const_cast<InputImageType *>(this->GetInput());
90  if ( !input )
91  { return; }
92  input->SetRequestedRegion( input->GetLargestPossibleRegion() ); */
93 }
94 
95 /*
96 template<class TGISTable, class TVectorData >
97 void
98 GISTableToVectorDataFilter<TGISTable, TVectorData>
99 ::EnlargeOutputRequestedRegion(DataObject *)
100 {
101  this->GetOutput()
102  ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
103 }
104 */
105 
106 template<class TGISTable, class TVectorData>
107 void
110 {
111 
112  // Allocate the output
113  //this->AllocateOutputs();
114 
115  OutputVectorDataType * output = this->GetOutput();
116  const InputGISTableType * input = this->GetInput();
117 
119 // DataNodePointerType document = DataNodeType::New();
120 // DataNodePointerType folder1 = DataNodeType::New();
121 //
122 // document->SetNodeType(DOCUMENT);
123 // folder1->SetNodeType(FOLDER);
124 //
125 // DataNodePointerType root = output->GetDataTree()->GetRoot()->Get();
126 //
127 // output->GetDataTree()->Add(document, root);
128 // output->GetDataTree()->Add(folder1, document);
129 
130  OGRVectorDataIOPointerType gisReader = OGRVectorDataIOType::New();
131 
132  const std::string inputOGRConnStr = input->GetOGRStrConnection();
133  //Try if the Db is readable
134 // std::cout << "ogr connection: " << inputOGRConnStr[0] << std::endl;
135  if (gisReader->CanReadFile(inputOGRConnStr.data()))
136  {
137  //Read GISTable data and copy in the output VectorData
138 
139  gisReader->SetFileName(inputOGRConnStr);
140 // std::cout << "read ogr!!: " << inputOGRConnStr << std::endl;
141  gisReader->Read(output);
142  }
143  else
144  {
145  itkExceptionMacro(<< "The OGR connection is not valid; ogrconnection = " << inputOGRConnStr);
146  }
147 
148 // const std::string inputOGRConnStr=input->GetOGRStrConnection();
149 //Try if the Db is readable
150 //std::cout << "ogr connection: " << inputOGRConnStr[0] << std::endl;
151 
152 // m_Reader->SetFileName( inputOGRConnStr.data() );
153 // m_Reader->Update();
154 
155  output = m_Reader->GetOutput();
156 }
157 
158 template<class TGISTable, class TVectorData>
159 void
161 ::PrintSelf(std::ostream& os, itk::Indent indent) const
162 {
163  Superclass::PrintSelf(os, indent);
164 /*
165  os << indent << "BackgroundValue: " << static_cast<typename NumericTraits<OutputImagePixelType>::PrintType>(m_BackgroundValue) << std::endl;
166  */
167 }
168 
169 } // end namespace otb
170 #endif

Generated at Sat Mar 8 2014 15:57:37 for Orfeo Toolbox with doxygen 1.8.3.1