25 #include <QPainterPath>    44   return *otherCurve == *
this;
    55   Q_FOREACH ( 
const QgsCurveV2* c, curve.mCurves )
    57     mCurves.
append( static_cast<QgsCurveV2*>( c->
clone() ) );
    67     Q_FOREACH ( 
const QgsCurveV2* c, curve.mCurves )
    69       mCurves.
append( static_cast<QgsCurveV2*>( c->
clone() ) );
    83   qDeleteAll( mCurves );
    90   if ( mCurves.
size() < 1 )
    96   for ( 
int i = 1; i < mCurves.
size(); ++i )
   122   int currentCurveSize = 0;
   123   for ( 
int i = 0; i < 
nCurves; ++i )
   126     wkbPtr -= 1 + 
sizeof( int );
   139     currentCurve->
fromWkb( wkbPtr );
   140     currentCurveSize = currentCurve->
wkbSize();
   141     mCurves.
append( currentCurve );
   142     wkbPtr += currentCurveSize;
   172     if ( !mCurves.
back()->fromWkt( childWkt ) )
   183   Q_FOREACH ( 
const QgsCurveV2* curve, mCurves )
   185     hasZ = hasZ || curve->
is3D();
   200   int size = 
sizeof( char ) + 
sizeof( quint32 ) + 
sizeof( quint32 );
   201   Q_FOREACH ( 
const QgsCurveV2 *curve, mCurves )
   211   unsigned char* geomPtr = 
new unsigned char[binarySize];
   214   wkb << static_cast<quint32>( 
wkbType() );
   215   wkb << static_cast<quint32>( mCurves.
size() );
   216   Q_FOREACH ( 
const QgsCurveV2* curve, mCurves )
   219     unsigned char* curveWkb = curve->
asWkb( curveWkbLen );
   220     memcpy( wkb, curveWkb, curveWkbLen );
   230   Q_FOREACH ( 
const QgsCurveV2* curve, mCurves )
   233     if ( dynamic_cast<const QgsLineStringV2*>( curve ) )
   236       childWkt = childWkt.
mid( childWkt.
indexOf( 
'(' ) );
   238     wkt += childWkt + 
',';
   260   Q_FOREACH ( 
const QgsCurveV2* curve, mCurves )
   268   return compoundCurveElem;
   284   for ( ; curveIt != mCurves.
constEnd(); ++curveIt )
   286     length += ( *curveIt )->length();
   293   if ( mCurves.
size() < 1 )
   297   return mCurves.
at( 0 )->startPoint();
   302   if ( mCurves.
size() < 1 )
   312   if ( mCurves.
size() < 1 )
   317   mCurves[0]->points( pts );
   318   for ( 
int i = 1; i < mCurves.
size(); ++i )
   321     mCurves[i]->points( pList );
   336   for ( 
int i = 0; i < 
nCurves; ++i )
   338     nPoints += mCurves.
at( i )->numPoints() - 1; 
   349   for ( ; curveIt != mCurves.
constEnd(); ++curveIt )
   351     currentLine = ( *curveIt )->
curveToLine( tolerance, toleranceType );
   352     line->
append( currentLine );
   360   if ( i >= mCurves.
size() )
   364   return mCurves.
at( i );
   392   if ( mCurves.
size() - 1  < i )
   397   delete( mCurves.
at( i ) );
   413     lastCurve = mCurves.
at( mCurves.
size() - 1 );
   438   for ( ; it != mCurves.
constEnd(); ++it )
   466   for ( ; it != mCurves.
constEnd(); ++it )
   468     ( *it )->addToPainterPath( pp );
   477   for ( ; it != mCurves.
constEnd(); ++it )
   479     ( *it )->addToPainterPath( pp );
   487   if ( curveIds.
size() < 1 )
   491   int curveId = curveIds.
at( 0 ).first;
   492   if ( curveId >= mCurves.
size() )
   497   bool success = mCurves.
