Skip to content

Commit be0b4eb

Browse files
author
jef
committedOct 8, 2009
postgres: don't repeat geometry filter
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11768 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed
 

‎src/app/qgspgsourceselect.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,23 +297,29 @@ QString QgsPgSourceSelect::layerURI( const QModelIndex &index )
297297
int a = geomColumnName.indexOf( " AS " );
298298
QString typeName = geomColumnName.mid( a + 4 ); //only the type name
299299
geomColumnName = geomColumnName.left( a ); //only the geom column name
300-
301-
if ( !sql.isEmpty() )
302-
{
303-
sql += " AND ";
304-
}
300+
QString geomFilter;
305301

306302
if ( typeName == "POINT" )
307303
{
308-
sql += QString( "GeometryType(\"%1\") IN ('POINT','MULTIPOINT')" ).arg( geomColumnName );
304+
geomFilter = QString( "GeometryType(\"%1\") IN ('POINT','MULTIPOINT')" ).arg( geomColumnName );
309305
}
310306
else if ( typeName == "LINESTRING" )
311307
{
312-
sql += QString( "GeometryType(\"%1\") IN ('LINESTRING','MULTILINESTRING')" ).arg( geomColumnName );
308+
geomFilter = QString( "GeometryType(\"%1\") IN ('LINESTRING','MULTILINESTRING')" ).arg( geomColumnName );
313309
}
314310
else if ( typeName == "POLYGON" )
315311
{
316-
sql += QString( "GeometryType(\"%1\") IN ('POLYGON','MULTIPOLYGON')" ).arg( geomColumnName );
312+
geomFilter = QString( "GeometryType(\"%1\") IN ('POLYGON','MULTIPOLYGON')" ).arg( geomColumnName );
313+
}
314+
315+
if ( !geomFilter.isEmpty() && !sql.contains( geomFilter ) )
316+
{
317+
if ( !sql.isEmpty() )
318+
{
319+
sql += " AND ";
320+
}
321+
322+
sql += geomFilter;
317323
}
318324
}
319325

0 commit comments

Comments
 (0)
Please sign in to comment.