21 #ifndef otbRasterizeVectorDataFilter_hxx
22 #define otbRasterizeVectorDataFilter_hxx
31 template <
class TVectorData,
class TInputImage,
class TOutputImage>
34 this->SetNumberOfRequiredInputs(1);
37 template <
class TVectorData,
class TInputImage,
class TOutputImage>
42 if (this->GetNumberOfInputs() < 1)
44 this->itk::ProcessObject::SetNthInput(1,
const_cast<VectorDataType*
>(vd));
48 this->itk::ProcessObject::PushBackInput(vd);
53 template <
class TVectorData,
class TInputImage,
class TOutputImage>
56 Superclass::GenerateOutputInformation();
60 for (
unsigned int idx = 1; idx < this->GetNumberOfInputs(); ++idx)
65 std::string projectionRefWkt = vd->GetProjectionRef();
66 bool projectionInformationAvailable = !projectionRefWkt.empty();
67 OGRSpatialReference* oSRS =
nullptr;
69 if (projectionInformationAvailable)
71 oSRS =
static_cast<OGRSpatialReference*
>(OSRNewSpatialReference(projectionRefWkt.c_str()));
83 OGRLayer* ogrCurrentLayer =
nullptr;
84 std::vector<OGRLayer*> ogrLayerVector;
90 m_OGRDataSourcePointer =
nullptr;
91 ogrLayerVector = IOConversion->ConvertDataTreeNodeToOGRLayers(vd,root, m_OGRDataSourcePointer, ogrCurrentLayer, oSRS);
94 for (
unsigned int idx2 = 0; idx2 < ogrLayerVector.size(); ++idx2)
96 m_SrcDataSetLayers.push_back((OGRLayerH)(ogrLayerVector[idx2]));
111 if (m_BurnValues.size() != m_BandsToBurn.size() * m_SrcDataSetLayers.size())
113 std::ostringstream oss;
114 oss <<
"Inconsistency detected : expected burn vector size to be equal to( bandToBurn * nb layers = " << m_BandsToBurn.size() * m_SrcDataSetLayers.size()
115 <<
" ), got : " << m_BurnValues.size() << std::endl;
116 itkWarningMacro(<< oss.str());
120 for (
unsigned int idx = 0; idx < m_SrcDataSetLayers.size(); ++idx)
122 for (
unsigned int burnidx = 0; burnidx < m_BurnValues.size(); ++burnidx)
124 m_FullBurnValues.push_back(m_BurnValues[burnidx]);
129 template <
class TVectorData,
class TInputImage,
class TOutputImage>
133 Superclass::GenerateData();
139 unsigned int nbBands = this->GetOutput()->GetNumberOfComponentsPerPixel();
143 this->GetOutput()->GetBufferPointer(),
144 bufferedRegion.GetSize()[0],
145 bufferedRegion.GetSize()[1], GdalDataTypeBridge::GetGDALDataType<OutputImageInternalPixelType>(),
151 GDALSetProjection(dataset->GetDataSet(), this->GetOutput()->GetProjectionRef().c_str());
154 itk::VariableLengthVector<double> geoTransform(6);
160 this->GetOutput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin);
161 geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSignedSpacing()[0];
162 geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSignedSpacing()[1];
163 geoTransform[1] = this->GetOutput()->GetSignedSpacing()[0];
164 geoTransform[5] = this->GetOutput()->GetSignedSpacing()[1];
167 geoTransform[2] = 0.;
168 geoTransform[4] = 0.;
169 GDALSetGeoTransform(dataset->GetDataSet(),
170 const_cast<double*
>(geoTransform.GetDataPointer()));
172 char** options =
nullptr;
173 if (m_AllTouchedMode)
175 options = CSLSetNameValue(options,
"ALL_TOUCHED",
"TRUE");
179 if (dataset->GetDataSet() !=
nullptr)
181 GDALRasterizeLayers(dataset->GetDataSet(), m_BandsToBurn.size(),
182 &(m_BandsToBurn[0]), m_SrcDataSetLayers.size(),
183 &(m_SrcDataSetLayers[0]),
nullptr,
nullptr,
184 &(m_FullBurnValues[0]), options, GDALDummyProgress,
192 template <
class TVectorData,
class TInputImage,
class TOutputImage>
195 Superclass::PrintSelf(os, indent);
itk::SmartPointer< Self > Pointer
static GDALDriverManagerWrapper & GetInstance()
GDALDatasetWrapper::Pointer OpenFromMemory(void *mem_ptr, const uint64_t &width, const uint64_t &height, const GDALDataType pix_type, const uint32_t byte_per_pixel, const uint16_t nb_bands=1, const uint64_t &band_offset=1) const
itk::SmartPointer< Self > Pointer
void GenerateData() override
OutputImageType::RegionType OutputImageRegionType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
TVectorData VectorDataType
RasterizeVectorDataFilter()
VectorDataType::DataNodePointerType DataNodePointerType
OutputImageType::InternalPixelType OutputImageInternalPixelType
InputImageType::PointType InputPointType
InputImageType::IndexType InputIndexType
virtual void AddVectorData(const VectorDataType *vd)
void GenerateOutputInformation() override
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
#define otbMsgDevMacro(x)