Skip to content

Commit

Permalink
add support for mixed case geometry types of PostGIS 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 5, 2011
1 parent a637ebc commit 97f8039
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/app/postgres/qgspgsourceselect.cpp
Expand Up @@ -345,15 +345,15 @@ QString QgsPgSourceSelect::layerURI( const QModelIndex &index )

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

if ( !geomFilter.isEmpty() && !sql.contains( geomFilter ) )
Expand Down Expand Up @@ -972,9 +972,9 @@ void QgsGeomColumnTypeThread::getLayerTypes()
{
QString query = QString( "select distinct "
"case"
" when geometrytype(%1) IN ('POINT','MULTIPOINT') THEN 'POINT'"
" when geometrytype(%1) IN ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING'"
" when geometrytype(%1) IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON'"
" when upper(geometrytype(%1)) IN ('POINT','MULTIPOINT') THEN 'POINT'"
" when upper(geometrytype(%1)) IN ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING'"
" when upper(geometrytype(%1)) IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON'"
" end "
"from " ).arg( "\"" + columns[i] + "\"" );
if ( mUseEstimatedMetadata )
Expand Down
10 changes: 5 additions & 5 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -3213,7 +3213,7 @@ bool QgsPostgresProvider::getGeometryDetails()
}
}

sql = QString( "select type,srid from geometry_columns"
sql = QString( "select upper(type),srid from geometry_columns"
" where f_table_name=%1 and f_geometry_column=%2 and f_table_schema=%3" )
.arg( quotedValue( tableName ) )
.arg( quotedValue( geomCol ) )
Expand Down Expand Up @@ -3257,7 +3257,7 @@ bool QgsPostgresProvider::getGeometryDetails()
// Didn't find what we need in the geometry_columns table, so
// get stuff from the relevant column instead. This may (will?)
// fail if there is no data in the relevant table.
sql = QString( "select %1(%2),geometrytype(%2) from %3" )
sql = QString( "select %1(%2),upper(geometrytype(%2)) from %3" )
.arg( connectionRO->majorVersion() < 2 ? "srid" : "st_srid" )
.arg( quotedIdentifier( geometryColumn ) )
.arg( mQuery );
Expand Down Expand Up @@ -3287,9 +3287,9 @@ bool QgsPostgresProvider::getGeometryDetails()
// check to see if there is a unique geometry type
sql = QString( "select distinct "
"case"
" when geometrytype(%1) IN ('POINT','MULTIPOINT') THEN 'POINT'"
" when geometrytype(%1) IN ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING'"
" when geometrytype(%1) IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON'"
" when upper(geometrytype(%1)) IN ('POINT','MULTIPOINT') THEN 'POINT'"
" when upper(geometrytype(%1)) IN ('LINESTRING','MULTILINESTRING') THEN 'LINESTRING'"
" when upper(geometrytype(%1)) IN ('POLYGON','MULTIPOLYGON') THEN 'POLYGON'"
" end "
"from " ).arg( quotedIdentifier( geometryColumn ) );
if ( mUseEstimatedMetadata )
Expand Down

0 comments on commit 97f8039

Please sign in to comment.