Skip to content
Snippets Groups Projects
Commit 97c926cd authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: exceptions to replace printf/exit

parent e28a7712
Branches
Tags
No related merge requests found
...@@ -607,41 +607,41 @@ SHPVectorDataIO<TData> ...@@ -607,41 +607,41 @@ SHPVectorDataIO<TData>
PolygonPointerType extRing = PolygonType::New(); PolygonPointerType extRing = PolygonType::New();
for (int pIndex = 0;pIndex<ogrRing->getNumPoints();++pIndex) for (int pIndex = 0;pIndex<ogrRing->getNumPoints();++pIndex)
{ {
ogrRing->getPoint(pIndex,ogrTmpPoint); ogrRing->getPoint(pIndex,ogrTmpPoint);
typename PolygonType::VertexType vertex; typename PolygonType::VertexType vertex;
vertex[0] = ogrTmpPoint->getX(); vertex[0] = ogrTmpPoint->getX();
vertex[1] = ogrTmpPoint->getY(); vertex[1] = ogrTmpPoint->getY();
if (DataNodeType::Dimension > 2) if (DataNodeType::Dimension > 2)
{ {
vertex[2]= ogrTmpPoint->getZ(); vertex[2]= ogrTmpPoint->getZ();
} }
extRing->AddVertex(vertex); extRing->AddVertex(vertex);
} }
PolygonListPointerType intRings = PolygonListType::New(); PolygonListPointerType intRings = PolygonListType::New();
for (int intRingIndex = 0;intRingIndex<ogrPolygon->getNumInteriorRings();++intRingIndex) for (int intRingIndex = 0;intRingIndex<ogrPolygon->getNumInteriorRings();++intRingIndex)
{ {
PolygonPointerType ring = PolygonType::New(); PolygonPointerType ring = PolygonType::New();
ogrRing = ogrPolygon->getInteriorRing(intRingIndex); ogrRing = ogrPolygon->getInteriorRing(intRingIndex);
for (int pIndex = 0;pIndex<ogrRing->getNumPoints();++pIndex) for (int pIndex = 0;pIndex<ogrRing->getNumPoints();++pIndex)
{ {
ogrRing->getPoint(pIndex,ogrTmpPoint); ogrRing->getPoint(pIndex,ogrTmpPoint);
typename PolygonType::VertexType vertex; typename PolygonType::VertexType vertex;
vertex[0] = ogrTmpPoint->getX(); vertex[0] = ogrTmpPoint->getX();
vertex[1] = ogrTmpPoint->getY(); vertex[1] = ogrTmpPoint->getY();
if (DataNodeType::Dimension > 2) if (DataNodeType::Dimension > 2)
{ {
vertex[2]= ogrTmpPoint->getZ(); vertex[2]= ogrTmpPoint->getZ();
}
ring->AddVertex(vertex);
} }
intRings->PushBack(ring); ring->AddVertex(vertex);
} }
intRings->PushBack(ring);
}
delete ogrTmpPoint; delete ogrTmpPoint;
...@@ -874,8 +874,7 @@ template<class TData> ...@@ -874,8 +874,7 @@ template<class TData>
if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE ) if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE )
{ {
printf( "Failed to create feature in shapefile.\n" ); itkExceptionMacro(<<"Failed to create feature in shapefile.");
exit( 1 );
} }
OGRFeature::DestroyFeature( ogrFeature ); OGRFeature::DestroyFeature( ogrFeature );
...@@ -919,8 +918,7 @@ template<class TData> ...@@ -919,8 +918,7 @@ template<class TData>
if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE ) if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE )
{ {
printf( "Failed to create feature in shapefile.\n" ); itkExceptionMacro(<<"Failed to create feature in shapefile.");
exit( 1 );
} }
OGRFeature::DestroyFeature( ogrFeature ); OGRFeature::DestroyFeature( ogrFeature );
...@@ -993,8 +991,7 @@ template<class TData> ...@@ -993,8 +991,7 @@ template<class TData>
if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE ) if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE )
{ {
printf( "Failed to create feature in shapefile.\n" ); itkExceptionMacro(<<"Failed to create feature in shapefile.");
exit( 1 );
} }
OGRFeature::DestroyFeature( ogrFeature ); OGRFeature::DestroyFeature( ogrFeature );
...@@ -1025,8 +1022,7 @@ template<class TData> ...@@ -1025,8 +1022,7 @@ template<class TData>
if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE ) if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE )
{ {
printf( "Failed to create feature in shapefile.\n" ); itkExceptionMacro(<<"Failed to create feature in shapefile.");
exit( 1 );
} }
ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS); ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS);
...@@ -1049,8 +1045,7 @@ template<class TData> ...@@ -1049,8 +1045,7 @@ template<class TData>
if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE ) if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE )
{ {
printf( "Failed to create feature in shapefile.\n" ); itkExceptionMacro(<<"Failed to create feature in shapefile.");
exit( 1 );
} }
ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS); ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS);
...@@ -1073,8 +1068,7 @@ template<class TData> ...@@ -1073,8 +1068,7 @@ template<class TData>
if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE ) if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE )
{ {
printf( "Failed to create feature in shapefile.\n" ); itkExceptionMacro(<<"Failed to create feature in shapefile.");
exit( 1 );
} }
ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS); ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS);
...@@ -1097,8 +1091,7 @@ template<class TData> ...@@ -1097,8 +1091,7 @@ template<class TData>
if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE ) if( ogrCurrentLayer->CreateFeature( ogrFeature ) != OGRERR_NONE )
{ {
printf( "Failed to create feature in shapefile.\n" ); itkExceptionMacro(<<"Failed to create feature in shapefile.");
exit( 1 );
} }
ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS); ProcessNodeWrite(*it, ogrCollection, ogrCurrentLayer, oSRS);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment