OTB  6.7.0
Orfeo Toolbox
otbPersistentImageToVectorDataFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbPersistentImageToVectorDataFilter_hxx
23 #define otbPersistentImageToVectorDataFilter_hxx
24 
26 
27 namespace otb
28 {
29 
30 template<class TImage, class TOutputVectorData>
33 {
34  m_ExtractFilter = ExtractImageFilterType::New();
35  m_OutputVectorData = OutputVectorDataType::New();
36 
37  m_VectorDataIO = OGRVectorDataIOType::New();
38 }
39 
40 template<class TImage, class TOutputVectorData>
44 {
45  return m_OutputVectorData;
46 }
47 
48 template<class TImage, class TOutputVectorData>
49 void
52 {
53  // Nothing that needs to be allocated for the outputs : the output is not meant to be used
54 }
55 
56 template<class TImage, class TOutputVectorData>
57 void
60 {
61  typedef typename OutputVectorDataType::DataNodeType DataNodeType;
62  typedef typename DataNodeType::Pointer DataNodePointerType;
63 
64  this->GetOutputVectorData()->Clear();
65  DataNodePointerType root = DataNodeType::New();
66  root->SetNodeId("Root");
67  this->GetOutputVectorData()->GetDataTree()->SetRoot(root);
68 
69  DataNodePointerType folder = DataNodeType::New();
70  folder->SetNodeType(otb::FOLDER);
71 
72  DataNodePointerType document = DataNodeType::New();
73  document->SetNodeType(otb::DOCUMENT);
74 
75  this->GetOutputVectorData()->GetDataTree()->Add(document, this->GetOutputVectorData()->GetDataTree()->GetRoot()->Get());
76  this->GetOutputVectorData()->GetDataTree()->Add(folder , document);
77 }
78 
79 template<class TImage, class TOutputVectorData>
80 void
83 {
84 
85 }
86 
87 template<class TImage, class TOutputVectorData>
88 void
91 {
92  // call the processing function for this tile
93  OutputVectorDataPointerType currentTileVD = this->ProcessTile();
94 
95  // merge the result into the output vector data object
96  OutputVectorDataPointerType output = GetOutputVectorData();
97 
98 
99  ConcatenateVectorDataFilterPointerType concatenate = ConcatenateVectorDataFilterType::New();
100  concatenate->AddInput(output);
101  concatenate->AddInput(currentTileVD);
102  concatenate->Update();
103 
104  concatenate->GetOutput()->SetMetaDataDictionary(currentTileVD->GetMetaDataDictionary());
105 
106  // copy metadata and reference the same data tree
107  output->Graft( concatenate->GetOutput() );
108 }
109 
110 template<class TImage, class TOutputVectorData>
111 void
113 ::PrintSelf(std::ostream& os, itk::Indent indent) const
114 {
115  Superclass::PrintSelf(os, indent);
116 }
117 
118 } // end namespace otb
119 #endif
void PrintSelf(std::ostream &os, itk::Indent indent) const override