Skip to content

Commit 7d8f3f7

Browse files
committedNov 12, 2017
[OGR provider] Make extent() return a isNull() rectangle on empty layer (fixes #16721)
1 parent ef70eaf commit 7d8f3f7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,25 +1096,25 @@ QgsRectangle QgsOgrProvider::extent()
10961096
}
10971097
#endif
10981098

1099+
mExtent->MinX = std::numeric_limits<double>::max();
1100+
mExtent->MinY = std::numeric_limits<double>::max();
1101+
mExtent->MaxX = -std::numeric_limits<double>::max();
1102+
mExtent->MaxY = -std::numeric_limits<double>::max();
1103+
10991104
// TODO: This can be expensive, do we really need it!
11001105
if ( ogrLayer == ogrOrigLayer )
11011106
{
11021107
OGR_L_GetExtent( ogrLayer, mExtent, true );
11031108
}
11041109
else
11051110
{
1106-
mExtent->MinX = std::numeric_limits<double>::max();
1107-
mExtent->MinY = std::numeric_limits<double>::max();
1108-
mExtent->MaxX = -std::numeric_limits<double>::max();
1109-
mExtent->MaxY = -std::numeric_limits<double>::max();
1110-
11111111
OGRFeatureH f;
11121112

11131113
OGR_L_ResetReading( ogrLayer );
11141114
while (( f = OGR_L_GetNextFeature( ogrLayer ) ) )
11151115
{
11161116
OGRGeometryH g = OGR_F_GetGeometryRef( f );
1117-
if ( g )
1117+
if ( g && !OGR_G_IsEmpty( g ) )
11181118
{
11191119
OGREnvelope env;
11201120
OGR_G_GetEnvelope( g, &env );

0 commit comments

Comments
 (0)