Skip to content
Permalink
Browse files

postgres provider: use INT_MIN for unknown srid (fixes #7889)

  • Loading branch information
jef-n committed May 26, 2013
1 parent 7a47be2 commit 10a91b7fb964b1a36ca0693187e165713c4b3127
@@ -77,7 +77,7 @@ void QgsGeomColumnTypeThread::run()

if ( !layerProperty.geometryColName.isNull() &&
( layerProperty.types.value( 0, QGis::WKBUnknown ) == QGis::WKBUnknown ||
layerProperty.srids.value( 0, 0 ) <= 0 ) )
layerProperty.srids.value( 0, INT_MIN ) == INT_MIN ) )
{
if ( dontResolveType )
{
@@ -56,7 +56,7 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
wkbType = QGis::WKBNoGeometry;
}

bool selectable = wkbType == QGis::WKBNoGeometry || ( wkbType != QGis::WKBUnknown && srid >= 0 );
bool selectable = wkbType == QGis::WKBNoGeometry || ( wkbType != QGis::WKBUnknown && srid != INT_MIN );

QStandardItem *schemaNameItem = new QStandardItem( layerProperty.schemaName );
QStandardItem *typeItem = new QStandardItem( iconForWkbType( wkbType ), wkbType == QGis::WKBUnknown ? tr( "Select..." ) : QgsPostgresConn::displayStringForWkbType( wkbType ) );
@@ -70,7 +70,7 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
QStandardItem *tableItem = new QStandardItem( layerProperty.tableName );
QStandardItem *geomItem = new QStandardItem( layerProperty.geometryColName );
QStandardItem *sridItem = new QStandardItem( wkbType != QGis::WKBNoGeometry ? QString::number( srid ) : "" );
sridItem->setEditable( wkbType != QGis::WKBNoGeometry && srid < 0 );
sridItem->setEditable( wkbType != QGis::WKBNoGeometry && srid == INT_MIN );
if ( sridItem->isEditable() )
{
sridItem->setText( tr( "Enter..." ) );
@@ -250,7 +250,7 @@ bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, in
if ( ok && geomType != QGis::WKBNoGeometry )
{
int srid = idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );
ok &= srid >= 0;
ok &= srid != INT_MIN;
}

QStringList pkCols = idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
@@ -378,10 +378,15 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
QString schemaName = result.PQgetvalue( idx, 1 );
QString column = result.PQgetvalue( idx, 2 );
QString type = result.PQgetvalue( idx, 3 );
QString srid = result.PQgetvalue( idx, 4 );
QString ssrid = result.PQgetvalue( idx, 4 );
QString relkind = result.PQgetvalue( idx, 5 );
if ( srid.isEmpty() || srid == "0" )
srid = "-1";

int srid = ssrid.isEmpty() ? INT_MIN : ssrid.toInt();
if ( majorVersion() >= 2 && srid == 0 )
{
// 0 doesn't constraint => detect
srid = INT_MIN;
}

QgsDebugMsg( QString( "%1 : %2.%3.%4: %5 %6 %7" )
.arg( gtableName )
@@ -396,7 +401,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
layerProperty.geometryColName = column;
layerProperty.geometryColType = columnType;
layerProperty.types = QList<QGis::WkbType>() << ( QgsPostgresConn::wkbTypeFromPostgis( type ) );
layerProperty.srids = QList<int>() << srid.toInt();
layerProperty.srids = QList<int>() << srid;
layerProperty.sql = "";

if ( relkind == "v" )
@@ -572,7 +577,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
QgsDebugMsg( QString( "%1.%2: %3" ).arg( schema ).arg( table ).arg( relkind ) );

layerProperty.types = QList<QGis::WkbType>() << QGis::WKBNoGeometry;
layerProperty.srids = QList<int>() << -1;
layerProperty.srids = QList<int>() << INT_MIN;
layerProperty.schemaName = schema;
layerProperty.tableName = table;
layerProperty.geometryColName = QString::null;
@@ -122,9 +122,8 @@ void QgsPGConnectionItem::setLayerType( QgsPostgresLayerProperty layerProperties
for ( int i = 0; i < layerProperties.size(); i++ )
{
QgsPostgresLayerProperty layerProperty = layerProperties.at( i );

if ( layerProperty.types[0] == QGis::WKBUnknown ||
(!layerProperty.geometryColName.isEmpty() && layerProperty.srids[0] < 0 ) )
( !layerProperty.geometryColName.isEmpty() && layerProperty.srids[0] == INT_MIN ) )
continue;

if ( !schemaItem )

0 comments on commit 10a91b7

Please sign in to comment.
You can’t perform that action at this time.