Commit d17aaf76 authored by Julien Michel's avatar Julien Michel

ENH: Adding an accessor to the wkt string

parent 0cbf2395
......@@ -229,6 +229,26 @@ OGRSpatialReference const* otb::ogr::Layer::GetSpatialRef() const
return m_Layer->GetSpatialRef();
}
std::string otb::ogr::Layer::GetProjectionRef() const
{
char * wkt;
const OGRErr res = m_Layer->GetSpatialRef()->exportToWkt(&wkt);
if(res != OGRERR_NONE)
{
itkGenericExceptionMacro(<< "Cannot convert spatial reference to wkt string for layer <"
<<m_Layer->GetName()<<">: " << CPLGetLastErrorMsg());
}
std::string stringWkt(wkt);
// According to documentation, argument of exportToWkt() should be freed
OGRFree(wkt);
return stringWkt;
}
/*===========================================================================*/
/*==========================[ Feature Definition ]===========================*/
/*===========================================================================*/
......
......@@ -283,6 +283,11 @@ public:
*/
OGRSpatialReference const* GetSpatialRef() const;
/** Returns the projection ref associated with the layer
* \return The projection ref (wkt string) associated with the layer
*/
std::string GetProjectionRef() const;
/**\name Iteration */
//@{
/**\ingroup gGeometry
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment