OTB  9.0.0
Orfeo Toolbox
otbOGRDataSourceToLabelImageFilter.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 otbOGRDataSourceToLabelImageFilter_h
22 #define otbOGRDataSourceToLabelImageFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbMacro.h"
26 
27 
28 #include "gdal.h"
29 #include "gdal_alg.h"
31 #include <string>
32 
33 namespace otb
34 {
35 
58 template <class TOutputImage>
59 class ITK_EXPORT OGRDataSourceToLabelImageFilter : public itk::ImageSource<TOutputImage>
60 {
61 public:
64  typedef itk::ImageSource<TOutputImage> Superclass;
65  typedef itk::SmartPointer<Self> Pointer;
66  typedef itk::SmartPointer<const Self> ConstPointer;
67 
69  itkTypeMacro(OGRDataSourceToLabelImageFilter, itk::ImageSource);
70 
72  itkNewMacro(Self);
73 
74  typedef TOutputImage OutputImageType;
75  typedef typename OutputImageType::Pointer OutputImagePointer;
76  typedef typename OutputImageType::SizeType OutputSizeType;
77  typedef typename OutputImageType::IndexType OutputIndexType;
78  typedef typename OutputImageType::SpacingType OutputSpacingType;
79  typedef typename OutputImageType::PointType OutputOriginType;
80  typedef typename OutputImageType::RegionType OutputImageRegionType;
81  typedef typename OutputImageType::PixelType OutputImagePixelType;
82  typedef typename OutputImageType::InternalPixelType OutputImageInternalPixelType;
83 
88 
89  typedef itk::ImageBase<OutputImageType::ImageDimension> ImageBaseType;
90 
92  const OGRDataSourceType* GetInput(unsigned int idx);
93 
95  virtual void AddOGRDataSource(const OGRDataSourceType* ds);
96 
98  itkSetMacro(OutputSize, OutputSizeType);
99 
101  itkGetConstReferenceMacro(OutputSize, OutputSizeType);
102 
106  itkSetMacro(OutputOrigin, OutputOriginType);
107  virtual void SetOutputOrigin(const double origin[2]);
108  virtual void SetOutputOrigin(const float origin[2]);
110 
111  itkGetConstReferenceMacro(OutputOrigin, OutputOriginType);
112 
116  virtual void SetOutputSpacing(const OutputSpacingType& spacing);
117  virtual void SetOutputSpacing(const double spacing[2]);
118  virtual void SetOutputSpacing(const float spacing[2]);
120 
122  itkSetStringMacro(OutputProjectionRef);
123  itkGetStringMacro(OutputProjectionRef);
125 
127  itkSetStringMacro(BurnAttribute);
128  itkGetStringMacro(BurnAttribute);
130 
132  itkSetMacro(BackgroundValue, OutputImageInternalPixelType);
133  itkGetConstReferenceMacro(BackgroundValue, OutputImageInternalPixelType);
135 
137  itkSetMacro(ForegroundValue, OutputImageInternalPixelType);
138  itkGetConstReferenceMacro(ForegroundValue, OutputImageInternalPixelType);
140 
142  itkSetMacro(BurnAttributeMode, bool);
143  itkGetConstReferenceMacro(BurnAttributeMode, bool);
144  itkBooleanMacro(BurnAttributeMode);
146 
148  itkSetMacro(AllTouchedMode, bool);
149  itkGetConstReferenceMacro(AllTouchedMode, bool);
150  itkBooleanMacro(AllTouchedMode);
152 
154  template <class ImagePointerType>
155  void SetOutputParametersFromImage(const ImagePointerType image);
156 
157 protected:
158  void GenerateData() override;
159 
161  ~OGRDataSourceToLabelImageFilter() override = default;
162 
163  void GenerateOutputInformation() override;
164 
165  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
166 
167 private:
168  OGRDataSourceToLabelImageFilter(const Self&) = delete;
169  void operator=(const Self&) = delete;
170 
171  std::vector<OGRLayerH> m_SrcDataSetLayers;
172  std::vector<int> m_BandsToBurn;
173 
174  // Field used to extract the burn value
175  std::string m_BurnAttribute;
176 
177  // Output params
187 }; // end of class VectorDataToLabelImageFilter
188 
189 } // end of namespace otb
190 
191 
192 #ifndef OTB_MANUAL_INSTANTIATION
194 #endif
195 
196 #endif
otb::OGRDataSourceToLabelImageFilter::m_OutputProjectionRef
std::string m_OutputProjectionRef
Definition: otbOGRDataSourceToLabelImageFilter.h:178
otb::OGRDataSourceToLabelImageFilter
Burn geometries from the specified VectorData into raster.
Definition: otbOGRDataSourceToLabelImageFilter.h:59
otb::OGRDataSourceToLabelImageFilter::OGRDataSourcePointerType
OGRDataSourceType::Pointer OGRDataSourcePointerType
Definition: otbOGRDataSourceToLabelImageFilter.h:86
otb::OGRDataSourceToLabelImageFilter::m_ForegroundValue
OutputImageInternalPixelType m_ForegroundValue
Definition: otbOGRDataSourceToLabelImageFilter.h:184
otb::OGRDataSourceToLabelImageFilter::Superclass
itk::ImageSource< TOutputImage > Superclass
Definition: otbOGRDataSourceToLabelImageFilter.h:64
otb::OGRDataSourceToLabelImageFilter::ImageBaseType
itk::ImageBase< OutputImageType::ImageDimension > ImageBaseType
Definition: otbOGRDataSourceToLabelImageFilter.h:89
otb::OGRDataSourceToLabelImageFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbOGRDataSourceToLabelImageFilter.h:80
otb::OGRDataSourceToLabelImageFilter::m_OutputOrigin
OutputOriginType m_OutputOrigin
Definition: otbOGRDataSourceToLabelImageFilter.h:180
otb::OGRDataSourceToLabelImageFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbOGRDataSourceToLabelImageFilter.h:72
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::OGRDataSourceToLabelImageFilter::m_OutputSize
OutputSizeType m_OutputSize
Definition: otbOGRDataSourceToLabelImageFilter.h:181
otb::ogr::DataSource
Collection of geometric objects.
Definition: otbOGRDataSourceWrapper.h:83
otb::OGRDataSourceToLabelImageFilter::m_BurnAttribute
std::string m_BurnAttribute
Definition: otbOGRDataSourceToLabelImageFilter.h:175
otb::OGRDataSourceToLabelImageFilter::m_SrcDataSetLayers
std::vector< OGRLayerH > m_SrcDataSetLayers
Definition: otbOGRDataSourceToLabelImageFilter.h:171
otb::OGRDataSourceToLabelImageFilter::m_BandsToBurn
std::vector< int > m_BandsToBurn
Definition: otbOGRDataSourceToLabelImageFilter.h:172
otb::OGRDataSourceToLabelImageFilter::m_OutputSpacing
OutputSpacingType m_OutputSpacing
Definition: otbOGRDataSourceToLabelImageFilter.h:179
otbMacro.h
otb::OGRDataSourceToLabelImageFilter::OutputIndexType
OutputImageType::IndexType OutputIndexType
Definition: otbOGRDataSourceToLabelImageFilter.h:77
otb::OGRDataSourceToLabelImageFilter::OutputSpacingType
OutputImageType::SpacingType OutputSpacingType
Definition: otbOGRDataSourceToLabelImageFilter.h:78
otb::OGRDataSourceToLabelImageFilter::OutputImageInternalPixelType
OutputImageType::InternalPixelType OutputImageInternalPixelType
Definition: otbOGRDataSourceToLabelImageFilter.h:82
otb::OGRDataSourceToLabelImageFilter::Self
OGRDataSourceToLabelImageFilter Self
Definition: otbOGRDataSourceToLabelImageFilter.h:63
otb::OGRDataSourceToLabelImageFilter::OutputOriginType
OutputImageType::PointType OutputOriginType
Definition: otbOGRDataSourceToLabelImageFilter.h:79
otb::OGRDataSourceToLabelImageFilter::OGRLayerType
ogr::Layer OGRLayerType
Definition: otbOGRDataSourceToLabelImageFilter.h:87
otb::OGRDataSourceToLabelImageFilter::m_BackgroundValue
OutputImageInternalPixelType m_BackgroundValue
Definition: otbOGRDataSourceToLabelImageFilter.h:183
otb::OGRDataSourceToLabelImageFilter::m_AllTouchedMode
bool m_AllTouchedMode
Definition: otbOGRDataSourceToLabelImageFilter.h:186
otb::ogr::DataSource::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbOGRDataSourceWrapper.h:90
otb::OGRDataSourceToLabelImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbOGRDataSourceToLabelImageFilter.h:65
otb::OGRDataSourceToLabelImageFilter::OutputImagePointer
OutputImageType::Pointer OutputImagePointer
Definition: otbOGRDataSourceToLabelImageFilter.h:75
otb::OGRDataSourceToLabelImageFilter::OutputSizeType
OutputImageType::SizeType OutputSizeType
Definition: otbOGRDataSourceToLabelImageFilter.h:76
otb::OGRDataSourceToLabelImageFilter::m_BurnAttributeMode
bool m_BurnAttributeMode
Definition: otbOGRDataSourceToLabelImageFilter.h:185
otb::OGRDataSourceToLabelImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbOGRDataSourceToLabelImageFilter.h:66
otb::ogr::Layer
Layer of geometric objects.
Definition: otbOGRLayerWrapper.h:80
otb::OGRDataSourceToLabelImageFilter::OGRDataSourceType
ogr::DataSource OGRDataSourceType
Definition: otbOGRDataSourceToLabelImageFilter.h:85
otbOGRDataSourceToLabelImageFilter.hxx
otbOGRDataSourceWrapper.h
otb::OGRDataSourceToLabelImageFilter::m_OutputStartIndex
OutputIndexType m_OutputStartIndex
Definition: otbOGRDataSourceToLabelImageFilter.h:182
otb::OGRDataSourceToLabelImageFilter::OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Definition: otbOGRDataSourceToLabelImageFilter.h:81