@@ -293,7 +293,6 @@ QString QgsPostgresFeatureIterator::whereClauseRect()
293
293
bool QgsPostgresFeatureIterator::declareCursor ( const QString& whereClause )
294
294
{
295
295
mFetchGeometry = !( mRequest .flags () & QgsFeatureRequest::NoGeometry ) && !P->mGeometryColumn .isNull ();
296
- bool simplifyGeometry = false ;
297
296
298
297
try
299
298
{
@@ -304,11 +303,10 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
304
303
if ( mFetchGeometry && !simplifyMethod.forceLocalOptimization () && simplifyMethod.methodType () != QgsSimplifyMethod::NoSimplification && QGis::flatType ( QGis::singleType ( P->geometryType () ) ) != QGis::WKBPoint )
305
304
{
306
305
QString simplifyFunctionName = simplifyMethod.methodType () == QgsSimplifyMethod::OptimizeForRendering
307
- ? ( P->mConnectionRO ->majorVersion () < 2 ? " simplify " : " st_simplify " )
306
+ ? ( P->mConnectionRO ->majorVersion () < 2 ? " snaptogrid " : " st_snaptogrid " )
308
307
: ( P->mConnectionRO ->majorVersion () < 2 ? " simplifypreservetopology" : " st_simplifypreservetopology" );
309
308
310
309
double tolerance = simplifyMethod.tolerance () * 0.8 ; // -> Default factor for the maximum displacement distance for simplification, similar as GeoServer does
311
- simplifyGeometry = simplifyMethod.methodType () == QgsSimplifyMethod::OptimizeForRendering;
312
310
313
311
query += QString ( " %1(%5(%2%3,%6),'%4')" )
314
312
.arg ( P->mConnectionRO ->majorVersion () < 2 ? " asbinary" : " st_asbinary" )
@@ -369,17 +367,6 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
369
367
query += delim + P->mConnectionRO ->fieldExpression ( P->field ( idx ) );
370
368
}
371
369
372
- // query BBOX of geometries to redefine the geometries collapsed by ST_Simplify()
373
- if ( simplifyGeometry && !( P->mConnectionRO ->majorVersion () >= 2 && P->mConnectionRO ->minorVersion () >= 1 ) )
374
- {
375
- query += QString ( " ,%1(%5(%2)%3,'%4')" )
376
- .arg ( P->mConnectionRO ->majorVersion () < 2 ? " asbinary" : " st_asbinary" )
377
- .arg ( P->quotedIdentifier ( P->mGeometryColumn ) )
378
- .arg ( P->mSpatialColType == sctGeography ? " ::geometry" : " " )
379
- .arg ( P->endianString () )
380
- .arg ( P->mConnectionRO ->majorVersion () < 2 ? " envelope" : " st_envelope" );
381
- }
382
-
383
370
query += " FROM " + P->mQuery ;
384
371
385
372
if ( !whereClause.isEmpty () )
@@ -603,43 +590,6 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int
603
590
getFeatureAttribute ( idx, queryResult, row, col, feature );
604
591
}
605
592
606
- // fix collapsed geometries by ST_Simplify() using the BBOX fetched from the current query
607
- const QgsSimplifyMethod& simplifyMethod = mRequest .simplifyMethod ();
608
- if ( mFetchGeometry && !simplifyMethod.forceLocalOptimization () && simplifyMethod.methodType () == QgsSimplifyMethod::OptimizeForRendering && QGis::flatType ( QGis::singleType ( P->geometryType () ) ) != QGis::WKBPoint )
609
- {
610
- QgsGeometry* geometry = feature.geometry ();
611
-
612
- if ( !( P->mConnectionRO ->majorVersion () >= 2 && P->mConnectionRO ->minorVersion () >= 1 ) && ( !geometry || geometry->length () == 0 ) )
613
- {
614
- int returnedLength = ::PQgetlength ( queryResult.result (), row, col );
615
-
616
- if ( returnedLength > 0 )
617
- {
618
- unsigned char *featureGeom = new unsigned char [returnedLength + 1 ];
619
- memcpy ( featureGeom, PQgetvalue ( queryResult.result (), row, col ), returnedLength );
620
- memset ( featureGeom + returnedLength, 0 , 1 );
621
-
622
- QgsGeometry *envelope = new QgsGeometry ();
623
- envelope->fromWkb ( featureGeom, returnedLength + 1 );
624
-
625
- if ( QGis::flatType ( QGis::singleType ( P->geometryType () ) ) == QGis::WKBPolygon )
626
- {
627
- feature.setGeometry ( envelope );
628
- }
629
- else
630
- {
631
- QgsPolyline polyline;
632
- polyline.append ( envelope->vertexAt ( 0 ) );
633
- polyline.append ( envelope->vertexAt ( 2 ) );
634
- delete envelope;
635
-
636
- geometry = QgsGeometry::fromPolyline ( polyline );
637
- feature.setGeometry ( geometry );
638
- }
639
- }
640
- }
641
- }
642
-
643
593
return true ;
644
594
}
645
595
catch ( QgsPostgresProvider::PGFieldNotFound )
0 commit comments