Skip to content

Commit

Permalink
QgsAbstractGeometryV2::wkbType always returns a valid type
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 7, 2016
1 parent fdb28c0 commit c07f02d
Show file tree
Hide file tree
Showing 41 changed files with 111 additions and 64 deletions.
5 changes: 0 additions & 5 deletions python/core/geometry/qgsabstractgeometryv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ class QgsAbstractGeometryV2
*/
QgsWKBTypes::Type wkbType() const;

/** Returns the flat WKB type of the geometry class. Corresponds to information obtained from
* geometryType().
*/
virtual QgsWKBTypes::Type flatWkbType() const = 0;

/** Returns the WKT type string of the geometry.
* @see geometryType
* @see wkbType
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgscircularstringv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class QgsCircularStringV2: public QgsCurveV2
virtual bool operator!=( const QgsCurveV2& other ) const;

virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual int dimension() const;
virtual QgsCircularStringV2* clone() const;
virtual void clear();
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgscompoundcurvev2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class QgsCompoundCurveV2: public QgsCurveV2
virtual bool operator!=( const QgsCurveV2& other ) const;

virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual int dimension() const;
virtual QgsCompoundCurveV2* clone() const;
virtual void clear();
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgscurvepolygonv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
~QgsCurvePolygonV2();

virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual int dimension() const;
virtual QgsCurvePolygonV2* clone() const;
void clear();
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgsgeometrycollectionv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
//methods inherited from QgsAbstractGeometry
virtual int dimension() const;
virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual void clear();

/** Adds a geometry and takes ownership. Returns true in case of success.*/
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgslinestringv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class QgsLineStringV2: public QgsCurveV2
//reimplemented methods

virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual int dimension() const;
virtual QgsLineStringV2* clone() const /Factory/;
virtual void clear();
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgsmulticurvev2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class QgsMultiCurveV2: public QgsGeometryCollectionV2

public:
virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual QgsMultiCurveV2* clone() const;

bool fromWkt( const QString& wkt );
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgsmultilinestringv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class QgsMultiLineStringV2: public QgsMultiCurveV2

public:
virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual QgsMultiLineStringV2* clone() const;

bool fromWkt( const QString& wkt );
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgsmultipointv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class QgsMultiPointV2: public QgsGeometryCollectionV2
%End
public:
virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual QgsMultiPointV2* clone() const;

bool fromWkt( const QString& wkt );
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgsmultipolygonv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class QgsMultiPolygonV2: public QgsMultiSurfaceV2
%End
public:
virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual QgsMultiPolygonV2* clone() const;

bool fromWkt( const QString& wkt );
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgsmultisurfacev2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class QgsMultiSurfaceV2: public QgsGeometryCollectionV2
%End
public:
virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual QgsMultiSurfaceV2* clone() const;

bool fromWkt( const QString& wkt );
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgspointv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class QgsPointV2: public QgsAbstractGeometryV2
//implementation of inherited methods
virtual QgsRectangle boundingBox() const;
virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual int dimension() const;
virtual QgsPointV2* clone() const /Factory/;
void clear();
Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgspolygonv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class QgsPolygonV2: public QgsCurvePolygonV2
bool operator!=( const QgsPolygonV2& other ) const;

virtual QString geometryType() const;
virtual QgsWKBTypes::Type flatWkbType() const;
virtual QgsPolygonV2* clone() const;
void clear();

virtual bool fromWkb( QgsConstWkbPtr wkb );

Expand Down
9 changes: 2 additions & 7 deletions src/core/geometry/qgsabstractgeometryv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,18 @@ class CORE_EXPORT QgsAbstractGeometryV2
virtual int dimension() const = 0;
//virtual int coordDim() const { return mCoordDimension; }

/** Returns a unique string representing the geometry class type.
/** Returns a unique string representing the geometry type.
* @see wkbType
* @see wktTypeStr
*/
virtual QString geometryType() const = 0;

/** Returns the WKB type of the saved geometry.
/** Returns the WKB type of the geometry.
* @see geometryType
* @see wktTypeStr
*/
QgsWKBTypes::Type wkbType() const { return mWkbType; }

/** Returns the flat WKB type of the geometry class. Corresponds to information obtained from
* geometryType().
*/
virtual QgsWKBTypes::Type flatWkbType() const = 0;