at( curveId )->insertVertex( curveIds.
at( 0 ).second, vertex );
   509   for ( ; idIt != curveIds.
constEnd(); ++idIt )
   511     mCurves.
at( idIt->
first )->moveVertex( idIt->second, newPos );
   514   bool success = !curveIds.
isEmpty();
   525   if ( curveIds.
size() == 1 )
   532     if ( mCurves.
at( curveIds.
at( 0 ).first )->
numPoints() == 0 )
   537   else if ( curveIds.
size() == 2 )
   539     Q_ASSERT( curveIds.
at( 1 ).first == curveIds.
at( 0 ).first + 1 );
   540     Q_ASSERT( curveIds.
at( 0 ).second.vertex == mCurves.
at( curveIds.
at( 0 ).first )->
numPoints() - 1 );
   541     Q_ASSERT( curveIds.
at( 1 ).second.vertex == 0 );
   550       mCurves.
at( curveIds.
at( 1 ).first ) ->
pointAt( 2, intermediatePoint, type );
   554     else if ( !mCurves.
at( curveIds.
at( 0 ).first )->
deleteVertex( curveIds.
at( 0 ).second ) )
   566     else if ( !mCurves.
at( curveIds.
at( 1 ).first )->
deleteVertex( curveIds.
at( 1 ).second ) )
   571     if ( mCurves.
at( curveIds.
at( 0 ).first )->
numPoints() == 0 &&
   577     else if ( mCurves.
at( curveIds.
at( 0 ).first )->
numPoints() != 0 &&
   584     else if ( mCurves.
at( curveIds.
at( 0 ).first )->
numPoints() == 0 &&
   590       line->insertVertex( 
QgsVertexId( 0, 0, 0 ), startPoint );
   591       line->insertVertex( 
QgsVertexId( 0, 0, 1 ), endPoint );
   592       mCurves.
insert( curveIds.
at( 0 ).first, line );
   598       if ( endPointOfFirst != startPointOfSecond )
   603         mCurves.
insert( curveIds.
at( 1 ).first, line );
   608   bool success = !curveIds.
isEmpty();
   620   int currentVertexIndex = 0;
   621   for ( 
int i = 0; i < mCurves.
size(); ++i )
   623     int increment = mCurves.
at( i )->numPoints() - 1;
   624     if ( 
id.vertex >= currentVertexIndex && 
id.vertex <= currentVertexIndex + increment )
   626       int curveVertexId = 
id.vertex - currentVertexIndex;
   630       vid.
vertex = curveVertexId;
   631       curveIds.
append( qMakePair( i, vid ) );
   632       if ( curveVertexId == increment && i < ( mCurves.
size() - 1 ) ) 
   635         curveIds.
append( qMakePair( i + 1, vid ) );
   639     currentVertexIndex += increment;
   652   int currentVertexId = 0;
   653   for ( 
int j = 0; j < mCurves.
size(); ++j )
   655     int nCurvePoints = mCurves.
at( j )->numPoints();
   656     if (( node - currentVertexId ) < nCurvePoints )
   658       return ( mCurves.
at( j )->pointAt( node - currentVertexId, point, type ) );
   660     currentVertexId += ( nCurvePoints - 1 );
   668   for ( ; curveIt != mCurves.
constEnd(); ++curveIt )
   670     ( *curveIt )->sumUpArea( sum );
   686   for ( ; curveIt != mCurves.
constEnd(); ++curveIt )
   688     if (( *curveIt )->hasCurvedSegments() )
   699   if ( curveIds.
size() == 1 )
   704   else if ( curveIds.
size() > 1 )
   708     double angle1 = curve1->
vertexAngle( curveIds.
at( 0 ).second );
   709     double angle2 = curve2->
vertexAngle( curveIds.
at( 1 ).second );
 QString wktTypeStr() const
Returns the WKT type string of the geometry. 
 
virtual QgsCompoundCurveV2 * reversed() const override
Returns a reversed copy of the curve, where the direction of the curve has been flipped. 
 
virtual bool deleteVertex(QgsVertexId position) override
Deletes a vertex within the geometry. 
 
void addPath(const QPainterPath &path)
 
virtual bool insertVertex(QgsVertexId position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry. 
 
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
 
A rectangle specified with double values. 
 
QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML2 representation of the geometry. 
 
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry. 
 
static QPair< QgsWKBTypes::Type, QString > wktReadBlock(const QString &wkt)
Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents (...
 
void close()
Appends first point if not already closed. 
 
virtual QgsAbstractGeometryV2 & operator=(const QgsAbstractGeometryV2 &geom)
 
QDomNode appendChild(const QDomNode &newChild)
 
bool hasCurvedSegments() const override
Returns true if the geometry contains curved segments. 
 
static double averageAngle(double x1, double y1, double x2, double y2, double x3, double y3)
Angle between two linear segments. 
 
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type. 
 
static bool hasM(Type type)
Tests whether a WKB type contains m values. 
 
Circular string geometry type. 
 
virtual QgsPointV2 endPoint() const override
Returns the end point of the curve. 
 
double vertexAngle(QgsVertexId vertex) const override
Returns approximate rotation angle for a vertex. 
 
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
 
virtual QgsPointV2 startPoint() const override
Returns the starting point of the curve. 
 
const T & at(int i) const
 
QDomElement asGML2(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML2 representation of the geometry. 
 
virtual bool insertVertex(QgsVertexId position, const QgsPointV2 &vertex) override
Inserts a vertex into the geometry. 
 
static QStringList wktGetChildBlocks(const QString &wkt, const QString &defaultType="")
Parses a WKT string and returns of list of blocks contained in the WKT. 
 
unsigned char * asWkb(int &binarySize) const override
Returns a WKB representation of the geometry. 
 
virtual bool operator==(const QgsCurveV2 &other) const override
 
static double closestSegmentFromComponents(T &container, componentType ctype, const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon)
 
virtual QgsRectangle calculateBoundingBox() const override
Default calculator for the minimal bounding box for the geometry. 
 
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry. 
 
void append(const QgsLineStringV2 *line)
Appends the contents of another line string to the end of this line string. 
 
void sumUpArea(double &sum) const override
Sums up the area of the curve by iterating over the vertices (shoelace formula). 
 
QDomElement createElementNS(const QString &nsURI, const QString &qName)
 
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension. 
 
virtual QgsCurveV2 * clone() const override=0
Clones the geometry by performing a deep copy. 
 
void addToPainterPath(QPainterPath &path) const override
Adds a curve to a painter path. 
 
static endian_t endian()
Returns whether this machine uses big or little endian. 
 
virtual int wkbSize() const =0
Returns the size of the WKB representation of the geometry. 
 
QgsCompoundCurveV2 & operator=(const QgsCompoundCurveV2 &curve)
 
void removeCurve(int i)
Removes a curve from the geometry. 
 
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value. 
 
void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) override
Transforms the geometry using a coordinate transform. 
 
void append(const T &value)
 
static Type dropZ(Type type)
Drops the z dimension (if present) for a WKB type and returns the new type. 
 
virtual bool operator!=(const QgsCurveV2 &other) const override
 
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new type. 
 
virtual QgsCurveV2 * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped. 
 
virtual void clearCache() const override
Clears any cached parameters associated with the geometry, eg bounding boxes. 
 
virtual bool isClosed() const
Returns true if the curve is closed. 
 
Utility class for identifying a unique vertex within a geometry. 
 
void drawAsPolygon(QPainter &p) const override
Draws the curve as a polygon on the specified QPainter. 
 
Line string geometry type, with support for z-dimension and m-values. 
 
virtual bool fromWkb(QgsConstWkbPtr wkb)=0
Sets the geometry from a WKB string. 
 
void draw(QPainter &p) const override
Draws the geometry using the specified QPainter. 
 
void addVertex(const QgsPointV2 &pt)
Adds a vertex to the end of the geometry. 
 
bool isMeasure() const
Returns true if the geometry contains m values. 
 
Point geometry type, with support for z-dimension and m-values. 
 
QString asJSON(int precision=17) const override
Returns a GeoJSON representation of the geometry. 
 
QgsWKBTypes::Type mWkbType
 
QString asWkt(int precision=17) const override
Returns a WKT representation of the geometry. 
 
virtual bool fromWkb(QgsConstWkbPtr wkb) override
Sets the geometry from a WKB string. 
 
virtual unsigned char * asWkb(int &binarySize) const =0
Returns a WKB representation of the geometry. 
 
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
 
void setZMTypeFromSubGeometry(const QgsAbstractGeometryV2 *subggeom, QgsWKBTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values. 
 
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value. 
 
virtual bool addMValue(double mValue=0) override
Adds a measure to the geometry, initialized to a preset value. 
 
virtual QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
Returns a GML3 representation of the geometry. 
 
virtual bool dropZValue() override
Drops any z-dimensions which exist in the geometry. 
 
virtual bool dropMValue() override
Drops any measure values which exist in the geometry. 
 
QString asJSON(int precision=17) const override
Returns a GeoJSON representation of the geometry. 
 
Compound curve geometry type. 
 
virtual void points(QgsPointSequenceV2 &pts) const override
Returns a list of points within the curve. 
 
void combineExtentWith(const QgsRectangle &rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
 
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex. 
 
static Type dropM(Type type)
Drops the m dimension (if present) for a WKB type and returns the new type. 
 
void addCurve(QgsCurveV2 *c)
Adds a curve to the geometr (takes ownership) 
 
void addVertex(const QgsPointV2 &pt)
Adds a new vertex to the end of the line string. 
 
virtual QgsPointV2 endPoint() const =0
Returns the end point of the curve. 
 
const QgsCurveV2 * curveAt(int i) const
Returns the curve at the specified index. 
 
QString mid(int position, int n) const
 
void drawPath(const QPainterPath &path)
 
virtual QgsLineStringV2 * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
 
virtual QgsLineStringV2 * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
 
virtual bool fromWkt(const QString &wkt) override
Sets the geometry from a WKT string. 
 
virtual QgsCompoundCurveV2 * clone() const override
Clones the geometry by performing a deep copy. 
 
void insert(int i, const T &value)
 
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry. 
 
bool pointAt(int node, QgsPointV2 &point, QgsVertexId::VertexType &type) const override
Returns the point and vertex id of a point within the curve. 
 
int wkbSize() const override
Returns the size of the WKB representation of the geometry. 
 
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry. 
 
int nCurves() const
Returns the number of curves in the geometry. 
 
virtual double closestSegment(const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const override
Searches for the closest segment of the geometry to a given point. 
 
static Type flatType(Type type)
Returns the flat type for a WKB type. 
 
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. 
 
QgsWKBTypes::Type readHeader() const
 
const_iterator constEnd() const
 
const_iterator constBegin() const
 
Abstract base class for curved geometry type. 
 
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
 
virtual int numPoints() const override
Returns the number of points in the curve. 
 
QDomElement asGML3(QDomDocument &doc, int precision=17, const QString &ns="gml") const override
Returns a GML3 representation of the geometry. 
 
virtual double length() const override
Returns the length of the geometry. 
 
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)=0
Transforms the geometry using a coordinate transform. 
 
bool is3D() const
Returns true if the geometry is 3D and contains a z-value. 
 
virtual void clear() override
Clears the geometry, ie reset it to a null geometry. 
 
virtual bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value. 
 
virtual bool moveVertex(QgsVertexId position, const QgsPointV2 &newPos) override
Moves a vertex within the geometry.