26 template<
class TVectorData,
class TInputImage,
class TOutputImage>
29 : m_OGRDataSourcePointer(0)
31 this->SetNumberOfRequiredInputs(1);
34 template<
class TVectorData,
class TInputImage,
class TOutputImage>
41 if (this->GetNumberOfInputs() < 1)
52 template<
class TVectorData,
class TInputImage,
class TOutputImage>
57 Superclass::GenerateOutputInformation();
61 for (
unsigned int idx = 1; idx < this->GetNumberOfInputs(); ++idx)
66 std::string projectionRefWkt = vd->GetProjectionRef();
67 bool projectionInformationAvailable = !projectionRefWkt.empty();
68 OGRSpatialReference * oSRS =
NULL;
70 if (projectionInformationAvailable)
72 oSRS =
static_cast<OGRSpatialReference *
>(OSRNewSpatialReference(projectionRefWkt.c_str()));
87 OGRLayer * ogrCurrentLayer =
NULL;
88 std::vector<OGRLayer *> ogrLayerVector;
94 m_OGRDataSourcePointer =
NULL;
95 ogrLayerVector = IOConversion->ConvertDataTreeNodeToOGRLayers(inputRoot,
96 m_OGRDataSourcePointer,
101 for (
unsigned int idx = 0; idx < ogrLayerVector.size(); ++idx)
103 m_SrcDataSetLayers.push_back( (OGRLayerH)(ogrLayerVector[idx]) );
118 if (m_BurnValues.size() != m_BandsToBurn.size() * m_SrcDataSetLayers.size())
120 std::ostringstream oss;
121 oss <<
"Inconsistency detected : expected burn vector size to be equal to( bandToBurn * nb layers = "
122 << m_BandsToBurn.size() * m_SrcDataSetLayers.size()
123 <<
" ), got : "<< m_BurnValues.size()<<std::endl;
124 itkWarningMacro(<<oss.str());
128 for (
unsigned int idx =0; idx < m_SrcDataSetLayers.size(); ++idx)
130 for (
unsigned int burnidx = 0; burnidx < m_BurnValues.size(); ++burnidx)
132 m_FullBurnValues.push_back(m_BurnValues[burnidx]);
137 template<
class TVectorData,
class TInputImage,
class TOutputImage>
142 Superclass::GenerateData();
148 unsigned int nbBands = this->GetOutput()->GetNumberOfComponentsPerPixel();
153 std::ostringstream stream;
155 <<
"DATAPOINTER=" << (
unsigned long)(this->GetOutput()->GetBufferPointer()) <<
","
156 <<
"PIXELS=" << bufferedRegion.GetSize()[0] <<
","
157 <<
"LINES=" << bufferedRegion.GetSize()[1]<<
","
158 <<
"BANDS=" << nbBands <<
","
159 <<
"DATATYPE=" << GDALGetDataTypeName(GdalDataTypeBridge::GetGDALDataType<OutputImageInternalPixelType>()) <<
","
164 GDALDatasetH dataset = GDALOpen(stream.str().c_str(), GA_Update);
167 GDALSetProjection (dataset, this->GetOutput()->GetProjectionRef().c_str());
176 this->GetOutput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin);
177 geoTransform[0] = bufferOrigin[0];
178 geoTransform[3] = bufferOrigin[1];
179 geoTransform[1] = this->GetOutput()->GetSpacing()[0];
180 geoTransform[5] = this->GetOutput()->GetSpacing()[1];
183 geoTransform[2] = 0.;
184 geoTransform[4] = 0.;
185 GDALSetGeoTransform(dataset,const_cast<double*>(geoTransform.
GetDataPointer()));
190 GDALRasterizeLayers( dataset, m_BandsToBurn.size(),
192 m_SrcDataSetLayers.size(),
193 &(m_SrcDataSetLayers[0]),
196 GDALDummyProgress,
NULL );
199 GDALClose( dataset );
203 template<
class TVectorData,
class TInputImage,
class TOutputImage>
208 Superclass::PrintSelf(os, indent);