OTB  9.0.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-2022 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>
32 {
33  m_ExtractFilter = ExtractImageFilterType::New();
34  m_OutputVectorData = OutputVectorDataType::New();
35 
36  m_VectorDataIO = OGRVectorDataIOType::New();
37 }
38 
39 template <class TImage, class TOutputVectorData>
42 {
43  return m_OutputVectorData;
44 }
45 
46 template <class TImage, class TOutputVectorData>
48 {
49  // Nothing that needs to be allocated for the outputs : the output is not meant to be used
50 }
51 
52 template <class TImage, class TOutputVectorData>
54 {
55  typedef typename OutputVectorDataType::DataNodeType DataNodeType;
56  typedef typename DataNodeType::Pointer DataNodePointerType;
57 
58  this->GetOutputVectorData()->Clear();
59  DataNodePointerType root = DataNodeType::New();
60  root->SetNodeId("Root");
61  this->GetOutputVectorData()->GetDataTree()->SetRoot(root);
62 
63  DataNodePointerType folder = DataNodeType::New();
64  folder->SetNodeType(otb::FOLDER);
65 
66  DataNodePointerType document = DataNodeType::New();
67  document->SetNodeType(otb::DOCUMENT);
68 
69  this->GetOutputVectorData()->GetDataTree()->Add(document, this->GetOutputVectorData()->GetDataTree()->GetRoot()->Get());
70  this->GetOutputVectorData()->GetDataTree()->Add(folder, document);
71 }
72 
73 template <class TImage, class TOutputVectorData>
75 {
76 }
77 
78 template <class TImage, class TOutputVectorData>
80 {
81  // call the processing function for this tile
82  OutputVectorDataPointerType currentTileVD = this->ProcessTile();
83 
84  // merge the result into the output vector data object
85  OutputVectorDataPointerType output = GetOutputVectorData();
86 
87 
88  ConcatenateVectorDataFilterPointerType concatenate = ConcatenateVectorDataFilterType::New();
89  concatenate->AddInput(output);
90  concatenate->AddInput(currentTileVD);
91  concatenate->Update();
92 
93  concatenate->GetOutput()->SetMetaDataDictionary(currentTileVD->GetMetaDataDictionary());
94 
95  // copy metadata and reference the same data tree
96  output->Graft(concatenate->GetOutput());
97 }
98 
99 template <class TImage, class TOutputVectorData>
100 void PersistentImageToVectorDataFilter<TImage, TOutputVectorData>::PrintSelf(std::ostream& os, itk::Indent indent) const
101 {
102  Superclass::PrintSelf(os, indent);
103 }
104 
105 } // end namespace otb
106 #endif
otb::PersistentImageToVectorDataFilter::Reset
void Reset(void) override
Definition: otbPersistentImageToVectorDataFilter.hxx:53
otb::DOCUMENT
@ DOCUMENT
Definition: otbDataNode.h:41
otb::PersistentImageToVectorDataFilter::PersistentImageToVectorDataFilter
PersistentImageToVectorDataFilter()
Definition: otbPersistentImageToVectorDataFilter.hxx:31
otb::DataNode
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:73
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbPersistentImageToVectorDataFilter.h
otb::FOLDER
@ FOLDER
Definition: otbDataNode.h:42
otb::PersistentImageToVectorDataFilter::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbPersistentImageToVectorDataFilter.hxx:100
otb::PersistentImageToVectorDataFilter::GetOutputVectorData
OutputVectorDataType * GetOutputVectorData() const
Definition: otbPersistentImageToVectorDataFilter.hxx:41
otb::PersistentImageToVectorDataFilter< TImageType, otb::LineSegmentDetector< TImageType, double >::VectorDataType >::OutputVectorDataPointerType
otb::LineSegmentDetector< TImageType, double >::VectorDataType ::Pointer OutputVectorDataPointerType
Definition: otbPersistentImageToVectorDataFilter.h:73
otb::PersistentImageToVectorDataFilter::OutputVectorDataType
TOutputVectorData OutputVectorDataType
Definition: otbPersistentImageToVectorDataFilter.h:72
otb::PersistentImageToVectorDataFilter::Synthetize
void Synthetize(void) override
Definition: otbPersistentImageToVectorDataFilter.hxx:74
otb::PersistentImageToVectorDataFilter< TImageType, otb::LineSegmentDetector< TImageType, double >::VectorDataType >::ConcatenateVectorDataFilterPointerType
ConcatenateVectorDataFilterType::Pointer ConcatenateVectorDataFilterPointerType
Definition: otbPersistentImageToVectorDataFilter.h:79
otb::PersistentImageToVectorDataFilter::GenerateData
void GenerateData() override
Definition: otbPersistentImageToVectorDataFilter.hxx:79
otb::PersistentImageToVectorDataFilter::AllocateOutputs
void AllocateOutputs() override
Definition: otbPersistentImageToVectorDataFilter.hxx:47