Orfeo Toolbox  4.0
otbVectorDataAdapter.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 __otbVectorDataAdapterFilter_txx
19 #define __otbVectorDataAdapterFilter_txx
20 
21 #include "otbVectorDataAdapter.h"
22 
23 namespace otb
24 {
25 
29 template <class TInputVectorData, class TOutputVectorData>
30 typename VectorDataAdapter<TInputVectorData, TOutputVectorData>::OutputPointType
32 ::ProcessPoint(InputPointType pointCoord) const
33 {
34 
35  OutputPointType point;
36  point[0] = pointCoord[0];
37  point[1] = pointCoord[1];
38  if (OutputPointType::PointDimension == 3)
39  {
40  point[2] = pointCoord[2];
41  }
42  return point;
43 }
44 
48 template <class TInputVectorData, class TOutputVectorData>
52 {
53  typedef typename InputLineType::VertexListType::ConstPointer VertexListConstPointerType;
54  typedef typename InputLineType::VertexListConstIteratorType VertexListConstIteratorType;
55  VertexListConstPointerType vertexList = line->GetVertexList();
56  VertexListConstIteratorType it = vertexList->Begin();
57  typename OutputLineType::Pointer newLine = OutputLineType::New();
58  while (it != vertexList->End())
59  {
60  typename OutputLineType::VertexType index;
61  typename InputLineType::VertexType pointCoord = it.Value();
62  index[0] = pointCoord[0];
63  index[1] = pointCoord[1];
64 
65  // fixme handle 2.5D ?
66 
67  newLine->AddVertex(index);
68  ++it;
69  }
70 
71  return newLine;
72 }
73 
77 template <class TInputVectorData, class TOutputVectorData>
81 {
82  typedef typename InputPolygonType::VertexListType::ConstPointer VertexListConstPointerType;
83  typedef typename InputPolygonType::VertexListConstIteratorType VertexListConstIteratorType;
84  VertexListConstPointerType vertexList = polygon->GetVertexList();
85  VertexListConstIteratorType it = vertexList->Begin();
86  typename OutputPolygonType::Pointer newPolygon = OutputPolygonType::New();
87  while (it != vertexList->End())
88  {
89  typename OutputPolygonType::VertexType index;
90  typename InputPolygonType::VertexType pointCoord = it.Value();
91  index[0] = pointCoord[0];
92  index[1] = pointCoord[1];
93 
94  // fixme handle 2.5D ?
95 
96  newPolygon->AddVertex(index);
97  ++it;
98  }
99  return newPolygon;
100 }
101 
105 template <class TInputVectorData, class TOutputVectorData>
109 {
110 
111  OutputPolygonListPointerType newPolygonList = OutputPolygonListType::New();
112  for (typename InputPolygonListType::ConstIterator it = polygonList->Begin();
113  it != polygonList->End(); ++it)
114  {
115  newPolygonList->PushBack(this->ProcessPolygon(it.Get()));
116  }
117  return newPolygonList;
118 }
119 
120 
121 } // end namespace otb
122 
123 #endif

Generated at Sat Mar 8 2014 16:24:26 for Orfeo Toolbox with doxygen 1.8.3.1