Commit 86710785 authored by Julien Michel's avatar Julien Michel

ENH: Adding a GetExtent() method to Layer

parent fd25c4ab
......@@ -158,6 +158,22 @@ std::string otb::ogr::Layer::GetName() const
#endif
}
void otb::ogr::Layer::GetExtent(double& ulx, double& uly, double& lrx, double& lry, bool force) const
{
OGREnvelope sExtent;
const OGRErr res = m_Layer->GetExtent(&sExtent,force);
if(res != OGRERR_NONE)
{
itkGenericExceptionMacro(<< "Cannot retrieve extent of layer <"
<<GetName()<<">: " << CPLGetLastErrorMsg());
}
ulx = sExtent.MinX;
uly = sExtent.MinY;
lrx = sExtent.MaxX;
lry = sExtent.MaxY;
}
OGRLayer & otb::ogr::Layer::ogr()
{
assert(m_Layer && "OGRLayer not initialized");
......
......@@ -189,6 +189,22 @@ public:
*/
std::string GetName() const;
/** Allow to retrieve the extent of the layer
* \param[out] ulx reference to upper-left x coordinate of the
* extent
* \param[out] uly reference to upper-left y coordinate of the
* extent
* \param[out] lrx reference to lower-right x coordinate of the
* extent
* \param[out] uly reference to lower-right y coordinate of the
* extent
* \param[in] force Force computation of the extent if not
* available. May force the driver to walk all geometries to
* compute the extent.
* \throw itk::ExceptionObject if the extent can not be retrieved.
*/
void GetExtent(double & ulx, double & uly, double & lrx, double & lry, bool force = false) const;
/** Prints self into stream. */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
......
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