diff --git a/src/providers/postgres/qgspostgresfeatureiterator.cpp b/src/providers/postgres/qgspostgresfeatureiterator.cpp index 162390f7002c..6d05950484c7 100644 --- a/src/providers/postgres/qgspostgresfeatureiterator.cpp +++ b/src/providers/postgres/qgspostgresfeatureiterator.cpp @@ -293,7 +293,6 @@ QString QgsPostgresFeatureIterator::whereClauseRect() bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause ) { mFetchGeometry = !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) && !P->mGeometryColumn.isNull(); - bool simplifyGeometry = false; try { @@ -304,11 +303,10 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause ) if ( mFetchGeometry && !simplifyMethod.forceLocalOptimization() && simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification && QGis::flatType( QGis::singleType( P->geometryType() ) ) != QGis::WKBPoint ) { QString simplifyFunctionName = simplifyMethod.methodType() == QgsSimplifyMethod::OptimizeForRendering - ? ( P->mConnectionRO->majorVersion() < 2 ? "simplify" : "st_simplify" ) + ? ( P->mConnectionRO->majorVersion() < 2 ? "snaptogrid" : "st_snaptogrid" ) : ( P->mConnectionRO->majorVersion() < 2 ? "simplifypreservetopology" : "st_simplifypreservetopology" ); double tolerance = simplifyMethod.tolerance() * 0.8; //-> Default factor for the maximum displacement distance for simplification, similar as GeoServer does - simplifyGeometry = simplifyMethod.methodType() == QgsSimplifyMethod::OptimizeForRendering; query += QString( "%1(%5(%2%3,%6),'%4')" ) .arg( P->mConnectionRO->majorVersion() < 2 ? "asbinary" : "st_asbinary" ) @@ -369,17 +367,6 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause ) query += delim + P->mConnectionRO->fieldExpression( P->field( idx ) ); } - // query BBOX of geometries to redefine the geometries collapsed by ST_Simplify() - if ( simplifyGeometry && !( P->mConnectionRO->majorVersion() >= 2 && P->mConnectionRO->minorVersion() >= 1 ) ) - { - query += QString( ",%1(%5(%2)%3,'%4')" ) - .arg( P->mConnectionRO->majorVersion() < 2 ? "asbinary" : "st_asbinary" ) - .arg( P->quotedIdentifier( P->mGeometryColumn ) ) - .arg( P->mSpatialColType == sctGeography ? "::geometry" : "" ) - .arg( P->endianString() ) - .arg( P->mConnectionRO->majorVersion() < 2 ? "envelope" : "st_envelope" ); - } - query += " FROM " + P->mQuery; if ( !whereClause.isEmpty() ) @@ -603,43 +590,6 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int getFeatureAttribute( idx, queryResult, row, col, feature ); } - // fix collapsed geometries by ST_Simplify() using the BBOX fetched from the current query - const QgsSimplifyMethod& simplifyMethod = mRequest.simplifyMethod(); - if ( mFetchGeometry && !simplifyMethod.forceLocalOptimization() && simplifyMethod.methodType() == QgsSimplifyMethod::OptimizeForRendering && QGis::flatType( QGis::singleType( P->geometryType() ) ) != QGis::WKBPoint ) - { - QgsGeometry* geometry = feature.geometry(); - - if ( !( P->mConnectionRO->majorVersion() >= 2 && P->mConnectionRO->minorVersion() >= 1 ) && ( !geometry || geometry->length() == 0 ) ) - { - int returnedLength = ::PQgetlength( queryResult.result(), row, col ); - - if ( returnedLength > 0 ) - { - unsigned char *featureGeom = new unsigned char[returnedLength + 1]; - memcpy( featureGeom, PQgetvalue( queryResult.result(), row, col ), returnedLength ); - memset( featureGeom + returnedLength, 0, 1 ); - - QgsGeometry *envelope = new QgsGeometry(); - envelope->fromWkb( featureGeom, returnedLength + 1 ); - - if ( QGis::flatType( QGis::singleType( P->geometryType() ) ) == QGis::WKBPolygon ) - { - feature.setGeometry( envelope ); - } - else - { - QgsPolyline polyline; - polyline.append( envelope->vertexAt( 0 ) ); - polyline.append( envelope->vertexAt( 2 ) ); - delete envelope; - - geometry = QgsGeometry::fromPolyline( polyline ); - feature.setGeometry( geometry ); - } - } - } - } - return true; } catch ( QgsPostgresProvider::PGFieldNotFound )