21 #ifndef __otbPersistentImageToOGRLayerFilter_txx
22 #define __otbPersistentImageToOGRLayerFilter_txx
26 #include <boost/foreach.hpp>
34 template<
class TImage>
41 template<
class TImage>
47 template<
class TImage>
52 m_OGRLayer = ogrLayer;
56 template<
class TImage>
64 template<
class TImage>
72 template<
class TImage>
79 template<
class TImage>
86 template<
class TImage>
92 const_cast<InputImageType*
> (this->GetInput())->UpdateOutputInformation();
96 OGRSpatialReference oSRS(this->GetInput()->GetProjectionRef().c_str());
101 OGRSpatialReference oSRSESRI(this->GetInput()->GetProjectionRef().c_str());
103 oSRSESRI.morphToESRI();
104 oSRSESRI.morphFromESRI();
105 if (m_OGRLayer.GetSpatialRef() && (!oSRS.IsSame(m_OGRLayer.GetSpatialRef())
106 && !oSRSESRI.IsSame(m_OGRLayer.GetSpatialRef())))
108 if ((oSRS.Validate() != OGRERR_NONE) && (oSRSESRI.Validate() != OGRERR_NONE))
110 itkExceptionMacro(<<
"Input projection ref is not valid");
112 itkExceptionMacro(<<
"Spatial reference of input image and target layer do not match! "<< std::endl
113 <<
"Input image : "<< this->GetInput()->GetProjectionRef()<< std::endl
114 <<
"Target layer : "<<m_OGRLayer.GetProjectionRef());
118 template<
class TImage>
125 itkExceptionMacro(<<
"Output OGRLayer is null.");
128 if (this->GetStreamSize()[0]==0 && this->GetStreamSize()[1]==0)
130 this->m_StreamSize = this->GetInput()->GetRequestedRegion().GetSize();
135 OGRLayerType srcLayer = currentTileVD->GetLayerChecked(0);
141 itkExceptionMacro(<<
"Spatial reference of internal and target layers do not match!");
147 m_OGRLayer.ogr().StartTransaction();
149 for(; featIt!=srcLayer.
end(); ++featIt)
152 dstFeature.
SetFrom( *featIt, TRUE );
153 m_OGRLayer.CreateFeature( dstFeature );
156 m_OGRLayer.ogr().CommitTransaction();
162 template<
class TImage>
167 Superclass::PrintSelf(os, indent);