Skip to content
Permalink
Browse files
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 0e0fec6e13113af3adb8a2183b26701230e74fc9
Showing with 14 additions and 8 deletions.
  1. +14 −8 src/app/qgspgsourceselect.cpp
@@ -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;
}
}

0 comments on commit 0e0fec6

Please sign in to comment.