QGIS_oracle_pre_rendering_simplification.diff

Michael Douchin, 2015-03-06 09:40 AM

Download (4.45 KB)

View differences:

src/providers/oracle/qgsoraclefeatureiterator.cpp
236 236
  }
237 237
}
238 238

  
239
bool QgsOracleFeatureIterator::prepareSimplification( const QgsSimplifyMethod& simplifyMethod )
240
{
241
  // setup simplification of geometries to fetch
242
  if ( !( mRequest.flags() & QgsFeatureRequest::NoGeometry ) &&
243
       simplifyMethod.methodType() != QgsSimplifyMethod::NoSimplification &&
244
       !simplifyMethod.forceLocalOptimization() )
245
  {
246
    QgsSimplifyMethod::MethodType methodType = simplifyMethod.methodType();
247

  
248
    if ( methodType == QgsSimplifyMethod::OptimizeForRendering || methodType == QgsSimplifyMethod::PreserveTopology )
249
    {
250
      return true;
251
    }
252
    else
253
    {
254
      QgsDebugMsg( QString( "Simplification method type (%1) is not recognised by OracleFeatureIterator" ).arg( methodType ) );
255
    }
256
  }
257
  return QgsAbstractFeatureIterator::prepareSimplification( simplifyMethod );
258
}
259

  
260
bool QgsOracleFeatureIterator::providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const
261
{
262
  return methodType == QgsSimplifyMethod::OptimizeForRendering || methodType == QgsSimplifyMethod::PreserveTopology;
263
}
264

  
239 265
bool QgsOracleFeatureIterator::rewind()
240 266
{
241 267
  if ( !mQry.isActive() )
......
268 294

  
269 295
    if (( mRequest.flags() & QgsFeatureRequest::NoGeometry ) == 0 && !mSource->mGeometryColumn.isNull() )
270 296
    {
271
      query += QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn );
297
      QString geom = QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn );
298

  
299
      if ( !mRequest.simplifyMethod().forceLocalOptimization() &&
300
           mRequest.simplifyMethod().methodType() != QgsSimplifyMethod::NoSimplification &&
301
           QGis::flatType( QGis::singleType( mSource->mRequestedGeomType != QGis::WKBUnknown
302
                                             ? mSource->mRequestedGeomType
303
                                             : mSource->mDetectedGeomType ) ) != QGis::WKBPoint )
304
      {
305
        if ( mRequest.simplifyMethod().methodType() == QgsSimplifyMethod::OptimizeForRendering )
306
        {
307
          geom = QString( "%1( %2, %3 )" )
308
               .arg( "SDO_UTIL.RECTIFY_GEOMETRY" )
309
               .arg( geom )
310
               .arg( mRequest.simplifyMethod().tolerance() * 0.8);
311
        }
312
        else
313
        {
314
          geom = QString( "%1( %2, %3, %4 )" )
315
               .arg( "SDO_UTIL.SIMPLIFY" )
316
               .arg( geom )
317
               .arg( mRequest.simplifyMethod().tolerance() * 0.8 )
318
               .arg( mRequest.simplifyMethod().tolerance() * 0.8 );
319

  
320
        }
321
      }
322

  
323
      query += geom;
272 324
      delim = ",";
273 325
    }
274 326

  
src/providers/oracle/qgsoraclefeatureiterator.h
72 72
    //! fetch next feature, return true on success
73 73
    virtual bool fetchFeature( QgsFeature& feature );
74 74

  
75
    //! Setup the simplification of geometries to fetch using the specified simplify method
76
    virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod ) override;
77

  
75 78
    bool openQuery( QString whereClause );
76 79

  
77 80
    QgsOracleConn *mConnection;
78 81
    QSqlQuery mQry;
79 82
    bool mRewind;
80 83
    QgsAttributeList mAttributeList;
84

  
85
  private:
86
    //! returns whether the iterator supports simplify geometries on provider side
87
    virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const override;
81 88
};
82 89

  
83 90
#endif // QGSORACLEFEATUREITERATOR_H
src/providers/oracle/qgsoracleprovider.cpp
836 836

  
837 837
  qry.finish();
838 838

  
839
  // supports geometry simplification on provider side
840
  mEnabledCapabilities |= ( QgsVectorDataProvider::SimplifyGeometries | QgsVectorDataProvider::SimplifyGeometriesWithTopologicalValidation );
841

  
839 842
  return true;
840 843
}
841 844