OTB  9.0.0
Orfeo Toolbox
otbVectorDataFileWriter.h
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 otbVectorDataFileWriter_h
22 #define otbVectorDataFileWriter_h
23 
24 #include "itkProcessObject.h"
25 #include "itkMacro.h"
26 #include "otbVectorDataIOBase.h"
27 #include <string>
28 
29 namespace otb
30 {
37 class VectorDataFileWriterException : public itk::ExceptionObject
38 {
39 public:
41  itkTypeMacro(VectorDataFileWriterException, ExceptionObject);
42 
44  VectorDataFileWriterException(const char* file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
45  : ExceptionObject(file, line, message, loc)
46  {
47  }
48 
50  VectorDataFileWriterException(const std::string& file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
51  : ExceptionObject(file, line, message, loc)
52  {
53  }
54 };
56 
65 template <class TInputVectorData>
66 class ITK_EXPORT VectorDataFileWriter : public itk::ProcessObject
67 {
68 public:
71  typedef itk::ProcessObject Superclass;
72  typedef itk::SmartPointer<Self> Pointer;
73  typedef itk::SmartPointer<const Self> ConstPointer;
74 
76  itkNewMacro(Self);
77 
79  itkTypeMacro(VectorDataFileWriter, itk::ProcessObject);
80 
81  typedef TInputVectorData InputVectorDataType;
83 
85  using Superclass::SetInput;
86  void SetInput(const InputVectorDataType* input);
87  const InputVectorDataType* GetInput(void);
88  const InputVectorDataType* GetInput(unsigned int idx);
90 
92  virtual void Write();
93 
94  void GenerateData() override;
95 
96  void Update() override
97  {
98  this->Write();
99  }
100 
102  itkSetStringMacro(FileName);
103  itkGetStringMacro(FileName);
105 
106 protected:
108  ~VectorDataFileWriter() override;
109 
110  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
111 
112  std::string m_FileName; // The file to be read
113  typename VectorDataIOBaseType::Pointer m_VectorDataIO;
114  bool m_UserSpecifiedVectorDataIO; // track whether the VectorDataIO
116 
117 private:
118  VectorDataFileWriter(const Self&) = delete;
119  void operator=(const Self&) = delete;
120 };
121 
122 } // end namespace otb
123 
124 #ifndef OTB_MANUAL_INSTANTIATION
126 #endif
127 
128 #endif // otbVectorDataFileWriter_h
otb::VectorDataFileWriterException::VectorDataFileWriterException
VectorDataFileWriterException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Definition: otbVectorDataFileWriter.h:44
otb::VectorDataFileWriter::m_FileName
std::string m_FileName
Definition: otbVectorDataFileWriter.h:112
otbVectorDataIOBase.h
otb::VectorDataFileWriter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataFileWriter.h:72
otb::VectorDataFileWriter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorDataFileWriter.h:73
otb::VectorData
This class represents a hierarchy of vector data.
Definition: otbVectorData.h:58
otb::Wrapper::XML::Write
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbVectorDataFileWriter.hxx
otb::VectorDataFileWriter::m_VectorDataIO
VectorDataIOBaseType::Pointer m_VectorDataIO
Definition: otbVectorDataFileWriter.h:113
otb::VectorDataFileWriter
This class writes vector data file format (shapefile and KML)
Definition: otbVectorDataFileWriter.h:66
otb::VectorDataFileWriter::Superclass
itk::ProcessObject Superclass
Definition: otbVectorDataFileWriter.h:71
otb::VectorDataFileWriter::InputVectorDataType
TInputVectorData InputVectorDataType
Definition: otbVectorDataFileWriter.h:79
otb::VectorDataFileWriter::m_FactorySpecifiedVectorDataIO
bool m_FactorySpecifiedVectorDataIO
Definition: otbVectorDataFileWriter.h:115
otb::VectorDataFileWriter::m_UserSpecifiedVectorDataIO
bool m_UserSpecifiedVectorDataIO
Definition: otbVectorDataFileWriter.h:114
otb::VectorDataFileWriter::Update
void Update() override
Definition: otbVectorDataFileWriter.h:96
otb::VectorDataFileWriter::VectorDataIOBaseType
VectorDataIOBase VectorDataIOBaseType
Definition: otbVectorDataFileWriter.h:82
otb::VectorDataFileWriter::Self
VectorDataFileWriter Self
Definition: otbVectorDataFileWriter.h:70
otb::VectorDataFileWriterException
Definition: otbVectorDataFileWriter.h:37
otb::VectorDataFileWriterException::VectorDataFileWriterException
VectorDataFileWriterException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
Definition: otbVectorDataFileWriter.h:50
otb::VectorDataIOBase
Abstract superclass defines VectorData IO interface.
Definition: otbVectorDataIOBase.h:60