Skip to content

Commit

Permalink
[OGR provider] Make extent() return a isNull() rectangle on empty lay…
Browse files Browse the repository at this point in the history
…er (fixes #16721)
  • Loading branch information
rouault committed Nov 12, 2017
1 parent ef70eaf commit 7d8f3f7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 7d8f3f7

Please sign in to comment.