OTB  7.2.0
Orfeo Toolbox
otbVectorDataFileWriter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 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
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
VectorDataIOBaseType::Pointer m_VectorDataIO
VectorDataFileWriterException(const std::string &file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
itk::SmartPointer< Self > Pointer
VectorDataFileWriterException(const char *file, unsigned int line, const char *message="Error in IO", const char *loc="Unknown")
itk::SmartPointer< Self > Pointer
Abstract superclass defines VectorData IO interface.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
itk::SmartPointer< const Self > ConstPointer
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
This class writes vector data file format (shapefile and KML)