[qgis] 04/13: Add patch to fix mis-detection of PostGIS table types.

Bas Couwenberg sebastic at xs4all.nl
Fri Feb 14 17:08:19 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch master
in repository qgis.

commit 117e1a7ebf2acf74cf18819ba0b255ecce883dde
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Feb 8 05:41:27 2014 +0100

    Add patch to fix mis-detection of PostGIS table types.
---
 debian/changelog                                   |  1 +
 .../mis-detection-of-PostGIS-table-type.patch      | 67 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 69 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 68d0a76..94be5d4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ qgis (2.0.1-2) UNRELEASED; urgency=low
 
   [ Bas Couwenberg ]
   * Additional checks in qgis-providers-common.postinst 
+  * Add patch to fix mis-detection of PostGIS table types.
 
  -- Bas Couwenberg <sebastic at xs4all.nl>  Fri, 31 Jan 2014 19:42:03 +0100
 
diff --git a/debian/patches/mis-detection-of-PostGIS-table-type.patch b/debian/patches/mis-detection-of-PostGIS-table-type.patch
new file mode 100644
index 0000000..c51d13e
--- /dev/null
+++ b/debian/patches/mis-detection-of-PostGIS-table-type.patch
@@ -0,0 +1,67 @@
+From: Sandro Santilli <strk at keybit.net>
+Subject: Backport fix for mis-detection of PostGIS table types
+Origin: https://github.com/qgis/QGIS/commit/b90fb29ed2d25b9d988044c8dbb74e3a3f212ba5
+Bug: http://hub.qgis.org/issues/9421
+
+Don't try to detect geometry type or srid, if it's already known
+Backport of eaf5725f569fab62a67a51c0b0bddbb6a44797a2 by Jef
+
+--- a/src/providers/postgres/qgspostgresconn.cpp
++++ b/src/providers/postgres/qgspostgresconn.cpp
+@@ -1118,21 +1118,41 @@ void QgsPostgresConn::retrieveLayerTypes
+       table += QString( " WHERE %1" ).arg( layerProperty.sql );
+     }
+ 
+-    QString query = QString( "SELECT DISTINCT"
+-                             " CASE"
+-                             " WHEN %1 THEN 'POINT'"
+-                             " WHEN %2 THEN 'LINESTRING'"
+-                             " WHEN %3 THEN 'POLYGON'"
+-                             " END,"
+-                             " %4(%5%6)"
+-                             " FROM %7" )
+-                    .arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBPoint, layerProperty.geometryColType == sctGeography ) )
+-                    .arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBLineString, layerProperty.geometryColType == sctGeography ) )
+-                    .arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBPolygon, layerProperty.geometryColType == sctGeography ) )
+-                    .arg( majorVersion() < 2 ? "srid" : "st_srid" )
+-                    .arg( quotedIdentifier( layerProperty.geometryColName ) )
+-                    .arg( layerProperty.geometryColType == sctGeography ? "::geometry" : "" )
+-                    .arg( table );
++    QString query = "SELECT DISTINCT ";
++
++    QGis::WkbType type = layerProperty.types.value( 0, QGis::WKBUnknown );
++    if ( type == QGis::WKBUnknown )
++    {
++      query += QString( "CASE"
++                        " WHEN %1 THEN 'POINT'"
++                        " WHEN %2 THEN 'LINESTRING'"
++                        " WHEN %3 THEN 'POLYGON'"
++                        " END" )
++               .arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBPoint, layerProperty.geometryColType == sctGeography ) )
++               .arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBLineString, layerProperty.geometryColType == sctGeography ) )
++               .arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBPolygon, layerProperty.geometryColType == sctGeography ) );
++    }
++    else
++    {
++      query += quotedValue( QgsPostgresConn::postgisWkbTypeName( type ) );
++    }
++
++    query += ",";
++
++    int srid = layerProperty.srids.value( 0, INT_MIN );
++    if ( srid  == INT_MIN )
++    {
++      query += QString( "%1(%2%3)" )
++               .arg( majorVersion() < 2 ? "srid" : "st_srid" )
++               .arg( quotedIdentifier( layerProperty.geometryColName ) )
++               .arg( layerProperty.geometryColType == sctGeography ? "::geometry" : "" );
++    }
++    else
++    {
++      query += QString::number( srid );
++    }
++
++    query += " FROM " + table;
+ 
+     QgsDebugMsg( "Retrieving geometry types: " + query );
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 6cd4cf0..1a39578 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -27,3 +27,4 @@ python-env.patch
 wms-c-don-t-crash-if-tile-matrix-set-isn-t-available.patch
 use-local-icon.patch
 fix-qreal-vs-double.patch
+mis-detection-of-PostGIS-table-type.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/qgis.git



More information about the Pkg-grass-devel mailing list