mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
#8725-R: define QgsSimplifyMethod
Define QgsSimplifyMethod to use as optional parameter in QgsFeatureRequest
This commit is contained in:
parent
08b5e3058a
commit
6358fde727
@ -75,6 +75,7 @@ SET(QGIS_CORE_SRCS
|
||||
qgsgeometrycache.cpp
|
||||
qgsgeometryvalidator.cpp
|
||||
qgsgeometrysimplifier.cpp
|
||||
qgssimplifymethod.cpp
|
||||
qgsgml.cpp
|
||||
qgsgmlschema.cpp
|
||||
qgshttptransaction.cpp
|
||||
|
@ -70,6 +70,7 @@ QgsFeatureRequest& QgsFeatureRequest::operator=( const QgsFeatureRequest & rh )
|
||||
mFilterExpression = 0;
|
||||
}
|
||||
mAttrs = rh.mAttrs;
|
||||
mSimplifyMethod = rh.mSimplifyMethod;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -120,7 +121,6 @@ QgsFeatureRequest& QgsFeatureRequest::setSubsetOfAttributes( const QgsAttributeL
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
QgsFeatureRequest& QgsFeatureRequest::setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields )
|
||||
{
|
||||
mFlags |= SubsetOfAttributes;
|
||||
@ -135,6 +135,12 @@ QgsFeatureRequest& QgsFeatureRequest::setSubsetOfAttributes( const QStringList&
|
||||
return *this;
|
||||
}
|
||||
|
||||
QgsFeatureRequest& QgsFeatureRequest::setSimplifyMethod( const QgsSimplifyMethod& simplifyMethod )
|
||||
{
|
||||
mSimplifyMethod = simplifyMethod;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool QgsFeatureRequest::acceptFeature( const QgsFeature& feature )
|
||||
{
|
||||
switch ( mFilter )
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "qgsfeature.h"
|
||||
#include "qgsrectangle.h"
|
||||
#include "qgsexpression.h"
|
||||
#include "qgssimplifymethod.h"
|
||||
|
||||
#include <QList>
|
||||
typedef QList<int> QgsAttributeList;
|
||||
@ -36,6 +37,7 @@ typedef QList<int> QgsAttributeList;
|
||||
* For efficiency, it is also possible to tell provider that some data is not required:
|
||||
* - NoGeometry flag
|
||||
* - SubsetOfAttributes flag
|
||||
* - SimplifyMethod for geometries to fetch
|
||||
*
|
||||
* The options may be chained, e.g.:
|
||||
* QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest::ExactIntersect)
|
||||
@ -120,6 +122,10 @@ class CORE_EXPORT QgsFeatureRequest
|
||||
//! Set a subset of attributes by names that will be fetched
|
||||
QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
|
||||
|
||||
//! Set a simplification method for geometries that will be fetched
|
||||
QgsFeatureRequest& setSimplifyMethod( const QgsSimplifyMethod& simplifyMethod );
|
||||
const QgsSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
|
||||
|
||||
/**
|
||||
* Check if a feature is accepted by this requests filter
|
||||
*
|
||||
@ -143,6 +149,7 @@ class CORE_EXPORT QgsFeatureRequest
|
||||
QgsExpression* mFilterExpression;
|
||||
Flags mFlags;
|
||||
QgsAttributeList mAttrs;
|
||||
QgsSimplifyMethod mSimplifyMethod;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureRequest::Flags )
|
||||
|
52
src/core/qgssimplifymethod.cpp
Normal file
52
src/core/qgssimplifymethod.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
qgssimplifymethod.cpp
|
||||
---------------------
|
||||
begin : December 2013
|
||||
copyright : (C) 2013 by Matthias Kuhn / Alvaro Huarte
|
||||
email :
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgssimplifymethod.h"
|
||||
|
||||
QgsSimplifyMethod::QgsSimplifyMethod()
|
||||
: mMethodType( QgsSimplifyMethod::NoSimplification )
|
||||
, mTolerance( 1 )
|
||||
, mForceLocalOptimization( true )
|
||||
{
|
||||
}
|
||||
|
||||
QgsSimplifyMethod::QgsSimplifyMethod( const QgsSimplifyMethod &rh )
|
||||
{
|
||||
operator=( rh );
|
||||
}
|
||||
|
||||
QgsSimplifyMethod& QgsSimplifyMethod::operator=( const QgsSimplifyMethod &rh )
|
||||
{
|
||||
mMethodType = rh.mMethodType;
|
||||
mTolerance = rh.mTolerance;
|
||||
mForceLocalOptimization = rh.mForceLocalOptimization;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void QgsSimplifyMethod::setMethodType( MethodType methodType )
|
||||
{
|
||||
mMethodType = methodType;
|
||||
}
|
||||
|
||||
void QgsSimplifyMethod::setTolerance( double tolerance )
|
||||
{
|
||||
mTolerance = tolerance;
|
||||
}
|
||||
|
||||
void QgsSimplifyMethod::setForceLocalOptimization( bool localOptimization )
|
||||
{
|
||||
mForceLocalOptimization = localOptimization;
|
||||
}
|
63
src/core/qgssimplifymethod.h
Normal file
63
src/core/qgssimplifymethod.h
Normal file
@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
qgssimplifymethod.h
|
||||
---------------------
|
||||
begin : December 2013
|
||||
copyright : (C) 2013 by Matthias Kuhn / Alvaro Huarte
|
||||
email :
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSSIMPLIFYMETHOD_H
|
||||
#define QGSSIMPLIFYMETHOD_H
|
||||
|
||||
/**
|
||||
* This class contains information about how to simplify geometries fetched from a QgsFeatureIterator
|
||||
*/
|
||||
class CORE_EXPORT QgsSimplifyMethod
|
||||
{
|
||||
public:
|
||||
enum MethodType
|
||||
{
|
||||
NoSimplification, //!< No simplification is applied
|
||||
OptimizeForRendering, //!< Simplify using the map2pixel data to optimize the rendering of geometries
|
||||
PreserveTopology //!< Simplify using the Douglas-Peucker algorithm ensuring that the result is a valid geometry
|
||||
};
|
||||
|
||||
//! construct a default method
|
||||
QgsSimplifyMethod();
|
||||
//! copy constructor
|
||||
QgsSimplifyMethod( const QgsSimplifyMethod& rh );
|
||||
//! assignment operator
|
||||
QgsSimplifyMethod& operator=( const QgsSimplifyMethod& rh );
|
||||
|
||||
//! Sets the simplification type
|
||||
void setMethodType( MethodType methodType );
|
||||
//! Gets the simplification type
|
||||
inline MethodType methodType() const { return mMethodType; }
|
||||
|
||||
//! Sets the tolerance of simplification. Represents the maximum distance between two coordinates which can be considered equal
|
||||
void setTolerance( double tolerance );
|
||||
//! Gets the tolerance of simplification
|
||||
inline double tolerance() const { return mTolerance; }
|
||||
|
||||
//! Sets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries
|
||||
void setForceLocalOptimization( bool localOptimization );
|
||||
//! Gets whether the simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries
|
||||
inline bool forceLocalOptimization() const { return mForceLocalOptimization; }
|
||||
|
||||
protected:
|
||||
//! Simplification method
|
||||
MethodType mMethodType;
|
||||
//! Tolerance of simplification, it represents the maximum distance between two coordinates which can be considered equal
|
||||
double mTolerance;
|
||||
//! Simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries
|
||||
bool mForceLocalOptimization;
|
||||
};
|
||||
|
||||
#endif // QGSSIMPLIFYMETHOD_H
|
Loading…
x
Reference in New Issue
Block a user