OTB  6.7.0
Orfeo Toolbox
otbOGRDataToSamplePositionFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 otbOGRDataToSamplePositionFilter_h
22 #define otbOGRDataToSamplePositionFilter_h
23 
27 #include "otbPeriodicSampler.h"
28 #include "otbImage.h"
29 #include <string>
30 
31 namespace otb
32 {
33 
52 template<class TInputImage, class TMaskImage, class TSampler>
54  public PersistentSamplingFilterBase<TInputImage, TMaskImage>
55 {
56 public:
57 
61  TInputImage,
62  TMaskImage> Superclass;
65 
66  typedef TInputImage InputImageType;
67  typedef typename InputImageType::Pointer InputImagePointer;
68  typedef typename InputImageType::RegionType RegionType;
70 
71  typedef TMaskImage MaskImageType;
72  typedef typename MaskImageType::Pointer MaskImagePointer;
73 
76 
77  typedef TSampler SamplerType;
78  typedef typename SamplerType::Pointer SamplerPointerType;
80  typedef typename std::map
82 
83  typedef std::map<std::string, unsigned int> ClassPartitionType;
84 
86 
88  itkNewMacro(Self);
89 
92 
93  void Synthetize(void) override{}
94 
96  void Reset(void) override;
97 
99  SamplerMapType& GetSamplers(unsigned int level);
100 
103  void SetOutputPositionContainerAndRates(
104  otb::ogr::DataSource* data,
106  unsigned int level);
107 
109  const otb::ogr::DataSource* GetOutputPositionContainer(unsigned int level) const;
110  otb::ogr::DataSource* GetOutputPositionContainer(unsigned int level);
112 
114  unsigned int GetNumberOfLevels();
115 
117  void ClearOutputs();
118 
121  itk::DataObject::Pointer MakeOutput(DataObjectPointerArraySizeType idx) override;
122  using Superclass::MakeOutput;
123 
125  itkSetMacro(OriginFieldName, std::string);
126  itkGetMacro(OriginFieldName, std::string);
128 
129 protected:
132 
135 
137  void ProcessSample(const ogr::Feature& feature,
138  typename TInputImage::IndexType& imgIndex,
139  typename TInputImage::PointType& imgPoint,
140  itk::ThreadIdType& threadid) override;
141 
145  void DispatchInputVectors(void) override;
146 
148  void FillOneOutput(unsigned int outIdx, ogr::DataSource* outDS, bool update) override;
149 
150 private:
151  PersistentOGRDataToSamplePositionFilter(const Self &) = delete;
152  void operator =(const Self&) = delete;
153 
154  void ComputeClassPartition(void);
155 
158 
160  std::vector<SamplerMapType> m_Samplers;
161 
164  std::string m_OriginFieldName;
165 
168 };
169 
179 template<class TInputImage, class TMaskImage = otb::Image<unsigned char> , class TSampler = otb::PeriodicSampler >
181  public PersistentFilterStreamingDecorator<PersistentOGRDataToSamplePositionFilter<TInputImage,TMaskImage,TSampler> >
182 {
183 public:
184 
189  <TInputImage,TMaskImage,TSampler> > Superclass;
192 
193  typedef TInputImage InputImageType;
194  typedef TMaskImage MaskImageType;
196 
198 
199  typedef TSampler SamplerType;
200  typedef typename SamplerType::Pointer SamplerPointerType;
202  typedef typename std::map
204 
206  itkNewMacro(Self);
207 
210 
211  using Superclass::SetInput;
212 
214  virtual void SetInput(const TInputImage* image);
215 
217  const TInputImage* GetInput();
218 
220  void SetOGRData(const otb::ogr::DataSource* data);
221 
223  const otb::ogr::DataSource* GetOGRData();
224 
226  void SetMask(const TMaskImage* mask);
227 
229  const TMaskImage* GetMask();
230 
232  void SetFieldName(std::string key);
233 
235  std::string GetFieldName();
236 
238  void SetLayerIndex(int index);
239 
241  int GetLayerIndex();
242 
244  void SetSamplerParameters(SamplerParameterType param, unsigned int level=0);
245 
247  SamplerMapType& GetSamplers(unsigned int level=0);
248 
250  void SetOutputPositionContainerAndRates(
251  otb::ogr::DataSource* data,
253  unsigned int level=0);
254 
256  otb::ogr::DataSource* GetOutputPositionContainer(unsigned int level=0);
257 
259  void SetOriginFieldName(std::string key);
260 
262  std::string GetOriginFieldName();
263 
264 protected:
267 
270 
271 private:
272  OGRDataToSamplePositionFilter(const Self &) = delete;
273  void operator =(const Self&) = delete;
274 };
275 
276 } // end of namespace otb
277 
278 #ifndef OTB_MANUAL_INSTANTIATION
280 #endif
281 
282 #endif
PersistentSamplingFilterBase< TInputImage, TMaskImage > Superclass
PersistentFilterStreamingDecorator< PersistentOGRDataToSamplePositionFilter< TInputImage, TMaskImage, TSampler > > Superclass
itk::DataObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
std::map< std::string, unsigned int > ClassPartitionType
Base class for persistent filter doing sampling tasks.
Collection of geometric objects.
Extracts sample position from an image using a persistent filter.
std::vector< Pointer >::size_type DataObjectPointerArraySizeType
Persistent filter to extract sample position from an image.
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
std::map< std::string, TripletType > MapRateType
unsigned int ThreadIdType
std::map< std::string, SamplerPointerType > SamplerMapType
Geometric objet with descriptive fields.
std::map< std::string, SamplerPointerType > SamplerMapType
VectorImageType::PointType PointType
Definition: mvdTypes.h:189
This filter link a persistent filter with a StreamingImageVirtualWriter.