OTB  9.0.0
Orfeo Toolbox
otbVectorDataAdapter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbVectorDataAdapterFilter_hxx
22 #define otbVectorDataAdapterFilter_hxx
23 
24 #include "otbVectorDataAdapter.h"
25 
26 namespace otb
27 {
28 
32 template <class TInputVectorData, class TOutputVectorData>
35 {
36 
37  OutputPointType point;
38  point[0] = pointCoord[0];
39  point[1] = pointCoord[1];
40  if (OutputPointType::PointDimension == 3)
41  {
42  point[2] = pointCoord[2];
43  }
44  return point;
45 }
46 
50 template <class TInputVectorData, class TOutputVectorData>
53 {
54  typedef typename InputLineType::VertexListType::ConstPointer VertexListConstPointerType;
55  typedef typename InputLineType::VertexListConstIteratorType VertexListConstIteratorType;
56  VertexListConstPointerType vertexList = line->GetVertexList();
57  VertexListConstIteratorType it = vertexList->Begin();
58  typename OutputLineType::Pointer newLine = OutputLineType::New();
59  while (it != vertexList->End())
60  {
61  typename OutputLineType::VertexType index;
62  typename InputLineType::VertexType pointCoord = it.Value();
63  index[0] = pointCoord[0];
64  index[1] = pointCoord[1];
66 
67  // fixme handle 2.5D ?
68 
69  newLine->AddVertex(index);
70  ++it;
71  }
72 
73  return newLine;
74 }
75 
79 template <class TInputVectorData, class TOutputVectorData>
82 {
83  typedef typename InputPolygonType::VertexListType::ConstPointer VertexListConstPointerType;
84  typedef typename InputPolygonType::VertexListConstIteratorType VertexListConstIteratorType;
85  VertexListConstPointerType vertexList = polygon->GetVertexList();
86  VertexListConstIteratorType it = vertexList->Begin();
87  typename OutputPolygonType::Pointer newPolygon = OutputPolygonType::New();
88  while (it != vertexList->End())
89  {
90  typename OutputPolygonType::VertexType index;
91  typename InputPolygonType::VertexType pointCoord = it.Value();
92  index[0] = pointCoord[0];
93  index[1] = pointCoord[1];
95 
96  // fixme handle 2.5D ?
97 
98  newPolygon->AddVertex(index);
99  ++it;
100  }
101  return newPolygon;
102 }
103 
107 template <class TInputVectorData, class TOutputVectorData>
110 {
111 
112  OutputPolygonListPointerType newPolygonList = OutputPolygonListType::New();
113  for (typename InputPolygonListType::ConstIterator it = polygonList->Begin(); 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
otb::VectorDataAdapter::ProcessPolygonList
OutputPolygonListPointerType ProcessPolygonList(InputPolygonListPointerType polygonList) const override
Definition: otbVectorDataAdapter.hxx:109
otb::VectorDataAdapter::OutputPolygonPointerType
OutputPolygonType::Pointer OutputPolygonPointerType
Definition: otbVectorDataAdapter.h:74
otb::VectorDataAdapter::ProcessLine
OutputLinePointerType ProcessLine(InputLinePointerType line) const override
Definition: otbVectorDataAdapter.hxx:52
otb::VectorDataAdapter::ProcessPolygon
OutputPolygonPointerType ProcessPolygon(InputPolygonPointerType polygon) const override
Definition: otbVectorDataAdapter.hxx:81
otb::VectorDataAdapter::InputPointType
InputDataNodeType::PointType InputPointType
Definition: otbVectorDataAdapter.h:59
otbVectorDataAdapter.h
otb::VectorDataAdapter::OutputLinePointerType
OutputLineType::Pointer OutputLinePointerType
Definition: otbVectorDataAdapter.h:73
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::VectorDataAdapter::InputLinePointerType
InputLineType::Pointer InputLinePointerType
Definition: otbVectorDataAdapter.h:64
otb::VectorDataAdapter::OutputPointType
OutputDataNodeType::PointType OutputPointType
Definition: otbVectorDataAdapter.h:68
otb::VectorDataAdapter::ProcessPoint
OutputPointType ProcessPoint(InputPointType point) const override
Definition: otbVectorDataAdapter.hxx:34
otb::VectorDataAdapter::InputPolygonListPointerType
InputPolygonListType::Pointer InputPolygonListPointerType
Definition: otbVectorDataAdapter.h:66
otb::VectorDataAdapter::InputPolygonPointerType
InputPolygonType::Pointer InputPolygonPointerType
Definition: otbVectorDataAdapter.h:65
otb::VectorDataAdapter::OutputPolygonListPointerType
OutputPolygonListType::Pointer OutputPolygonListPointerType
Definition: otbVectorDataAdapter.h:75