Skip to content
Snippets Groups Projects
Commit a5f6f89f authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Ensure that the SRS is the same

parent 561e195e
No related branches found
No related tags found
No related merge requests found
......@@ -87,8 +87,16 @@ template<class TImage>
void
PersistentImageToOGRLayerFilter<TImage>
::Initialize()
{}
{
// Ensure that spatial reference of the output layer matches with
// the spatial reference of the input image
OGRSpatialReference oSRS(this->GetInput()->GetProjectionRef().c_str());
if(!oSRS.IsSame(m_OGRLayer.GetSpatialRef()))
{
itkExceptionMacro(<<"Spatial reference of input image and target layer do not match!");
}
}
template<class TImage>
void
......@@ -108,7 +116,14 @@ PersistentImageToOGRLayerFilter<TImage>
// call the processing function for this tile
OGRDataSourcePointerType currentTileVD = this->ProcessTile();
OGRLayerType srcLayer = currentTileVD->GetLayerChecked(0);
// Check spatial reference matches
if(!srcLayer.GetSpatialRef()->IsSame(m_OGRLayer.GetSpatialRef()))
{
itkExceptionMacro(<<"Spatial reference of internal and target layers do not match!");
}
//Copy features contained in the memory layer (srcLayer) in the output layer
itk::TimeProbe chrono;
chrono.Start();
......
......@@ -100,10 +100,10 @@ int otbStreamingImageToOGRLayerSegmentationFilter(int argc, char * argv[])
// TODO: Change once flags have been updated
otb::ogr::DataSource::Pointer ogrDS = otb::ogr::DataSource::New(dataSourceName, otb::ogr::DataSource::Modes::write);
OGRSpatialReference * oSRS = static_cast<OGRSpatialReference *>(OSRNewSpatialReference(reader->GetOutput()->GetProjectionRef().c_str()));
OGRSpatialReference oSRS(reader->GetOutput()->GetProjectionRef().c_str());
// Create the layer
otb::ogr::Layer oLayer = ogrDS->CreateLayer(layerName,oSRS,wkbMultiPolygon,NULL);
otb::ogr::Layer oLayer = ogrDS->CreateLayer(layerName,&oSRS,wkbMultiPolygon,NULL);
// Create the field
OGRFieldDefn field(fieldName.c_str(),OFTInteger);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment