OTB  6.7.0
Orfeo Toolbox
otbVectorDataAdapter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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>
33 typename VectorDataAdapter<TInputVectorData, TOutputVectorData>::OutputPointType
35 ::ProcessPoint(InputPointType pointCoord) const
36 {
37 
38  OutputPointType point;
39  point[0] = pointCoord[0];
40  point[1] = pointCoord[1];
41  if (OutputPointType::PointDimension == 3)
42  {
43  point[2] = pointCoord[2];
44  }
45  return point;
46 }
47 
51 template <class TInputVectorData, class TOutputVectorData>
55 {
56  typedef typename InputLineType::VertexListType::ConstPointer VertexListConstPointerType;
57  typedef typename InputLineType::VertexListConstIteratorType VertexListConstIteratorType;
58  VertexListConstPointerType vertexList = line->GetVertexList();
59  VertexListConstIteratorType it = vertexList->Begin();
60  typename OutputLineType::Pointer newLine = OutputLineType::New();
61  while (it != vertexList->End())
62  {
63  typename OutputLineType::VertexType index;
64  typename InputLineType::VertexType pointCoord = it.Value();
65  index[0] = pointCoord[0];
66  index[1] = pointCoord[1];
68 
69  // fixme handle 2.5D ?
70 
71  newLine->AddVertex(index);
72  ++it;
73  }
74 
75  return newLine;
76 }
77 
81 template <class TInputVectorData, class TOutputVectorData>
85 {
86  typedef typename InputPolygonType::VertexListType::ConstPointer VertexListConstPointerType;
87  typedef typename InputPolygonType::VertexListConstIteratorType VertexListConstIteratorType;
88  VertexListConstPointerType vertexList = polygon->GetVertexList();
89  VertexListConstIteratorType it = vertexList->Begin();
90  typename OutputPolygonType::Pointer newPolygon = OutputPolygonType::New();
91  while (it != vertexList->End())
92  {
93  typename OutputPolygonType::VertexType index;
94  typename InputPolygonType::VertexType pointCoord = it.Value();
95  index[0] = pointCoord[0];
96  index[1] = pointCoord[1];
98 
99  // fixme handle 2.5D ?
100 
101  newPolygon->AddVertex(index);
102  ++it;
103  }
104  return newPolygon;
105 }
106 
110 template <class TInputVectorData, class TOutputVectorData>
114 {
115 
116  OutputPolygonListPointerType newPolygonList = OutputPolygonListType::New();
117  for (typename InputPolygonListType::ConstIterator it = polygonList->Begin();
118  it != polygonList->End(); ++it)
119  {
120  newPolygonList->PushBack(this->ProcessPolygon(it.Get()));
121  }
122  return newPolygonList;
123 }
124 
125 
126 } // end namespace otb
127 
128 #endif
InputPolygonListType::Pointer InputPolygonListPointerType
InputPolygonType::Pointer InputPolygonPointerType
OutputPointType ProcessPoint(InputPointType point) const override
InputDataNodeType::PointType InputPointType
OutputDataNodeType::PointType OutputPointType
OutputPolygonType::Pointer OutputPolygonPointerType
OutputLineType::Pointer OutputLinePointerType
OutputPolygonPointerType ProcessPolygon(InputPolygonPointerType polygon) const override
OutputPolygonListType::Pointer OutputPolygonListPointerType
OutputPolygonListPointerType ProcessPolygonList(InputPolygonListPointerType polygonList) const override
OutputLinePointerType ProcessLine(InputLinePointerType line) const override
InputLineType::Pointer InputLinePointerType