/** Returns the WKT type string of the geometry.
* @see geometryType
* @see wkbType
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgscircularstringv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

QgsCircularStringV2::QgsCircularStringV2(): QgsCurveV2()
{

mWkbType = QgsWKBTypes::CircularString;
}

QgsCircularStringV2::~QgsCircularStringV2()
Expand Down Expand Up @@ -57,11 +57,11 @@ QgsCircularStringV2 *QgsCircularStringV2::clone() const

void QgsCircularStringV2::clear()
{
mWkbType = QgsWKBTypes::CircularString;
mX.clear();
mY.clear();
mZ.clear();
mM.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache();
}

Expand Down
1 change: 0 additions & 1 deletion src/core/geometry/qgscircularstringv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class CORE_EXPORT QgsCircularStringV2: public QgsCurveV2
virtual bool operator!=( const QgsCurveV2& other ) const override;

virtual QString geometryType() const override { return "CircularString"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::CircularString; }
virtual int dimension() const override { return 1; }
virtual QgsCircularStringV2* clone() const override;
virtual void clear() override;
Expand Down
5 changes: 3 additions & 2 deletions src/core/geometry/qgscompoundcurvev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

QgsCompoundCurveV2::QgsCompoundCurveV2(): QgsCurveV2()
{

mWkbType = QgsWKBTypes::CompoundCurve;
}

QgsCompoundCurveV2::~QgsCompoundCurveV2()
Expand All @@ -51,6 +51,7 @@ bool QgsCompoundCurveV2::operator!=( const QgsCurveV2& other ) const

QgsCompoundCurveV2::QgsCompoundCurveV2( const QgsCompoundCurveV2& curve ): QgsCurveV2( curve )
{
mWkbType = QgsWKBTypes::CompoundCurve;
Q_FOREACH ( const QgsCurveV2* c, curve.mCurves )
{
mCurves.append( static_cast<QgsCurveV2*>( c->clone() ) );
Expand Down Expand Up @@ -78,9 +79,9 @@ QgsCompoundCurveV2 *QgsCompoundCurveV2::clone() const

void QgsCompoundCurveV2::clear()
{
mWkbType = QgsWKBTypes::CompoundCurve;
qDeleteAll( mCurves );
mCurves.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache();
}

Expand Down
1 change: 0 additions & 1 deletion src/core/geometry/qgscompoundcurvev2.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class CORE_EXPORT QgsCompoundCurveV2: public QgsCurveV2
virtual bool operator!=( const QgsCurveV2& other ) const override;

virtual QString geometryType() const override { return "CompoundCurve"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::CompoundCurve; }
virtual int dimension() const override { return 1; }
virtual QgsCompoundCurveV2* clone() const override;
virtual void clear() override;
Expand Down
7 changes: 4 additions & 3 deletions src/core/geometry/qgscurvepolygonv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

QgsCurvePolygonV2::QgsCurvePolygonV2(): QgsSurfaceV2(), mExteriorRing( nullptr )
{

mWkbType = QgsWKBTypes::CurvePolygon;
}

QgsCurvePolygonV2::~QgsCurvePolygonV2()
Expand All @@ -40,6 +40,7 @@ QgsCurvePolygonV2::QgsCurvePolygonV2( const QgsCurvePolygonV2& p )
: QgsSurfaceV2( p )
, mExteriorRing( nullptr )
{
mWkbType = p.mWkbType;
if ( p.mExteriorRing )
{
mExteriorRing = static_cast<QgsCurveV2*>( p.mExteriorRing->clone() );
Expand Down Expand Up @@ -77,11 +78,11 @@ QgsCurvePolygonV2* QgsCurvePolygonV2::clone() const

void QgsCurvePolygonV2::clear()
{
mWkbType = QgsWKBTypes::CurvePolygon;
delete mExteriorRing;
mExteriorRing = nullptr;
qDeleteAll( mInteriorRings );
mInteriorRings.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache();
}

Expand Down Expand Up @@ -149,7 +150,7 @@ bool QgsCurvePolygonV2::fromWkt( const QString& wkt )

QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );

if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::Polygon )
if ( QgsWKBTypes::geometryType( parts.first ) != QgsWKBTypes::PolygonGeometry )
return false;

mWkbType = parts.first;
Expand Down
1 change: 0 additions & 1 deletion src/core/geometry/qgscurvepolygonv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class CORE_EXPORT QgsCurvePolygonV2: public QgsSurfaceV2
~QgsCurvePolygonV2();

virtual QString geometryType() const override { return "CurvePolygon"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::CurvePolygon; }
virtual int dimension() const override { return 2; }
virtual QgsCurvePolygonV2* clone() const override;
void clear() override;
Expand Down
5 changes: 2 additions & 3 deletions src/core/geometry/qgsgeometrycollectionv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ void QgsGeometryCollectionV2::clear()
{
qDeleteAll( mGeometries );
mGeometries.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache(); //set bounding box invalid
}

Expand Down Expand Up @@ -491,7 +490,7 @@ bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList

QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );

if ( QgsWKBTypes::flatType( parts.first ) != flatWkbType() )
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::flatType( wkbType() ) )
return false;
mWkbType = parts.first;

Expand All @@ -504,7 +503,7 @@ bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList
bool success = false;
Q_FOREACH ( const QgsAbstractGeometryV2* geom, subtypes )
{
if ( QgsWKBTypes::flatType( childParts.first ) == geom->flatWkbType() )
if ( QgsWKBTypes::flatType( childParts.first ) == QgsWKBTypes::flatType( geom->wkbType() ) )
{
mGeometries.append( geom->clone() );
if ( mGeometries.back()->fromWkt( childWkt ) )
Expand Down
1 change: 0 additions & 1 deletion src/core/geometry/qgsgeometrycollectionv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class CORE_EXPORT QgsGeometryCollectionV2: public QgsAbstractGeometryV2
//methods inherited from QgsAbstractGeometry
virtual int dimension() const override;
virtual QString geometryType() const override { return "GeometryCollection"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::GeometryCollection; }
virtual void clear() override;

/** Adds a geometry and takes ownership. Returns true in case of success.*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgslinestringv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void QgsLineStringV2::clear()
mY.clear();
mZ.clear();
mM.clear();
mWkbType = QgsWKBTypes::Unknown;
mWkbType = QgsWKBTypes::LineString;
clearCache();
}

Expand Down
1 change: 0 additions & 1 deletion src/core/geometry/qgslinestringv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class CORE_EXPORT QgsLineStringV2: public QgsCurveV2
//reimplemented methods

virtual QString geometryType() const override { return "LineString"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::LineString; }
virtual int dimension() const override { return 1; }
virtual QgsLineStringV2* clone() const override;
virtual void clear() override;
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgsmulticurvev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ email : marco.hugentobler at sourcepole dot com
#include "qgsgeometryutils.h"
#include "qgslinestringv2.h"

QgsMultiCurveV2::QgsMultiCurveV2()
: QgsGeometryCollectionV2()
{
mWkbType = QgsWKBTypes::MultiCurve;
}

QgsMultiCurveV2 *QgsMultiCurveV2::clone() const
{
return new QgsMultiCurveV2( *this );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsmulticurvev2.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ email : marco.hugentobler at sourcepole dot com
class CORE_EXPORT QgsMultiCurveV2: public QgsGeometryCollectionV2
{
public:
QgsMultiCurveV2();
virtual QString geometryType() const override { return "MultiCurve"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::MultiCurve; }
QgsMultiCurveV2* clone() const override;

bool fromWkt( const QString& wkt ) override;
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgsmultilinestringv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ email : marco.hugentobler at sourcepole dot com
#include "qgslinestringv2.h"
#include "qgsmulticurvev2.h"

QgsMultiLineStringV2::QgsMultiLineStringV2()
: QgsMultiCurveV2()
{
mWkbType = QgsWKBTypes::MultiLineString;
}

QgsMultiLineStringV2* QgsMultiLineStringV2::clone() const
{
return new QgsMultiLineStringV2( *this );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsmultilinestringv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ email : marco.hugentobler at sourcepole dot com
class CORE_EXPORT QgsMultiLineStringV2: public QgsMultiCurveV2
{
public:
QgsMultiLineStringV2();
virtual QString geometryType() const override { return "MultiLineString"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::MultiLineString; }
QgsMultiLineStringV2* clone() const override;

bool fromWkt( const QString& wkt ) override;
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgsmultipointv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ email : marco.hugentobler at sourcepole dot com
#include "qgspointv2.h"
#include "qgswkbptr.h"

QgsMultiPointV2::QgsMultiPointV2()
: QgsGeometryCollectionV2()
{
mWkbType = QgsWKBTypes::MultiPoint;
}

QgsMultiPointV2 *QgsMultiPointV2::clone() const
{
return new QgsMultiPointV2( *this );
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsmultipointv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ email : marco.hugentobler at sourcepole dot com
class CORE_EXPORT QgsMultiPointV2: public QgsGeometryCollectionV2
{
public:
QgsMultiPointV2();
virtual QString geometryType() const override { return "MultiPoint"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::MultiPoint; }
QgsMultiPointV2* clone() const override;

bool fromWkt( const QString& wkt ) override;
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgsmultipolygonv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ email : marco.hugentobler at sourcepole dot com
#include "qgspolygonv2.h"
#include "qgscurvepolygonv2.h"

QgsMultiPolygonV2::QgsMultiPolygonV2()
: QgsMultiSurfaceV2()
{
mWkbType = QgsWKBTypes::MultiPolygon;
}

QgsMultiPolygonV2 *QgsMultiPolygonV2::clone() const
{
return new QgsMultiPolygonV2( *this );
Expand Down