Skip to content
Permalink
Browse files

[OGR provider] Make extent() return a isNull() rectangle on empty lay…

…er (fixes #16721)
  • Loading branch information
rouault committed Nov 12, 2017
1 parent ef70eaf commit 7d8f3f72d91a18503648ec0a95271776371ae3cc
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/providers/ogr/qgsogrprovider.cpp
@@ -1096,25 +1096,25 @@ QgsRectangle QgsOgrProvider::extent()
}
#endif

mExtent->MinX = std::numeric_limits<double>::max();
mExtent->MinY = std::numeric_limits<double>::max();
mExtent->MaxX = -std::numeric_limits<double>::max();
mExtent->MaxY = -std::numeric_limits<double>::max();

// TODO: This can be expensive, do we really need it!
if ( ogrLayer == ogrOrigLayer )
{
OGR_L_GetExtent( ogrLayer, mExtent, true );
}
else
{
mExtent->MinX = std::numeric_limits<double>::max();
mExtent->MinY = std::numeric_limits<double>::max();
mExtent->MaxX = -std::numeric_limits<double>::max();
mExtent->MaxY = -std::numeric_limits<double>::max();

OGRFeatureH f;

OGR_L_ResetReading( ogrLayer );
while (( f = OGR_L_GetNextFeature( ogrLayer ) ) )
{
OGRGeometryH g = OGR_F_GetGeometryRef( f );
if ( g )
if ( g && !OGR_G_IsEmpty( g ) )
{
OGREnvelope env;
OGR_G_GetEnvelope( g, &env );

0 comments on commit 7d8f3f7

Please sign in to comment.
You can’t perform that action at this time.