Skip to content

Commit

Permalink
[Geometry checker] Move core classes to qgis_analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Oct 23, 2017
1 parent a555320 commit 767538b
Show file tree
Hide file tree
Showing 68 changed files with 240 additions and 179 deletions.
52 changes: 52 additions & 0 deletions src/analysis/CMakeLists.txt
Expand Up @@ -80,6 +80,32 @@ SET(QGIS_ANALYSIS_SRCS
network/qgsnetworkdistancestrategy.cpp
network/qgsvectorlayerdirector.cpp
network/qgsgraphanalyzer.cpp

vector/geometry_checker/qgsfeaturepool.cpp
vector/geometry_checker/qgsgeometrychecker.cpp
vector/geometry_checker/qgsgeometryanglecheck.cpp
vector/geometry_checker/qgsgeometryareacheck.cpp
vector/geometry_checker/qgsgeometrycheck.cpp
vector/geometry_checker/qgsgeometrychecker.cpp
vector/geometry_checker/qgsgeometrycheckerutils.cpp
vector/geometry_checker/qgsgeometrycontainedcheck.cpp
vector/geometry_checker/qgsgeometrydanglecheck.cpp
vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.cpp
vector/geometry_checker/qgsgeometryduplicatecheck.cpp
vector/geometry_checker/qgsgeometryduplicatenodescheck.cpp
vector/geometry_checker/qgsgeometrygapcheck.cpp
vector/geometry_checker/qgsgeometryholecheck.cpp
vector/geometry_checker/qgsgeometrylineintersectioncheck.cpp
vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.cpp
vector/geometry_checker/qgsgeometrymultipartcheck.cpp
vector/geometry_checker/qgsgeometryoverlapcheck.cpp
vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.cpp
vector/geometry_checker/qgsgeometrypointinpolygoncheck.cpp
vector/geometry_checker/qgsgeometrysegmentlengthcheck.cpp
vector/geometry_checker/qgsgeometryselfcontactcheck.cpp
vector/geometry_checker/qgsgeometryselfintersectioncheck.cpp
vector/geometry_checker/qgsgeometrysliverpolygoncheck.cpp
vector/geometry_checker/qgsgeometrytypecheck.cpp
)

