[QGIS Commit] r11768 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Oct 8 08:16:13 EDT 2009


Author: jef
Date: 2009-10-08 08:16:13 -0400 (Thu, 08 Oct 2009)
New Revision: 11768

Modified:
   trunk/qgis/src/app/qgspgsourceselect.cpp
Log:
postgres: don't repeat geometry filter

Modified: trunk/qgis/src/app/qgspgsourceselect.cpp
===================================================================
--- trunk/qgis/src/app/qgspgsourceselect.cpp	2009-10-08 11:53:09 UTC (rev 11767)
+++ trunk/qgis/src/app/qgspgsourceselect.cpp	2009-10-08 12:16:13 UTC (rev 11768)
@@ -297,24 +297,30 @@
     int a = geomColumnName.indexOf( " AS " );
     QString typeName = geomColumnName.mid( a + 4 ); //only the type name
     geomColumnName = geomColumnName.left( a ); //only the geom column name
+    QString geomFilter;
 
-    if ( !sql.isEmpty() )
-    {
-      sql += " AND ";
-    }
-
     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;
+    }
   }
 
   QString uri = m_connectionInfo;



More information about the QGIS-commit mailing list