LCOV - code coverage report
Current view: top level - core - qgsvectorsimplifymethod.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 12 14 85.7 %
Date: 2021-04-10 08:29:14 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :     qgsvectorsimplifymethod.h
       3                 :            :     ---------------------
       4                 :            :     begin                : December 2013
       5                 :            :     copyright            : (C) 2013 by Alvaro Huarte
       6                 :            :     email                : http://wiki.osgeo.org/wiki/Alvaro_Huarte
       7                 :            :  ***************************************************************************
       8                 :            :  *                                                                         *
       9                 :            :  *   This program is free software; you can redistribute it and/or modify  *
      10                 :            :  *   it under the terms of the GNU General Public License as published by  *
      11                 :            :  *   the Free Software Foundation; either version 2 of the License, or     *
      12                 :            :  *   (at your option) any later version.                                   *
      13                 :            :  *                                                                         *
      14                 :            :  ***************************************************************************/
      15                 :            : 
      16                 :            : #ifndef QGSVECTORSIMPLIFYMETHOD_H
      17                 :            : #define QGSVECTORSIMPLIFYMETHOD_H
      18                 :            : 
      19                 :            : #include <QFlags>
      20                 :            : #include <QObject>
      21                 :            : 
      22                 :            : #include "qgis_core.h"
      23                 :            : 
      24                 :            : /**
      25                 :            :  * \ingroup core
      26                 :            :  * \brief This class contains information how to simplify geometries fetched from a vector layer
      27                 :            :  * \since QGIS 2.2
      28                 :            :  */
      29                 :            : class CORE_EXPORT QgsVectorSimplifyMethod
      30                 :            : {
      31                 :            :     Q_GADGET
      32                 :            :   public:
      33                 :            :     //! construct a default object
      34                 :            :     QgsVectorSimplifyMethod();
      35                 :            : 
      36                 :            :     //! Simplification flags for fast rendering of features
      37                 :            :     enum SimplifyHint
      38                 :            :     {
      39                 :            :       NoSimplification           = 0, //!< No simplification can be applied
      40                 :            :       GeometrySimplification     = 1, //!< The geometries can be simplified using the current map2pixel context state
      41                 :            :       AntialiasingSimplification = 2, //!< The geometries can be rendered with 'AntiAliasing' disabled because of it is '1-pixel size'
      42                 :            :       FullSimplification         = 3, //!< All simplification hints can be applied ( Geometry + AA-disabling )
      43                 :            :     };
      44                 :            :     Q_ENUM( SimplifyHint )
      45                 :            :     Q_DECLARE_FLAGS( SimplifyHints, SimplifyHint )
      46                 :        156 :     Q_FLAG( SimplifyHints )
      47                 :            : 
      48                 :            :     //! Sets the simplification hints of the vector layer managed
      49                 :         84 :     void setSimplifyHints( SimplifyHints simplifyHints ) { mSimplifyHints = simplifyHints; }
      50                 :            :     //! Gets the simplification hints of the vector layer managed
      51                 :         78 :     inline SimplifyHints simplifyHints() const { return mSimplifyHints; }
      52                 :            : 
      53                 :            :     //! Types of local simplification algorithms that can be used
      54                 :            :     enum SimplifyAlgorithm
      55                 :            :     {
      56                 :            :       Distance    = 0, //!< The simplification uses the distance between points to remove duplicate points
      57                 :            :       SnapToGrid  = 1, //!< The simplification uses a grid (similar to ST_SnapToGrid) to remove duplicate points
      58                 :            :       Visvalingam = 2, //!< The simplification gives each point in a line an importance weighting, so that least important points are removed first
      59                 :            :       SnappedToGridGlobal = 3, //!< Snap to a global grid based on the tolerance. Good for consistent results for incoming vertices, regardless of their feature
      60                 :            :     };
      61                 :        156 :     Q_ENUM( SimplifyAlgorithm )
      62                 :            : 
      63                 :            :     //! Sets the local simplification algorithm of the vector layer managed
      64                 :         78 :     void setSimplifyAlgorithm( SimplifyAlgorithm simplifyAlgorithm ) { mSimplifyAlgorithm = simplifyAlgorithm; }
      65                 :            :     //! Gets the local simplification algorithm of the vector layer managed
      66                 :         78 :     inline SimplifyAlgorithm simplifyAlgorithm() const { return mSimplifyAlgorithm; }
      67                 :            : 
      68                 :            :     //! Sets the tolerance of simplification in map units. Represents the maximum distance in map units between two coordinates which can be considered equal
      69                 :          0 :     void setTolerance( double tolerance ) { mTolerance = tolerance; }
      70                 :            :     //! Gets the tolerance of simplification in map units. Represents the maximum distance in map units between two coordinates which can be considered equal
      71                 :          0 :     inline double tolerance() const { return mTolerance; }
      72                 :            : 
      73                 :            :     //! Sets the simplification threshold of the vector layer managed
      74                 :         78 :     void setThreshold( float threshold ) { mThreshold = threshold; }
      75                 :            :     //! Gets the simplification threshold of the vector layer managed
      76                 :         78 :     inline float threshold() const { return mThreshold; }
      77                 :            : 
      78                 :            :     //! Sets where the simplification executes, after fetch the geometries from provider, or when supported, in provider before fetch the geometries
      79                 :         78 :     void setForceLocalOptimization( bool localOptimization ) { mLocalOptimization = localOptimization; }
      80                 :            :     //! Gets where the simplification executes, after fetch the geometries from provider, or when supported, in provider before fetch the geometries
      81                 :         78 :     inline bool forceLocalOptimization() const { return mLocalOptimization; }
      82                 :            : 
      83                 :            :     //! Sets the maximum scale at which the layer should be simplified
      84                 :         78 :     void setMaximumScale( float maximumScale ) { mMaximumScale = maximumScale; }
      85                 :            :     //! Gets the maximum scale at which the layer should be simplified
      86                 :         78 :     inline float maximumScale() const { return mMaximumScale; }
      87                 :            : 
      88                 :            :   private:
      89                 :            :     //! Simplification hints for fast rendering of features of the vector layer managed
      90                 :            :     SimplifyHints mSimplifyHints;
      91                 :            :     //! Simplification algorithm
      92                 :            :     SimplifyAlgorithm mSimplifyAlgorithm = QgsVectorSimplifyMethod::Distance;
      93                 :            :     //! Simplification tolerance, it represents the maximum distance between two coordinates which can be considered equal
      94                 :            :     double mTolerance = 1;
      95                 :            :     //! Simplification threshold
      96                 :            :     float mThreshold;
      97                 :            :     //! Simplification executes after fetch the geometries from provider, otherwise it executes, when supported, in provider before fetch the geometries
      98                 :            :     bool mLocalOptimization = true;
      99                 :            :     //! Maximum scale at which the layer should be simplified (Maximum scale at which generalisation should be carried out)
     100                 :            :     float mMaximumScale = 1;
     101                 :            : };
     102                 :            : 
     103                 :            : Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorSimplifyMethod::SimplifyHints )
     104                 :            : 
     105                 :            : #endif // QGSVECTORSIMPLIFYMETHOD_H

Generated by: LCOV version 1.14