Sirius  0.0.0
input_stream.h
Go to the documentation of this file.
1 
22 #ifndef SIRIUS_GDAL_INPUT_STREAM_H_
23 #define SIRIUS_GDAL_INPUT_STREAM_H_
24 
25 #include <system_error>
26 
27 #include "sirius/image.h"
28 #include "sirius/types.h"
29 
31 #include "sirius/gdal/types.h"
32 
33 namespace sirius {
34 namespace gdal {
35 
39 class InputStream {
40  public:
48  InputStream(const std::string& image_path, const sirius::Size& block_size,
49  const sirius::Size& block_margin_size,
50  PaddingType block_padding_type);
51 
52  ~InputStream() = default;
53 
54  InputStream(const InputStream&) = delete;
55  InputStream& operator=(const InputStream&) = delete;
56  InputStream(InputStream&&) = delete;
57  InputStream& operator=(InputStream&&) = delete;
58 
64  return {input_dataset_->GetRasterYSize(),
65  input_dataset_->GetRasterXSize()};
66  }
67 
73  StreamBlock Read(std::error_code& ec);
74 
79  bool IsAtEnd() { return is_ended_; }
80 
81  private:
82  gdal::DatasetUPtr input_dataset_;
83  sirius::Size block_size_{256, 256};
84  sirius::Size block_margin_size_;
85  PaddingType block_padding_type_;
86  bool is_ended_ = false;
87  int row_idx_ = 0;
88  int col_idx_ = 0;
89 };
90 
91 } // namespace gdal
92 } // namespace sirius
93 
94 #endif // SIRIUS_GDAL_INPUT_STREAM_H_
PaddingType
Definition: image.h:31
Definition: exception.h:27
std::unique_ptr<::GDALDataset, detail::DatasetDeleter > DatasetUPtr
Definition: types.h:45
InputStream & operator=(const InputStream &)=delete
bool IsAtEnd()
Indicate end of image.
Definition: input_stream.h:79
StreamBlock Read(std::error_code &ec)
Read a block from the image.
Stream block.
Definition: stream_block.h:33
Data class that represents the size of an image.
Definition: types.h:38
Stream an image in block.
Definition: input_stream.h:39
InputStream(const std::string &image_path, const sirius::Size &block_size, const sirius::Size &block_margin_size, PaddingType block_padding_type)
Instanciate an InputStreamer and set its block size.
sirius::Size Size()
Get the size of the input file.
Definition: input_stream.h:63