SET(QGIS_ANALYSIS_MOC_HDRS
Expand All @@ -89,6 +115,32 @@ SET(QGIS_ANALYSIS_MOC_HDRS

network/qgsgraphdirector.h
network/qgsvectorlayerdirector.h

vector/geometry_checker/qgsfeaturepool.h
vector/geometry_checker/qgsgeometrychecker.h
vector/geometry_checker/qgsgeometryanglecheck.h
vector/geometry_checker/qgsgeometryareacheck.h
vector/geometry_checker/qgsgeometrychecker.h
vector/geometry_checker/qgsgeometrycheckerutils.h
vector/geometry_checker/qgsgeometrycheck.h
vector/geometry_checker/qgsgeometrycontainedcheck.h
vector/geometry_checker/qgsgeometrydanglecheck.h
vector/geometry_checker/qgsgeometrydegeneratepolygoncheck.h
vector/geometry_checker/qgsgeometryduplicatecheck.h
vector/geometry_checker/qgsgeometryduplicatenodescheck.h
vector/geometry_checker/qgsgeometrygapcheck.h
vector/geometry_checker/qgsgeometryholecheck.h
vector/geometry_checker/qgsgeometrylineintersectioncheck.h
vector/geometry_checker/qgsgeometrylinelayerintersectioncheck.h
vector/geometry_checker/qgsgeometrymultipartcheck.h
vector/geometry_checker/qgsgeometryoverlapcheck.h
vector/geometry_checker/qgsgeometrypointcoveredbylinecheck.h
vector/geometry_checker/qgsgeometrypointinpolygoncheck.h
vector/geometry_checker/qgsgeometrysegmentlengthcheck.h
vector/geometry_checker/qgsgeometryselfcontactcheck.h
vector/geometry_checker/qgsgeometryselfintersectioncheck.h
vector/geometry_checker/qgsgeometrysliverpolygoncheck.h
vector/geometry_checker/qgsgeometrytypecheck.h
)

INCLUDE_DIRECTORIES(SYSTEM ${SPATIALITE_INCLUDE_DIR})
Expand Down
Expand Up @@ -21,13 +21,14 @@
#include <QLinkedList>
#include <QMap>
#include <QMutex>
#include "qgis_analysis.h"
#include "qgsfeature.h"
#include "qgsspatialindex.h"
#include "qgsgeometrycheckerutils.h"

class QgsVectorLayer;

class QgsFeaturePool : public QObject
class ANALYSIS_EXPORT QgsFeaturePool : public QObject
{
Q_OBJECT
public:
Expand Down
Expand Up @@ -15,7 +15,7 @@

#include "qgsgeometryanglecheck.h"
#include "qgsgeometryutils.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

void QgsGeometryAngleCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryAngleCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryAngleCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -16,7 +16,7 @@
#include "qgsgeometryengine.h"
#include "qgsgeometrycollection.h"
#include "qgsgeometryareacheck.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

void QgsGeometryAreaCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
Expand Down
Expand Up @@ -20,7 +20,7 @@

class QgsSurface;

class QgsGeometryAreaCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryAreaCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -16,7 +16,7 @@
#include "qgsgeometrycollection.h"
#include "qgscurvepolygon.h"
#include "qgsgeometrycheck.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

QgsGeometryCheckerContext::QgsGeometryCheckerContext( int _precision, const QString &_mapCrs, const QMap<QString, QgsFeaturePool *> &_featurePools )
: tolerance( qPow( 10, -_precision ) )
Expand Down
Expand Up @@ -16,21 +16,22 @@
#ifndef QGS_GEOMETRY_CHECK_H
#define QGS_GEOMETRY_CHECK_H

#include <QApplication>
#include <limits>
#include <QStringList>
#include "qgis_analysis.h"
#include "qgsfeature.h"
#include "qgsvectorlayer.h"
#include "geometry/qgsgeometry.h"
#include "../utils/qgsgeometrycheckerutils.h"
#include "qgsgeometrycheckerutils.h"
#include "geos_c.h"
#include <QApplication>

class QgsGeometryCheckError;
class QgsFeaturePool;

#define FEATUREID_NULL std::numeric_limits<QgsFeatureId>::min()

struct QgsGeometryCheckerContext
struct ANALYSIS_EXPORT QgsGeometryCheckerContext
{
QgsGeometryCheckerContext( int _precision, const QString &_mapCrs, const QMap<QString, QgsFeaturePool *> &_featurePools );
const double tolerance;
Expand All @@ -39,7 +40,7 @@ struct QgsGeometryCheckerContext
const QMap<QString, QgsFeaturePool *> featurePools;
};

class QgsGeometryCheck : public QObject
class ANALYSIS_EXPORT QgsGeometryCheck : public QObject
{
Q_OBJECT

Expand Down Expand Up @@ -89,7 +90,7 @@ class QgsGeometryCheck : public QObject
};


class QgsGeometryCheckError
class ANALYSIS_EXPORT QgsGeometryCheckError
{
public:
enum Status { StatusPending, StatusFixFailed, StatusFixed, StatusObsolete };
Expand Down
Expand Up @@ -16,8 +16,8 @@

#include "qgscrscache.h"
#include "qgsgeometrychecker.h"
#include "checks/qgsgeometrycheck.h"
#include "utils/qgsfeaturepool.h"
#include "qgsgeometrycheck.h"
#include "qgsfeaturepool.h"

#include <QtConcurrentMap>
#include <QFutureWatcher>
Expand Down
Expand Up @@ -21,6 +21,7 @@
#include <QList>
#include <QMutex>
#include <QStringList>
#include "qgis_analysis.h"

typedef qint64 QgsFeatureId;
typedef QSet<QgsFeatureId> QgsFeatureIds;
Expand All @@ -31,7 +32,7 @@ class QgsMapLayer;
class QgsVectorLayer;
class QMutex;

class QgsGeometryChecker : public QObject
class ANALYSIS_EXPORT QgsGeometryChecker : public QObject
{
Q_OBJECT
public:
Expand Down
Expand Up @@ -30,25 +30,6 @@ class QgsFeaturePool;

namespace QgsGeometryCheckerUtils
{
class VScrollArea : public QScrollArea
{
public:
explicit VScrollArea( QWidget *parent = 0 )
: QScrollArea( parent )
{
setWidgetResizable( true );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
}
virtual bool eventFilter( QObject *o, QEvent *e )
{
// This works because QScrollArea::setWidget installs an eventFilter on the widget
if ( o && o == widget() && e->type() == QEvent::Resize )
setMinimumWidth( widget()->minimumSizeHint().width() + verticalScrollBar()->width() );
return QScrollArea::eventFilter( o, e );
}
};

class LayerFeature
{
public:
Expand Down
Expand Up @@ -15,7 +15,7 @@

#include "qgsgeometryengine.h"
#include "qgsgeometrycontainedcheck.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"


bool QgsGeometryContainedCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryContainedCheckError : public QgsGeometryCheckError
class ANALYSIS_EXPORT QgsGeometryContainedCheckError : public QgsGeometryCheckError
{
public:
QgsGeometryContainedCheckError( const QgsGeometryCheck *check,
Expand All @@ -45,7 +45,7 @@ class QgsGeometryContainedCheckError : public QgsGeometryCheckError
QPair<QString, QgsFeatureId> mContainingFeature;
};

class QgsGeometryContainedCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryContainedCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryDangleCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryDangleCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -14,7 +14,7 @@
***************************************************************************/

#include "qgsgeometrydegeneratepolygoncheck.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

void QgsGeometryDegeneratePolygonCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryDegeneratePolygonCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryDegeneratePolygonCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -17,7 +17,7 @@
#include "qgsgeometryduplicatecheck.h"
#include "qgsspatialindex.h"
#include "qgsgeometry.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"


bool QgsGeometryDuplicateCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryDuplicateCheckError : public QgsGeometryCheckError
class ANALYSIS_EXPORT QgsGeometryDuplicateCheckError : public QgsGeometryCheckError
{
public:
QgsGeometryDuplicateCheckError( const QgsGeometryCheck *check,
Expand Down Expand Up @@ -46,7 +46,7 @@ class QgsGeometryDuplicateCheckError : public QgsGeometryCheckError
static QString duplicatesString( const QMap<QString, QgsFeaturePool *> &featurePools, const QMap<QString, QList<QgsFeatureId>> &duplicates );
};

class QgsGeometryDuplicateCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryDuplicateCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -15,7 +15,7 @@

#include "qgsgeometryduplicatenodescheck.h"
#include "qgsgeometryutils.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

void QgsGeometryDuplicateNodesCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryDuplicateNodesCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryDuplicateNodesCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -16,7 +16,7 @@
#include "qgsgeometryengine.h"
#include "qgsgeometrygapcheck.h"
#include "qgsgeometrycollection.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

bool QgsGeometryGapCheckError::handleFidChanges( const QString &layerId, const QMap<QgsFeatureId, QgsFeatureId> &oldNewFidMap )
{
Expand Down
Expand Up @@ -19,7 +19,7 @@
#include "qgsgeometrycheck.h"


class QgsGeometryGapCheckError : public QgsGeometryCheckError
class ANALYSIS_EXPORT QgsGeometryGapCheckError : public QgsGeometryCheckError
{
public:
QgsGeometryGapCheckError( const QgsGeometryCheck *check,
Expand Down Expand Up @@ -73,7 +73,7 @@ class QgsGeometryGapCheckError : public QgsGeometryCheckError
QgsRectangle mGapAreaBBox;
};

class QgsGeometryGapCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryGapCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -14,7 +14,7 @@
***************************************************************************/

#include "qgsgeometryholecheck.h"
#include "../utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

void QgsGeometryHoleCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryHoleCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryHoleCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryLineIntersectionCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryLineIntersectionCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down
Expand Up @@ -16,7 +16,7 @@
#include "qgsgeometrylinelayerintersectioncheck.h"
#include "qgspolygon.h"
#include "qgslinestring.h"
#include "utils/qgsfeaturepool.h"
#include "qgsfeaturepool.h"

void QgsGeometryLineLayerIntersectionCheck::collectErrors( QList<QgsGeometryCheckError *> &errors, QStringList &/*messages*/, QAtomicInt *progressCounter, const QMap<QString, QgsFeatureIds> &ids ) const
{
Expand Down
Expand Up @@ -18,7 +18,7 @@

#include "qgsgeometrycheck.h"

class QgsGeometryLineLayerIntersectionCheck : public QgsGeometryCheck
class ANALYSIS_EXPORT QgsGeometryLineLayerIntersectionCheck : public QgsGeometryCheck
{
Q_OBJECT

Expand Down

0 comments on commit 767538b

Please sign in to comment.