Skip to content
Permalink
Browse files

QgsAbstractGeometryV2::wkbType always returns a valid type

  • Loading branch information
m-kuhn committed Jun 6, 2016
1 parent fdb28c0 commit c07f02d6dc814bc2857811a5600cd848e17ea137
Showing with 111 additions and 64 deletions.
  1. +0 −5 python/core/geometry/qgsabstractgeometryv2.sip
  2. +0 −1 python/core/geometry/qgscircularstringv2.sip
  3. +0 −1 python/core/geometry/qgscompoundcurvev2.sip
  4. +0 −1 python/core/geometry/qgscurvepolygonv2.sip
  5. +0 −1 python/core/geometry/qgsgeometrycollectionv2.sip
  6. +0 −1 python/core/geometry/qgslinestringv2.sip
  7. +0 −1 python/core/geometry/qgsmulticurvev2.sip
  8. +0 −1 python/core/geometry/qgsmultilinestringv2.sip
  9. +0 −1 python/core/geometry/qgsmultipointv2.sip
  10. +0 −1 python/core/geometry/qgsmultipolygonv2.sip
  11. +0 −1 python/core/geometry/qgsmultisurfacev2.sip
  12. +0 −1 python/core/geometry/qgspointv2.sip
  13. +1 −1 python/core/geometry/qgspolygonv2.sip
  14. +2 −7 src/core/geometry/qgsabstractgeometryv2.h
  15. +2 −2 src/core/geometry/qgscircularstringv2.cpp
  16. +0 −1 src/core/geometry/qgscircularstringv2.h
  17. +3 −2 src/core/geometry/qgscompoundcurvev2.cpp
  18. +0 −1 src/core/geometry/qgscompoundcurvev2.h
  19. +4 −3 src/core/geometry/qgscurvepolygonv2.cpp
  20. +0 −1 src/core/geometry/qgscurvepolygonv2.h
  21. +2 −3 src/core/geometry/qgsgeometrycollectionv2.cpp
  22. +0 −1 src/core/geometry/qgsgeometrycollectionv2.h
  23. +1 −1 src/core/geometry/qgslinestringv2.cpp
  24. +0 −1 src/core/geometry/qgslinestringv2.h
  25. +6 −0 src/core/geometry/qgsmulticurvev2.cpp
  26. +1 −1 src/core/geometry/qgsmulticurvev2.h
  27. +6 −0 src/core/geometry/qgsmultilinestringv2.cpp
  28. +1 −1 src/core/geometry/qgsmultilinestringv2.h
  29. +6 −0 src/core/geometry/qgsmultipointv2.cpp
  30. +1 −1 src/core/geometry/qgsmultipointv2.h
  31. +6 −0 src/core/geometry/qgsmultipolygonv2.cpp
  32. +1 −1 src/core/geometry/qgsmultipolygonv2.h
  33. +6 −0 src/core/geometry/qgsmultisurfacev2.cpp
  34. +1 −1 src/core/geometry/qgsmultisurfacev2.h
  35. +0 −1 src/core/geometry/qgspointv2.cpp
  36. +0 −1 src/core/geometry/qgspointv2.h
  37. +6 −0 src/core/geometry/qgspolygonv2.cpp
  38. +1 −1 src/core/geometry/qgspolygonv2.h
  39. +14 −15 tests/src/core/testqgsgeometry.cpp
  40. +39 −0 tests/src/python/test_qgsgeometry.py
  41. +1 −1 tests/src/python/test_qgssymbolv2.py
@@ -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
@@ -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();
@@ -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();
@@ -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();
@@ -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.*/
@@ -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();
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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();
@@ -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 );

@@ -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
@@ -28,7 +28,7 @@

QgsCircularStringV2::QgsCircularStringV2(): QgsCurveV2()
{

mWkbType = QgsWKBTypes::CircularString;
}

QgsCircularStringV2::~QgsCircularStringV2()
@@ -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();
}

@@ -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;
@@ -27,7 +27,7 @@

QgsCompoundCurveV2::QgsCompoundCurveV2(): QgsCurveV2()
{

mWkbType = QgsWKBTypes::CompoundCurve;
}

QgsCompoundCurveV2::~QgsCompoundCurveV2()
@@ -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() ) );
@@ -78,9 +79,9 @@ QgsCompoundCurveV2 *QgsCompoundCurveV2::clone() const

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

@@ -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;
@@ -28,7 +28,7 @@

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

mWkbType = QgsWKBTypes::CurvePolygon;
}

QgsCurvePolygonV2::~QgsCurvePolygonV2()
@@ -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() );
@@ -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();
}

@@ -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;
@@ -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;
@@ -72,7 +72,6 @@ void QgsGeometryCollectionV2::clear()
{
qDeleteAll( mGeometries );
mGeometries.clear();
mWkbType = QgsWKBTypes::Unknown;
clearCache(); //set bounding box invalid
}

@@ -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;

@@ -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 ) )
@@ -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.*/
@@ -87,7 +87,7 @@ void QgsLineStringV2::clear()
mY.clear();
mZ.clear();
mM.clear();
mWkbType = QgsWKBTypes::Unknown;
mWkbType = QgsWKBTypes::LineString;
clearCache();
}

@@ -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;
@@ -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 );
@@ -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;
@@ -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 );
@@ -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;
@@ -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 );
@@ -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;
@@ -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 );
@@ -27,8 +27,8 @@ email : marco.hugentobler at sourcepole dot com
class CORE_EXPORT QgsMultiPolygonV2: public QgsMultiSurfaceV2
{
public:
QgsMultiPolygonV2();
virtual QString geometryType() const override { return "MultiPolygon"; }
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::MultiPolygon; }
QgsMultiPolygonV2* clone() const override;

bool fromWkt( const QString& wkt ) override;

0 comments on commit c07f02d

Please sign in to comment.
You can’t perform that action at this time.