OTB  10.0.0
Orfeo Toolbox
otbVectorDataFileWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 "OTBVectorDataIOExport.h"
27 #include "otbVectorDataIOBase.h"
28 #include <string>
29 
30 namespace otb
31 {
38 class VectorDataFileWriterException : public itk::ExceptionObject
39 {
40 public:
42  itkTypeMacro(VectorDataFileWriterException, ExceptionObject);
43 
45  VectorDataFileWriterException(const char* file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
46  : ExceptionObject(file, line, message, loc)
47  {
48  }
49 
51  VectorDataFileWriterException(const std::string& file, unsigned int line, const char* message = "Error in IO", const char* loc = "Unknown")
52  : ExceptionObject(file, line, message, loc)
53  {
54  }
55 };
57 
66 template <class TInputVectorData>
67 class ITK_TEMPLATE_EXPORT VectorDataFileWriter : public itk::ProcessObject
68 {
69 public:
72  typedef itk::ProcessObject Superclass;
73  typedef itk::SmartPointer<Self> Pointer;
74  typedef itk::SmartPointer<const Self> ConstPointer;
75 
77  itkNewMacro(Self);
78 
80  itkTypeMacro(VectorDataFileWriter, itk::ProcessObject);
81 
82  typedef TInputVectorData InputVectorDataType;
84 
86  using Superclass::SetInput;
87  void SetInput(const InputVectorDataType* input);
88  const InputVectorDataType* GetInput(void);
89  const InputVectorDataType* GetInput(unsigned int idx);
91 
93  virtual void Write();
94 
95  void GenerateData() override;
96 
97  void Update() override
98  {
99  this->Write();
100  }
101 
103  itkSetStringMacro(FileName);
104  itkGetStringMacro(FileName);
106 
107 protected:
109  ~VectorDataFileWriter() override;
110 
111  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
112 
113  std::string m_FileName; // The file to be read
115  bool m_UserSpecifiedVectorDataIO; // track whether the VectorDataIO
117 
118 private:
119  VectorDataFileWriter(const Self&) = delete;
120  void operator=(const Self&) = delete;
121 };
122 
123 } // end namespace otb
124 
125 #ifndef OTB_MANUAL_INSTANTIATION
127 #endif
128 
129 #endif // otbVectorDataFileWriter_h
VectorDataFileWriterException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
VectorDataFileWriterException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
This class writes vector data file format (shapefile and KML)
VectorDataIOBaseType::Pointer m_VectorDataIO
VectorDataFileWriter(const Self &)=delete
itk::SmartPointer< Self > Pointer
void operator=(const Self &)=delete
itk::SmartPointer< const Self > ConstPointer
Abstract superclass defines VectorData IO interface.
itk::SmartPointer< Self > Pointer
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.