Optimise QgsCurve::asQPolygonF for linestring geometries

This commit is contained in:
Nyall Dawson 2018-05-29 16:53:06 +10:00
parent 3ba7c0b322
commit 0c7df170e1
5 changed files with 19 additions and 2 deletions

View File

@ -177,7 +177,7 @@ Returns the y-coordinate of the specified node in the line string.
:return: y-coordinate of node, or 0.0 if index is out of bounds
%End
QPolygonF asQPolygonF() const;
virtual QPolygonF asQPolygonF() const;
%Docstring
Returns a QPolygonF representing the points.
%End

View File

@ -216,6 +216,7 @@ segment in the line.
virtual bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false );
virtual QPolygonF asQPolygonF() const;
virtual bool fromWkb( QgsConstWkbPtr &wkb );

View File

@ -164,7 +164,7 @@ class CORE_EXPORT QgsCurve: public QgsAbstractGeometry
/**
* Returns a QPolygonF representing the points.
*/
QPolygonF asQPolygonF() const;
virtual QPolygonF asQPolygonF() const;
/**
* Returns the straight distance of the curve, i.e. the direct/euclidean distance

View File

@ -274,6 +274,21 @@ bool QgsLineString::removeDuplicateNodes( double epsilon, bool useZValues )
return result;
}
QPolygonF QgsLineString::asQPolygonF() const
{
const int nb = mX.size();
QPolygonF points( nb );
const double *x = mX.constData();
const double *y = mY.constData();
QPointF *dest = points.data();
for ( int i = 0; i < nb; ++i )
{
*dest++ = QPointF( *x++, *y++ );
}
return points;
}
bool QgsLineString::fromWkb( QgsConstWkbPtr &wkbPtr )
{
if ( !wkbPtr )

View File

@ -210,6 +210,7 @@ class CORE_EXPORT QgsLineString: public QgsCurve
bool isEmpty() const override;
QgsLineString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const override SIP_FACTORY;
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) override;
virtual QPolygonF asQPolygonF() const override;
bool fromWkb( QgsConstWkbPtr &wkb ) override;
bool fromWkt( const QString &wkt ) override;