Skip to content
Permalink
Browse files

Move some more common geometry methods to headers to allow compiler i…

…nlining
  • Loading branch information
nyalldawson committed Jun 19, 2018
1 parent 3ea8a41 commit 4059c9b71dd5683e3724c51d23d4d1095c8ea67a
@@ -71,7 +71,9 @@ Curve polygon geometry type


int numInteriorRings() const;

const QgsCurve *exteriorRing() const;

const QgsCurve *interiorRing( int i ) const;

virtual QgsPolygon *toPolygon( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const /Factory/;
@@ -92,7 +92,6 @@ Construct a QgsPoint from a QPointF

virtual bool operator!=( const QgsAbstractGeometry &other ) const;


double x() const;
%Docstring
Returns the point's x-coordinate.
@@ -33,14 +33,17 @@ Examples are storing a layer extent or the current view extent of a map
%Docstring
Constructor
%End

QgsRectangle( const QgsPointXY &p1, const QgsPointXY &p2 );
%Docstring
Construct a rectangle from two points. The rectangle is normalized after construction.
%End

QgsRectangle( const QRectF &qRectF );
%Docstring
Construct a rectangle from a QRectF. The rectangle is normalized after construction.
%End

QgsRectangle( const QgsRectangle &other );
%Docstring
Copy constructor
@@ -70,7 +73,7 @@ Sets the rectangle from two :py:class:`QgsPoints`. The rectangle is
normalised after construction.
%End

void set( double mXmin, double mYmin, double mXmax, double mYmax );
void set( double xMin, double yMin, double xMax, double yMax );
%Docstring
Sets the rectangle from four points. The rectangle is
normalised after construction.
@@ -38,17 +38,6 @@ QgsAbstractGeometry &QgsAbstractGeometry::operator=( const QgsAbstractGeometry &
return *this;
}

bool QgsAbstractGeometry::is3D() const
{
return QgsWkbTypes::hasZ( mWkbType );
}

bool QgsAbstractGeometry::isMeasure() const
{
return QgsWkbTypes::hasM( mWkbType );
}


void QgsAbstractGeometry::setZMTypeFromSubGeometry( const QgsAbstractGeometry *subgeom, QgsWkbTypes::Type baseGeomType )
{
if ( !subgeom )
@@ -181,13 +181,19 @@ class CORE_EXPORT QgsAbstractGeometry
* Returns true if the geometry is 3D and contains a z-value.
* \see isMeasure
*/
bool is3D() const;
bool is3D() const
{
return QgsWkbTypes::hasZ( mWkbType );
}

/**
* Returns true if the geometry contains m values.
* \see is3D
*/
bool isMeasure() const;
bool isMeasure() const
{
return QgsWkbTypes::hasM( mWkbType );
}

/**
* Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry).
@@ -588,25 +588,6 @@ QgsPolygon *QgsCurvePolygon::toPolygon( double tolerance, SegmentationToleranceT
return poly.release();
}

int QgsCurvePolygon::numInteriorRings() const
{
return mInteriorRings.size();
}

const QgsCurve *QgsCurvePolygon::exteriorRing() const
{
return mExteriorRing.get();
}

const QgsCurve *QgsCurvePolygon::interiorRing( int i ) const
{
if ( i < 0 || i >= mInteriorRings.size() )
{
return nullptr;
}
return mInteriorRings.at( i );
}

void QgsCurvePolygon::setExteriorRing( QgsCurve *ring )
{
if ( !ring )
@@ -66,9 +66,24 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface
bool removeDuplicateNodes( double epsilon = 4 * std::numeric_limits<double>::epsilon(), bool useZValues = false ) override;

//curve polygon interface
int numInteriorRings() const;
const QgsCurve *exteriorRing() const;
const QgsCurve *interiorRing( int i ) const;
int numInteriorRings() const
{
return mInteriorRings.size();
}

const QgsCurve *exteriorRing() const
{
return mExteriorRing.get();
}

const QgsCurve *interiorRing( int i ) const
{
if ( i < 0 || i >= mInteriorRings.size() )
{
return nullptr;
}
return mInteriorRings.at( i );
}

/**
* Returns a new polygon geometry corresponding to a segmentized approximation
@@ -181,16 +181,6 @@ int QgsGeometryCollection::vertexNumberFromVertexId( QgsVertexId id ) const
return -1; // should not happen
}

int QgsGeometryCollection::numGeometries() const
{
return mGeometries.size();
}

const QgsAbstractGeometry *QgsGeometryCollection::geometryN( int n ) const
{
return mGeometries.value( n );
}

QgsAbstractGeometry *QgsGeometryCollection::geometryN( int n )
{
clearCache();
@@ -47,14 +47,20 @@ class CORE_EXPORT QgsGeometryCollection: public QgsAbstractGeometry
/**
* Returns the number of geometries within the collection.
*/
int numGeometries() const;
int numGeometries() const
{
return mGeometries.size();
}

/**
* Returns a const reference to a geometry from within the collection.
* \param n index of geometry to return
* \note not available in Python bindings
*/
const QgsAbstractGeometry *geometryN( int n ) const SIP_SKIP;
const QgsAbstractGeometry *geometryN( int n ) const SIP_SKIP
{
return mGeometries.value( n );
}

/**
* Returns a geometry from within the collection.
@@ -306,12 +306,6 @@ bool QgsLineString::fromWkb( QgsConstWkbPtr &wkbPtr )
return true;
}

void QgsLineString::fromWkbPoints( QgsWkbTypes::Type type, const QgsConstWkbPtr &wkb )
{
mWkbType = type;
importVerticesFromWkb( wkb );
}

QgsRectangle QgsLineString::calculateBoundingBox() const
{
double xmin = std::numeric_limits<double>::max();
@@ -550,48 +544,6 @@ double QgsLineString::yAt( int index ) const
return 0.0;
}

const double *QgsLineString::xData() const
{
return mX.constData();
}

const double *QgsLineString::yData() const
{
return mY.constData();
}

const double *QgsLineString::zData() const
{
if ( mZ.empty() )
return nullptr;
else
return mZ.constData();
}

const double *QgsLineString::mData() const
{
if ( mM.empty() )
return nullptr;
else
return mM.constData();
}

double QgsLineString::zAt( int index ) const
{
if ( index >= 0 && index < mZ.size() )
return mZ.at( index );
else
return std::numeric_limits<double>::quiet_NaN();
}

double QgsLineString::mAt( int index ) const
{
if ( index >= 0 && index < mM.size() )
return mM.at( index );
else
return std::numeric_limits<double>::quiet_NaN();
}

void QgsLineString::setXAt( int index, double x )
{
if ( index >= 0 && index < mX.size() )
@@ -606,18 +558,6 @@ void QgsLineString::setYAt( int index, double y )
clearCache();
}

void QgsLineString::setZAt( int index, double z )
{
if ( index >= 0 && index < mZ.size() )
mZ[ index ] = z;
}

void QgsLineString::setMAt( int index, double m )
{
if ( index >= 0 && index < mM.size() )
mM[ index ] = m;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
@@ -102,15 +102,21 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* \see yData()
* \since QGIS 3.2
*/
const double *xData() const SIP_SKIP;
const double *xData() const SIP_SKIP
{
return mX.constData();
}

/**
* Returns a const pointer to the y vertex data.
* \note Not available in Python bindings
* \see xData()
* \since QGIS 3.2
*/
const double *yData() const SIP_SKIP;
const double *yData() const SIP_SKIP
{
return mY.constData();
}

/**
* Returns a const pointer to the z vertex data, or a nullptr if the linestring does
@@ -120,7 +126,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* \see yData()
* \since QGIS 3.2
*/
const double *zData() const SIP_SKIP;
const double *zData() const SIP_SKIP
{
if ( mZ.empty() )
return nullptr;
else
return mZ.constData();
}

/**
* Returns a const pointer to the m vertex data, or a nullptr if the linestring does
@@ -130,7 +142,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* \see yData()
* \since QGIS 3.2
*/
const double *mData() const SIP_SKIP;
const double *mData() const SIP_SKIP
{
if ( mM.empty() )
return nullptr;
else
return mM.constData();
}

/**
* Returns the z-coordinate of the specified node in the line string.
@@ -139,7 +157,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* does not have a z dimension
* \see setZAt()
*/
double zAt( int index ) const;
double zAt( int index ) const
{
if ( index >= 0 && index < mZ.size() )
return mZ.at( index );
else
return std::numeric_limits<double>::quiet_NaN();
}

/**
* Returns the m value of the specified node in the line string.
@@ -148,7 +172,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* does not have m values
* \see setMAt()
*/
double mAt( int index ) const;
double mAt( int index ) const
{
if ( index >= 0 && index < mM.size() )
return mM.at( index );
else
return std::numeric_limits<double>::quiet_NaN();
}

/**
* Sets the x-coordinate of the specified node in the line string.
@@ -175,7 +205,11 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* \param z z-coordinate of node
* \see zAt()
*/
void setZAt( int index, double z );
void setZAt( int index, double z )
{
if ( index >= 0 && index < mZ.size() )
mZ[ index ] = z;
}

/**
* Sets the m value of the specified node in the line string.
@@ -184,7 +218,11 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* \param m m value of node
* \see mAt()
*/
void setMAt( int index, double m );
void setMAt( int index, double m )
{
if ( index >= 0 && index < mM.size() )
mM[ index ] = m;
}

/**
* Resets the line string to match the specified list of points. The line string will
@@ -325,7 +363,11 @@ class CORE_EXPORT QgsLineString: public QgsCurve
* \param type WKB type
* \param wkb WKB representation of line geometry
*/
void fromWkbPoints( QgsWkbTypes::Type type, const QgsConstWkbPtr &wkb );
void fromWkbPoints( QgsWkbTypes::Type type, const QgsConstWkbPtr &wkb )
{
mWkbType = type;
importVerticesFromWkb( wkb );
}

friend class QgsPolygon;
friend class QgsTriangle;

0 comments on commit 4059c9b

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