Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
postgres: don't repeat geometry filter
git-svn-id: http://svn.osgeo.org/qgis/trunk@11768 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 8, 2009
1 parent fda7403 commit 0e0fec6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/app/qgspgsourceselect.cpp
Expand Up @@ -297,23 +297,29 @@ QString QgsPgSourceSelect::layerURI( const QModelIndex &index )
int a = geomColumnName.indexOf( " AS " );
QString typeName = geomColumnName.mid( a + 4 ); //only the type name
geomColumnName = geomColumnName.left( a ); //only the geom column name

if ( !sql.isEmpty() )
{
sql += " AND ";
}
QString geomFilter;

if ( typeName == "POINT" )
{
sql += QString( "GeometryType(\"%1\") IN ('POINT','MULTIPOINT')" ).arg( geomColumnName );
geomFilter = QString( "GeometryType(\"%1\") IN ('POINT','MULTIPOINT')" ).arg( geomColumnName );
}
else if ( typeName == "LINESTRING" )
{
sql += QString( "GeometryType(\"%1\") IN ('LINESTRING','MULTILINESTRING')" ).arg( geomColumnName );
geomFilter = QString( "GeometryType(\"%1\") IN ('LINESTRING','MULTILINESTRING')" ).arg( geomColumnName );
}
else if ( typeName == "POLYGON" )
{
sql += QString( "GeometryType(\"%1\") IN ('POLYGON','MULTIPOLYGON')" ).arg( geomColumnName );
geomFilter = QString( "GeometryType(\"%1\") IN ('POLYGON','MULTIPOLYGON')" ).arg( geomColumnName );
}

if ( !geomFilter.isEmpty() && !sql.contains( geomFilter ) )
{
if ( !sql.isEmpty() )
{
sql += " AND ";
}

sql += geomFilter;
}
}

Expand Down

0 comments on commit 0e0fec6

Please sign in to comment.