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

ENH: Adding an accessor to the wkt string

parent 0cbf2395
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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