mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
More string comparison fixes
This commit is contained in:
parent
d0feea57c1
commit
fdb28c09aa
@ -114,6 +114,11 @@ 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,6 +12,7 @@ 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,6 +14,7 @@ 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,6 +11,7 @@ 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,6 +29,7 @@ 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,6 +113,7 @@ 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,6 +6,7 @@ class QgsMultiCurveV2: public QgsGeometryCollectionV2
|
||||
|
||||
public:
|
||||
virtual QString geometryType() const;
|
||||
virtual QgsWKBTypes::Type flatWkbType() const;
|
||||
virtual QgsMultiCurveV2* clone() const;
|
||||
|
||||
bool fromWkt( const QString& wkt );
|
||||
|
@ -6,6 +6,7 @@ class QgsMultiLineStringV2: public QgsMultiCurveV2
|
||||
|
||||
public:
|
||||
virtual QString geometryType() const;
|
||||
virtual QgsWKBTypes::Type flatWkbType() const;
|
||||
virtual QgsMultiLineStringV2* clone() const;
|
||||
|
||||
bool fromWkt( const QString& wkt );
|
||||
|
@ -5,6 +5,7 @@ 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,6 +5,7 @@ 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,6 +5,7 @@ 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,6 +141,7 @@ 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,6 +11,7 @@ class QgsPolygonV2: public QgsCurvePolygonV2
|
||||
bool operator!=( const QgsPolygonV2& other ) const;
|
||||
|
||||
virtual QString geometryType() const;
|
||||
virtual QgsWKBTypes::Type flatWkbType() const;
|
||||
virtual QgsPolygonV2* clone() const;
|
||||
|
||||
virtual bool fromWkb( QgsConstWkbPtr wkb );
|
||||
|
@ -75,18 +75,23 @@ class CORE_EXPORT QgsAbstractGeometryV2
|
||||
virtual int dimension() const = 0;
|
||||
//virtual int coordDim() const { return mCoordDimension; }
|
||||
|
||||
/** Returns a unique string representing the geometry type.
|
||||
/** Returns a unique string representing the geometry class type.
|
||||
* @see wkbType
|
||||
* @see wktTypeStr
|
||||
*/
|
||||
virtual QString geometryType() const = 0;
|
||||
|
||||
/** Returns the WKB type of the geometry.
|
||||
/** Returns the WKB type of the saved 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
|
||||
|
@ -252,7 +252,7 @@ bool QgsCircularStringV2::fromWkt( const QString& wkt )
|
||||
|
||||
QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
|
||||
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::CircularString )
|
||||
return false;
|
||||
mWkbType = parts.first;
|
||||
|
||||
|
@ -37,6 +37,7 @@ 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;
|
||||
|
@ -149,7 +149,7 @@ bool QgsCompoundCurveV2::fromWkt( const QString& wkt )
|
||||
|
||||
QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
|
||||
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::CompoundCurve )
|
||||
return false;
|
||||
mWkbType = parts.first;
|
||||
|
||||
@ -430,7 +430,7 @@ void QgsCompoundCurveV2::addVertex( const QgsPointV2& pt )
|
||||
}
|
||||
|
||||
QgsLineStringV2* line = nullptr;
|
||||
if ( !lastCurve || lastCurve->geometryType() != "LineString" )
|
||||
if ( !lastCurve || QgsWKBTypes::flatType( lastCurve->wkbType() ) != QgsWKBTypes::LineString )
|
||||
{
|
||||
line = new QgsLineStringV2();
|
||||
mCurves.append( line );
|
||||
|
@ -38,6 +38,7 @@ 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;
|
||||
|
@ -149,7 +149,7 @@ bool QgsCurvePolygonV2::fromWkt( const QString& wkt )
|
||||
|
||||
QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
|
||||
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::Polygon )
|
||||
return false;
|
||||
|
||||
mWkbType = parts.first;
|
||||
@ -466,11 +466,11 @@ void QgsCurvePolygonV2::setExteriorRing( QgsCurveV2* ring )
|
||||
mExteriorRing = ring;
|
||||
|
||||
//set proper wkb type
|
||||
if ( geometryType() == "Polygon" )
|
||||
if ( QgsWKBTypes::flatType( wkbType() ) == QgsWKBTypes::Polygon )
|
||||
{
|
||||
setZMTypeFromSubGeometry( ring, QgsWKBTypes::Polygon );
|
||||
}
|
||||
else if ( geometryType() == "CurvePolygon" )
|
||||
else if ( QgsWKBTypes::flatType( wkbType() ) == QgsWKBTypes::CurvePolygon )
|
||||
{
|
||||
setZMTypeFromSubGeometry( ring, QgsWKBTypes::CurvePolygon );
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ 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;
|
||||
|
@ -449,7 +449,7 @@ bool QgsGeometry::deleteVertex( int atVertex )
|
||||
}
|
||||
|
||||
//maintain compatibility with < 2.10 API
|
||||
if ( d->geometry->geometryType() == "MultiPoint" )
|
||||
if ( QgsWKBTypes::flatType( d->geometry->wkbType() ) == QgsWKBTypes::MultiPoint )
|
||||
{
|
||||
detach( true );
|
||||
removeWkbGeos();
|
||||
@ -487,7 +487,7 @@ bool QgsGeometry::insertVertex( double x, double y, int beforeVertex )
|
||||
}
|
||||
|
||||
//maintain compatibility with < 2.10 API
|
||||
if ( d->geometry->geometryType() == "MultiPoint" )
|
||||
if ( QgsWKBTypes::flatType( d->geometry->wkbType() ) == QgsWKBTypes::MultiPoint )
|
||||
{
|
||||
detach( true );
|
||||
removeWkbGeos();
|
||||
@ -1008,7 +1008,7 @@ bool QgsGeometry::convertToSingleType()
|
||||
|
||||
QgsPoint QgsGeometry::asPoint() const
|
||||
{
|
||||
if ( !d->geometry || d->geometry->geometryType() != "Point" )
|
||||
if ( !d->geometry || QgsWKBTypes::flatType( d->geometry->wkbType() ) != QgsWKBTypes::Point )
|
||||
{
|
||||
return QgsPoint();
|
||||
}
|
||||
@ -1029,7 +1029,8 @@ QgsPolyline QgsGeometry::asPolyline() const
|
||||
return polyLine;
|
||||
}
|
||||
|
||||
bool doSegmentation = ( d->geometry->geometryType() == "CompoundCurve" || d->geometry->geometryType() == "CircularString" );
|
||||
bool doSegmentation = ( QgsWKBTypes::flatType( d->geometry->wkbType() ) == QgsWKBTypes::CompoundCurve
|
||||
|| QgsWKBTypes::flatType( d->geometry->wkbType() ) == QgsWKBTypes::CircularString );
|
||||
QgsLineStringV2* line = nullptr;
|
||||
if ( doSegmentation )
|
||||
{
|
||||
@ -1071,7 +1072,7 @@ QgsPolygon QgsGeometry::asPolygon() const
|
||||
if ( !d->geometry )
|
||||
return QgsPolygon();
|
||||
|
||||
bool doSegmentation = ( d->geometry->geometryType() == "CurvePolygon" );
|
||||
bool doSegmentation = ( QgsWKBTypes::flatType( d->geometry->wkbType() ) == QgsWKBTypes::CurvePolygon );
|
||||
|
||||
QgsPolygonV2* p = nullptr;
|
||||
if ( doSegmentation )
|
||||
@ -1105,7 +1106,7 @@ QgsPolygon QgsGeometry::asPolygon() const
|
||||
|
||||
QgsMultiPoint QgsGeometry::asMultiPoint() const
|
||||
{
|
||||
if ( !d->geometry || d->geometry->geometryType() != "MultiPoint" )
|
||||
if ( !d->geometry || QgsWKBTypes::flatType( d->geometry->wkbType() ) != QgsWKBTypes::MultiPoint )
|
||||
{
|
||||
return QgsMultiPoint();
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList
|
||||
|
||||
QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
|
||||
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != flatWkbType() )
|
||||
return false;
|
||||
mWkbType = parts.first;
|
||||
|
||||
@ -504,7 +504,7 @@ bool QgsGeometryCollectionV2::fromCollectionWkt( const QString &wkt, const QList
|
||||
bool success = false;
|
||||
Q_FOREACH ( const QgsAbstractGeometryV2* geom, subtypes )
|
||||
{
|
||||
if ( QgsWKBTypes::flatType( childParts.first ) == QgsWKBTypes::parseType( geom->geometryType() ) )
|
||||
if ( QgsWKBTypes::flatType( childParts.first ) == geom->flatWkbType() )
|
||||
{
|
||||
mGeometries.append( geom->clone() );
|
||||
if ( mGeometries.back()->fromWkt( childWkt ) )
|
||||
|
@ -53,6 +53,7 @@ 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.*/
|
||||
|
@ -120,13 +120,14 @@ int QgsGeometryEditUtils::addPart( QgsAbstractGeometryV2* geom, QgsAbstractGeome
|
||||
}
|
||||
|
||||
bool added = false;
|
||||
if ( geom->geometryType() == "MultiSurface" || geom->geometryType() == "MultiPolygon" )
|
||||
if ( QgsWKBTypes::flatType( geom->wkbType() ) == QgsWKBTypes::MultiSurface
|
||||
|| QgsWKBTypes::flatType( geom->wkbType() ) == QgsWKBTypes::MultiPolygon )
|
||||
{
|
||||
QgsCurveV2* curve = dynamic_cast<QgsCurveV2*>( part );
|
||||
if ( curve && curve->isClosed() && curve->numPoints() >= 4 )
|
||||
{
|
||||
QgsCurvePolygonV2 *poly = nullptr;
|
||||
if ( curve->geometryType() == "LineString" )
|
||||
if ( QgsWKBTypes::flatType( curve->wkbType() ) == QgsWKBTypes::LineString )
|
||||
{
|
||||
poly = new QgsPolygonV2();
|
||||
}
|
||||
@ -137,11 +138,11 @@ int QgsGeometryEditUtils::addPart( QgsAbstractGeometryV2* geom, QgsAbstractGeome
|
||||
poly->setExteriorRing( curve );
|
||||
added = geomCollection->addGeometry( poly );
|
||||
}
|
||||
else if ( part->geometryType() == "Polygon" )
|
||||
else if ( QgsWKBTypes::flatType( part->wkbType() ) == QgsWKBTypes::Polygon )
|
||||
{
|
||||
added = geomCollection->addGeometry( part );
|
||||
}
|
||||
else if ( part->geometryType() == "MultiPolygon" )
|
||||
else if ( QgsWKBTypes::flatType( part->wkbType() ) == QgsWKBTypes::MultiPolygon )
|
||||
{
|
||||
QgsGeometryCollectionV2 *parts = static_cast<QgsGeometryCollectionV2*>( part );
|
||||
|
||||
|
@ -150,7 +150,7 @@ bool QgsLineStringV2::fromWkt( const QString& wkt )
|
||||
|
||||
QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
|
||||
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::LineString )
|
||||
return false;
|
||||
mWkbType = parts.first;
|
||||
|
||||
|
@ -139,6 +139,7 @@ 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;
|
||||
|
@ -28,6 +28,7 @@ class CORE_EXPORT QgsMultiCurveV2: public QgsGeometryCollectionV2
|
||||
{
|
||||
public:
|
||||
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;
|
||||
|
@ -28,6 +28,7 @@ class CORE_EXPORT QgsMultiLineStringV2: public QgsMultiCurveV2
|
||||
{
|
||||
public:
|
||||
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;
|
||||
|
@ -28,6 +28,7 @@ class CORE_EXPORT QgsMultiPointV2: public QgsGeometryCollectionV2
|
||||
{
|
||||
public:
|
||||
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;
|
||||
|
@ -28,6 +28,7 @@ class CORE_EXPORT QgsMultiPolygonV2: public QgsMultiSurfaceV2
|
||||
{
|
||||
public:
|
||||
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;
|
||||
|
@ -28,6 +28,7 @@ class CORE_EXPORT QgsMultiSurfaceV2: public QgsGeometryCollectionV2
|
||||
{
|
||||
public:
|
||||
virtual QString geometryType() const override { return "MultiSurface"; }
|
||||
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::MultiSurface; }
|
||||
QgsMultiSurfaceV2* clone() const override;
|
||||
|
||||
bool fromWkt( const QString& wkt ) override;
|
||||
|
@ -130,7 +130,7 @@ bool QgsPointV2::fromWkt( const QString& wkt )
|
||||
|
||||
QPair<QgsWKBTypes::Type, QString> parts = QgsGeometryUtils::wktReadBlock( wkt );
|
||||
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::parseType( geometryType() ) )
|
||||
if ( QgsWKBTypes::flatType( parts.first ) != QgsWKBTypes::Point )
|
||||
return false;
|
||||
mWkbType = parts.first;
|
||||
|
||||
|
@ -153,6 +153,7 @@ class CORE_EXPORT QgsPointV2: public QgsAbstractGeometryV2
|
||||
//implementation of inherited methods
|
||||
virtual QgsRectangle boundingBox() const override { return QgsRectangle( mX, mY, mX, mY ); }
|
||||
virtual QString geometryType() const override { return "Point"; }
|
||||
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::Point; }
|
||||
virtual int dimension() const override { return 0; }
|
||||
virtual QgsPointV2* clone() const override;
|
||||
void clear() override;
|
||||
|
@ -35,6 +35,7 @@ class CORE_EXPORT QgsPolygonV2: public QgsCurvePolygonV2
|
||||
bool operator!=( const QgsPolygonV2& other ) const;
|
||||
|
||||
virtual QString geometryType() const override { return "Polygon"; }
|
||||
virtual QgsWKBTypes::Type flatWkbType() const override { return QgsWKBTypes::Polygon; }
|
||||
virtual QgsPolygonV2* clone() const override;
|
||||
|
||||
virtual bool fromWkb( QgsConstWkbPtr wkb ) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user