49 #include <netinet/in.h> 60 mutable const unsigned char*
mWkb;
99 void QgsGeometry::detach(
bool cloneGeom )
116 void QgsGeometry::removeWkbGeos()
552 double epsilon )
const 567 minDistPoint.
setX( segmentPt.
x() );
568 minDistPoint.
setY( segmentPt.
y() );
572 *leftOf = leftOfBool ? 1.0 : -1.0;
613 if ( points.
size() == 1 )
617 else if ( points.
size() > 1 )
623 return addPart( partGeom, geomType );
722 splitLineString.
setPoints( splitLinePointsV2 );
726 int result = geos.
splitGeometry( splitLineString, newGeoms, topological, tp );
733 newGeometries.
clear();
734 for (
int i = 1; i < newGeoms.
size(); ++i )
756 reshapeLineString.
setPoints( reshapeLine );
761 if ( errorCode == 0 && geom )
832 return geos.contains( pt );
935 return convertToPoint( destMultipart );
938 return convertToLine( destMultipart );
941 return convertToPolygon( destMultipart );
987 if ( !multiGeom || multiGeom->
partCount() < 1 )
1023 if ( doSegmentation )
1042 polyLine.
resize( nVertices );
1043 for (
int i = 0; i < nVertices; ++i )
1046 polyLine[i].setX( pt.
x() );
1047 polyLine[i].setY( pt.
y() );
1050 if ( doSegmentation )
1066 if ( doSegmentation )
1086 convertPolygon( *p, polygon );
1088 if ( doSegmentation )
1110 for (
int i = 0; i < nPoints; ++i )
1113 multiPoint[i].setX( pt->
x() );
1114 multiPoint[i].setY( pt->
y() );
1127 if ( !geomCollection )
1139 for (
int i = 0; i < nLines; ++i )
1141 bool deleteLine =
false;
1155 line->
points( lineCoords );
1157 convertToPolyline( lineCoords, polyLine );
1176 if ( !geomCollection )
1182 if ( nPolygons < 1 )
1188 for (
int i = 0; i < nPolygons; ++i )
1205 convertPolygon( *polygon, poly );
1221 double geosArea = g.
area();
1222 double qgisArea = 0;
1226 qgisArea = surface->
area();
1311 if ( !simplifiedGeom )
1327 bool ok = geos.
centroid( centroid );
1450 return engine.
extrude( x, y );
1458 return geometryList;
1465 geometryList.
reserve( numGeom );
1466 for (
int i = 0; i < numGeom; ++i )
1476 return geometryList;
1497 if ( polygon.
size() < 1 )
1499 polyline = polygon.
at( 0 );
1507 for ( ; lineIt != polyline.
constEnd(); ++lineIt )
1509 result << lineIt->toQPointF();
1607 for ( ; it != geometryList.
constEnd(); ++it )
1609 if ( *it && !(( *it )->isEmpty() ) )
1611 geomV2List.
append(( *it )->geometry() );
1708 int vertexCount = 0;
1709 for (
int part = 0; part < coords.
size(); ++part )
1712 for (
int ring = 0; ring < featureCoords.
size(); ++ring )
1715 for (
int vertex = 0; vertex < ringCoords.
size(); ++vertex )
1717 if ( vertexCount == nr )
1740 int vertexCount = 0;
1741 for (
int part = 0; part < coords.
size(); ++part )
1744 for (
int ring = 0; ring < featureCoords.
size(); ++ring )
1747 for (
int vertex = 0; vertex < ringCoords.
size(); ++vertex )
1749 if ( vertex ==
id.vertex && ring ==
id.ring && part ==
id.part )
1764 for ( ; it != input.
constEnd(); ++it )
1774 for ( ; it != input.
constEnd(); ++it )
1785 for (
int i = 0; i < input.
size(); ++i )
1788 output[i].setX( pt.
x() );
1789 output[i].setY( pt.
y() );
1797 if ( coords.
size() < 1 )
1803 for (
int i = 0; i < rings.
size(); ++i )
1805 convertToPolyline( rings[i], output[i] );
1842 for ( ; it != polygon.
constEnd(); ++it )
1854 for (
int i = 0; i < p1.
count(); ++i )
1856 if ( !p1.
at( i ).compare( p2.
at( i ), epsilon ) )
1867 for (
int i = 0; i < p1.
count(); ++i )
1881 for (
int i = 0; i < p1.
count(); ++i )
1913 for ( ; lineIt != multiline.
constEnd(); ++lineIt )
1915 resultMultiline <<
smoothLine( *lineIt, iterations, offset );
1933 for ( ; polyIt != multipoly.
constEnd(); ++polyIt )
1935 resultMultipoly <<
smoothPolygon( *polyIt, iterations, offset );
1948 double deltaX = p2.
x() - p1.
x();
1949 double deltaY = p2.
y() - p1.
y();
1950 return QgsPoint( p1.
x() + deltaX * offset, p1.
y() + deltaY * offset );
1956 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
1960 for (
int i = 0; i < result.
count() - 1; i++ )
1967 result = outputLine;
1976 for ( ; ringIt != polygon.
constEnd(); ++ringIt )
1979 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
1982 outputRing.
reserve( 2 * ( resultRing.
count() - 1 ) + 1 );
1983 for (
int i = 0; i < resultRing.
count() - 1; ++i )
1991 outputRing << outputRing.
at( 0 );
1993 resultRing = outputRing;
1995 resultPoly << resultRing;
2000 QgsGeometry* QgsGeometry::convertToPoint(
bool destMultipart )
const 2008 if (( destMultipart && srcIsMultipart ) ||
2009 ( !destMultipart && !srcIsMultipart ) )
2014 if ( destMultipart )
2023 if ( multiPoint.
count() == 1 )
2034 if ( !destMultipart )
2044 multiPoint << *lineIt;
2060 if ( !destMultipart )
2071 multiPoint << *lineIt;
2081 multiPoint << *lineIt;
2091 QgsGeometry* QgsGeometry::convertToLine(
bool destMultipart )
const 2101 if ( multiPoint.
count() < 2 )
2104 if ( destMultipart )
2114 if (( destMultipart && srcIsMultipart ) ||
2115 ( !destMultipart && ! srcIsMultipart ) )
2120 if ( destMultipart )
2131 if ( multiLine.
count() == 1 )
2146 multiLine << *multiLineIt;
2148 if ( destMultipart )
2153 else if ( multiLine.
count() == 1 )
2164 if ( polygon.
count() > 1 )
2168 if ( destMultipart )
2173 multiLine << *multiLineIt;
2178 else if ( polygon.
count() == 1 )
2180 if ( destMultipart )
2198 QgsGeometry* QgsGeometry::convertToPolygon(
bool destMultipart )
const 2208 if ( multiPoint.
count() < 3 )
2211 if ( multiPoint.
last() != multiPoint.
first() )
2212 multiPoint << multiPoint.
first();
2215 if ( destMultipart )
2231 if (( *multiLineIt ).count() < 3 )
2233 if (( *multiLineIt ).count() == 3 && ( *multiLineIt ).first() == ( *multiLineIt ).last() )
2237 if (( *multiLineIt ).first() != ( *multiLineIt ).last() )
2238 *multiLineIt << ( *multiLineIt ).
first();
2239 multiPolygon << (
QgsPolygon() << *multiLineIt );
2242 if ( !multiPolygon.
isEmpty() )
2244 if ( destMultipart )
2248 else if ( multiPolygon.
count() == 1 )
2261 if ( line.
count() < 3 )
2268 line << line.
first();
2271 if ( destMultipart )
2287 if (( destMultipart && srcIsMultipart ) ||
2288 ( !destMultipart && ! srcIsMultipart ) )
2293 if ( destMultipart )
2303 if ( multiPolygon.
count() == 1 )
2319 return new QgsGeos( geometry );
2333 if ( byteArray.isEmpty() )
2339 char *data =
new char[byteArray.size()];
2340 memcpy( data, byteArray.data(), byteArray.size() );
2341 geometry.
fromWkb( reinterpret_cast< unsigned char* >( data ), byteArray.size() );
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
static QgsGeometry * fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
A rectangle specified with double values.
int numGeometries() const
Returns the number of geometries within the collection.
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
QgsGeometry * symDifference(const QgsGeometry *geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
virtual QgsCoordinateSequenceV2 coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry, using GEOS.
QgsAbstractGeometryV2 * combine(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
QPointF toQPointF() const
Converts a point to a QPointF.
int reshapeGeometry(const QList< QgsPoint > &reshapeWithLine)
Replaces a part of this geometry with another line.
void append(const T &value)
bool isValid() const
Returns true if the vertex id is valid.
void push_back(const T &value)
void fromWkb(unsigned char *wkb, int length)
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length...
bool isEmpty(QString *errorMsg=nullptr) const override
void points(QgsPointSequenceV2 &pt) const override
Returns a list of points within the curve.
bool touches(const QgsGeometry *geometry) const
Test for if geometry touch another (uses GEOS)
static bool compare(const QgsPolyline &p1, const QgsPolyline &p2, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compares two polylines for equality within a specified tolerance.
QgsGeometry shortestLine(const QgsGeometry &other, QString *errorMsg=nullptr) const
Returns the shortest line joining this geometry to the other geometry.
double area(QString *errorMsg=nullptr) const override
QVector< QgsPoint > QgsPolyline
Polyline is represented as a vector of points.
static Type multiType(Type type)
Returns the multi type for a WKB type.
virtual QgsCoordinateSequenceV2 coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
const_iterator constEnd() const
const T & at(int i) const
virtual QString asJSON(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
static QGis::WkbType fromNewWkbType(QgsWKBTypes::Type type)
Converts from new (post 2.10) WKB type (OGC) to old WKB type.
void setGeometry(QgsAbstractGeometryV2 *geometry)
Sets the underlying geometry store.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
int makeDifference(const QgsGeometry *other)
Changes this geometry such that it does not intersect the other geometry.
bool moveVertex(double x, double y, int atVertex)
Moves the vertex at the given position number and item (first number is index 0) to the given coordin...
static QgsAbstractGeometryV2 * fromPolygon(const QgsPolygon &polygon)
Construct geometry from a polygon.
Abstract base class for all geometries.
double length(QString *errorMsg=nullptr) const override
int addPart(const QList< QgsPoint > &points, QGis::GeometryType geomType=QGis::UnknownGeometry)
Adds a new part to a the geometry.
A geometry is the spatial representation of a feature.
static QgsAbstractGeometryV2 * fromGeos(const GEOSGeometry *geos)
Create a geometry from a GEOSGeometry.
static QgsPointV2 closestVertex(const QgsAbstractGeometryV2 &geom, const QgsPointV2 &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
QByteArray fromRawData(const char *data, int size)
WkbType
Used for symbology operations.
QgsGeometry()
Constructor.
QgsAbstractGeometryV2 * symDifference(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
bool isValid(QString *errorMsg=nullptr) const override
bool isGeosEmpty() const
Check if the geometry is empty using GEOS.
Multi point geometry collection.
QgsAbstractGeometryV2 * simplify(double tolerance, QString *errorMsg=nullptr) const override
static QgsAbstractGeometryV2 * fromPolyline(const QgsPolyline &polyline)
Construct geometry from a polyline.
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
static QgsAbstractGeometryV2 * fromPoint(const QgsPoint &point)
Construct geometry from a point.
static QgsAbstractGeometryV2 * fromMultiPolygon(const QgsMultiPolygon &multipoly)
Construct geometry from a multipolygon.
double y() const
Returns the point's y-coordinate.
QgsGeometry closestPoint(const QgsGeometry &other, QString *errorMsg=nullptr) const
Returns the closest point on the geometry to the other geometry.
bool insertVertex(double x, double y, int beforeVertex)
Insert a new vertex before the given vertex index, ring and item (first number is index 0) If the req...
static QgsAbstractGeometryV2 * geomFromWkb(QgsConstWkbPtr wkb)
Construct geometry from a WKB string.
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
QgsGeometry & operator=(QgsGeometry const &rhs)
Assignments will prompt a deep copy of the object.
int wkbSize() const
Returns the size of the WKB in asWkb().
Multi line string geometry collection.
static QgsPolyline createPolylineFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolyline from a QPolygonF.
QgsPolyline smoothLine(const QgsPolyline &polyline, const unsigned int iterations=1, const double offset=0.25) const
Smooths a polyline using the Chaikin algorithm.
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
static int addPart(QgsAbstractGeometryV2 *geom, QgsAbstractGeometryV2 *part)
Adds part to multi type geometry (taking ownership)
bool deleteRing(int ringNum, int partNum=0)
Delete a ring in polygon or multipolygon.
bool isGeosValid() const
Checks validity of the geometry using GEOS.
int splitGeometry(const QgsLineStringV2 &splitLine, QList< QgsAbstractGeometryV2 *> &newGeometries, bool topological, QgsPointSequenceV2 &topologyTestPoints, QString *errorMsg=nullptr) const override
Splits this geometry according to a given line.
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
static GEOSContextHandle_t getGEOSHandler()
double y() const
Get the y value of the point.
QgsGeometry * centroid() const
Returns the center of mass of a geometry.
QgsAbstractGeometryV2 * interpolate(double distance, QString *errorMsg=nullptr) const override
QgsGeometry * difference(const QgsGeometry *geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
static QgsAbstractGeometryV2 * geomFromWkt(const QString &text)
Construct geometry from a WKT string.
bool within(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
bool deletePart(int partNum)
Delete part identified by the part number.
bool contains(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
QgsMultiPoint asMultiPoint() const
Return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
bool intersects(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
Perform transforms between map coordinates and device coordinates.
QgsGeometry * convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
static QgsGeometry * fromQPointF(QPointF point)
Construct geometry from a QPointF.
static QgsAbstractGeometryV2 * fromMultiPoint(const QgsMultiPoint &multipoint)
Construct geometry from a multipoint.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
void append(const T &value)
int avoidIntersections(const QMap< QgsVectorLayer *, QSet< QgsFeatureId > > &ignoreFeatures=(QMap< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Modifies geometry to avoid intersections with the layers specified in project properties.
static double sqrDistance2D(const QgsPointV2 &pt1, const QgsPointV2 &pt2)
Returns the squared 2D distance between two points.
bool convertToSingleType()
Converts multi type geometry into single type geometry e.g.
QgsGeometry * pointOnSurface() const
Returns a point within a geometry.
Utility class for identifying a unique vertex within a geometry.
Line string geometry type, with support for z-dimension and m-values.
double sqrDistToVertexAt(QgsPoint &point, int atVertex) const
Returns the squared cartesian distance between the given point to the given vertex index (vertex at t...
QgsPoint interpolatePointOnLine(const QgsPoint &p1, const QgsPoint &p2, const double offset)
void setPoints(const QgsPointSequenceV2 &points)
Resets the line string to match the specified list of points.
QgsGeometry * buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
Point geometry type, with support for z-dimension and m-values.
QgsGeometry extrude(double x, double y)
Will extrude a line or (segmentized) curve by a given offset and return a polygon representation of i...
bool deleteVertex(int atVertex)
Deletes the vertex at the given position number and item (first number is index 0) Returns false if a...
QgsGeometry * smooth(const unsigned int iterations=1, const double offset=0.25) const
Smooths a geometry by rounding off corners using the Chaikin algorithm.
QgsAbstractGeometryV2 * intersection(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
QgsGeometry * interpolate(double distance) const
Return interpolated point on line at distance.
bool equals(const QgsGeometry *geometry) const
Test for if geometry equals another (uses GEOS)
bool crosses(const QgsGeometry *geometry) const
Test for if geometry crosses another (uses GEOS)
QVector< QgsPolygon > QgsMultiPolygon
A collection of QgsPolygons that share a common collection of attributes.
QVector< QgsPoint > QgsMultiPoint
A collection of QgsPoints that share a common collection of attributes.
void fromGeos(GEOSGeometry *geos)
Set the geometry, feeding in a geometry in GEOS format.
virtual unsigned char * asWkb(int &binarySize) const =0
Returns a WKB representation of the geometry.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
double x() const
Returns the point's x-coordinate.
virtual QgsPointV2 * clone() const override
Clones the geometry by performing a deep copy.
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
static void adjacentVertices(const QgsAbstractGeometryV2 &geom, QgsVertexId atVertex, QgsVertexId &beforeVertex, QgsVertexId &afterVertex)
Returns vertices adjacent to a specified vertex within a geometry.
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform)=0
Transforms the geometry using a coordinate transform.
QString exportToWkt(int precision=17) const
Exports the geometry to WKT.
virtual int partCount() const override
Returns count of parts contained in the geometry.
bool disjoint(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
QVector< QgsPolyline > QgsPolygon
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
bool within(const QgsGeometry *geometry) const
Test for if geometry is within another (uses GEOS)
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
void validateGeometry(QList< Error > &errors)
Validate geometry and produce a list of geometry errors.
void convertToStraightSegment()
Converts the geometry to straight line segments, if it is a curved geometry type. ...
static QgsAbstractGeometryV2 * geomFromWkbType(QgsWKBTypes::Type t)
Return empty geometry from wkb type.
Does vector analysis using the geos library and handles import, export, exception handling*...
int splitGeometry(const QList< QgsPoint > &splitLine, QList< QgsGeometry *> &newGeometries, bool topological, QList< QgsPoint > &topologyTestPoints)
Splits this geometry according to a given line.
A class to represent a point.
QgsGeometry * convertToType(QGis::GeometryType destType, bool destMultipart=false) const
Try to convert the geometry to the requested type.
static QgsGeometry * fromPoint(const QgsPoint &point)
Creates a new geometry from a QgsPoint object.
int translate(double dx, double dy)
Translate this geometry by dx, dy.
QgsGeometry * combine(const QgsGeometry *geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
double length() const
Returns the length of geometry using GEOS.
This class offers geometry processing methods.
QgsGeometry * simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
bool touches(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, eg both MultiPolygon and CurvePolygon would have a PolygonG...
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometryV2 *geometry)
Creates and returns a new geometry engine.
static GEOSGeometry * asGeos(const QgsAbstractGeometryV2 *geom, double precision=0)
void draw(QPainter &p) const
Draws the geometry onto a QPainter.
QgsAbstractGeometryV2 * reshapeGeometry(const QgsLineStringV2 &reshapeWithLine, int *errorCode, QString *errorMsg=nullptr) const
void setX(double x)
Sets the x value of the point.
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
QList< QgsGeometry * > asGeometryCollection() const
Return contents of the geometry as a list of geometries.
void setY(double y)
Sets the y value of the point.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
static void validateGeometry(const QgsGeometry *g, QList< QgsGeometry::Error > &errors)
Validate geometry and produce a list of geometry errors.
QPolygonF asQPolygonF() const
Return contents of the geometry as a QPolygonF.
QVector< QgsPolyline > QgsMultiPolyline
A collection of QgsPolylines that share a common collection of attributes.
double xMaximum() const
Get the x maximum value (right side of rectangle)
bool crosses(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
static QgsGeometry * fromMultiPolyline(const QgsMultiPolyline &multiline)
Creates a new geometry from a QgsMultiPolyline object.
static QgsGeometry * unaryUnion(const QList< QgsGeometry *> &geometryList)
Compute the unary union on a list of geometries.
static bool deletePart(QgsAbstractGeometryV2 *geom, int partNum)
Deletes a part from a geometry.
int vertexNrFromVertexId(QgsVertexId i) const
Returns the vertex number corresponding to a vertex idd.
QgsPolygon smoothPolygon(const QgsPolygon &polygon, const unsigned int iterations=1, const double offset=0.25) const
Smooths a polygon using the Chaikin algorithm.
static bool deleteRing(QgsAbstractGeometryV2 *geom, int ringNum, int partNum=0)
Deletes a ring from a geometry.
static QgsAbstractGeometryV2 * avoidIntersections(const QgsAbstractGeometryV2 &geom, QMap< QgsVectorLayer *, QSet< QgsFeatureId > > ignoreFeatures=(QMap< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Alters a geometry so that it avoids intersections with features from all open vector layers...
double closestSegmentWithContext(const QgsPoint &point, QgsPoint &minDistPoint, int &afterVertex, double *leftOf=nullptr, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
static QgsPolygon createPolygonFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolygon from a QPolygonF.
const T & at(int i) const
virtual QgsLineStringV2 * curveToLine() const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
const_iterator constBegin() const
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
virtual bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
QgsGeometry * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit) const
Returns an offset line at a given distance and side from an input line.
virtual bool insertVertex(QgsVertexId position, const QgsPointV2 &vertex)=0
Inserts a vertex into the geometry.
bool requiresConversionToStraightSegments() const
Returns true if the geometry is a curved geometry type which requires conversion to display as straig...
void mapToPixel(const QgsMapToPixel &mtp)
Transforms the geometry from map units to pixels in place.
QString exportToGeoJSON(int precision=17) const
Exports the geometry to GeoJSON.
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
bool centroid(QgsPointV2 &pt, QString *errorMsg=nullptr) const override
bool vertexIdFromVertexNr(int nr, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
const unsigned char * mWkb
int rotate(double rotation, const QgsPoint ¢er)
Rotate this geometry around the Z axis.
QPointF asQPointF() const
Return contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPointF...
const GEOSGeometry * asGeos(double precision=0) const
Returns a geos geometry.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
virtual bool addGeometry(QgsAbstractGeometryV2 *g)
Adds a geometry and takes ownership.
virtual QgsPolygonV2 * toPolygon() const
int count(const T &value) const
bool isEqual(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
virtual QgsAbstractGeometryV2 * segmentize() const
Returns a version of the geometry without curves.
double xMinimum() const
Get the x minimum value (left side of rectangle)
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
static QgsGeometry * fromMultiPoint(const QgsMultiPoint &multipoint)
Creates a new geometry from a QgsMultiPoint object.
static QgsAbstractGeometryV2 * fromMultiPolyline(const QgsMultiPolyline &multiline)
Construct geometry from a multipolyline.
bool pointOnSurface(QgsPointV2 &pt, QString *errorMsg=nullptr) const override
static QgsGeometry * fromPolyline(const QgsPolyline &polyline)
Creates a new geometry from a QgsPolyline object.
void adjacentVertices(int atVertex, int &beforeVertex, int &afterVertex) const
Returns the indexes of the vertices before and after the given vertex index.
double distance(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
static int addRing(QgsAbstractGeometryV2 *geom, QgsCurveV2 *ring)
Adds interior ring (taking ownership).
static Type flatType(Type type)
Returns the flat type for a WKB type.
Multi polygon geometry collection.
Contains geometry relation and modification algorithms.
double yMaximum() const
Get the y maximum value (top side of rectangle)
bool disjoint(const QgsGeometry *geometry) const
Test for if geometry is disjoint of another (uses GEOS)
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
static QgsGeometry * fromMultiPolygon(const QgsMultiPolygon &multipoly)
Creates a new geometry from a QgsMultiPolygon.
static QgsGeometry * fromPolygon(const QgsPolygon &polygon)
Creates a new geometry from a QgsPolygon.
~QgsGeometry()
Destructor.
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.
Curve polygon geometry type.
int addRing(const QList< QgsPoint > &ring)
Adds a new ring to this geometry.
bool overlaps(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
static QgsGeometry * fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
double area() const
Returns the area of the geometry using GEOS.
QgsAbstractGeometryV2 * difference(const QgsAbstractGeometryV2 &geom, QString *errorMsg=nullptr) const override
const_iterator constEnd() const
const_iterator constBegin() const
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
Abstract base class for curved geometry type.
virtual bool moveVertex(QgsVertexId position, const QgsPointV2 &newPos)=0
Moves a vertex within the geometry.
Represents a vector layer which manages a vector based data sets.
virtual double closestSegment(const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const =0
Searches for the closest segment of the geometry to a given point.
QgsPoint closestVertex(const QgsPoint &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist) const
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
QgsAbstractGeometryV2 * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit, QString *errorMsg=nullptr) const override
virtual double area() const
Returns the area of the geometry.
static void convertPointList(const QList< QgsPoint > &input, QgsPointSequenceV2 &output)
Upgrades a point list from QgsPoint to QgsPointV2.
double closestVertexWithContext(const QgsPoint &point, int &atVertex) const
Searches for the closest vertex in this geometry to the given point.
bool overlaps(const QgsGeometry *geometry) const
Test for if geometry overlaps another (uses GEOS)
QgsAbstractGeometryV2 * convexHull(QString *errorMsg=nullptr) const override
double x() const
Get the x value of the point.
virtual QgsPointV2 vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
QgsAbstractGeometryV2 * geometry
QgsAbstractGeometryV2 * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
int numPoints() const override
Returns the number of points in the curve.
QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry.
QgsPointV2 pointN(int i) const
Returns the specified point from inside the line string.