Skip to content

Commit 46a6f25

Browse files
authoredOct 23, 2017
Merge pull request #5418 from nyalldawson/from_polyline
Rename QgsGeometry::fromPolyline as QgsGeometry::fromPolylineXY
2 parents 2f44de0 + c4f3832 commit 46a6f25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+443
-338
lines changed
 

‎doc/api_break.dox

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,9 @@ empty geometry collection)
12831283
- isGeosEmpty() was removed. Use isEmpty() instead.
12841284
- reshapeGeometry() expects QgsLineString as a parameter instead of a list of 2D points (so that it can support 3D geometries)
12851285
- vertexAt() now returns a QgsPoint (previously QgsPointV2) instead of a QgsPointXY (previously QgsPoint)
1286+
- fromPolyline() now requires a list of QgsPoint objects, instead of QgsPointXY 2d points. A new method fromPolylineXY was
1287+
added which uses the old list of 2d QgsPointXY objects. Using the newer method with QgsPoint is greatly preferred, as it
1288+
maintains Z or M dimensions from the input points and is more efficient.
12861289

12871290

12881291
QgsGeometryAnalyzer {#qgis_api_break_3_0_QgsGeometryAnalyzer}
@@ -1892,6 +1895,13 @@ plugins calling this method will need to be updated.
18921895
plugins calling this method will need to be updated.
18931896

18941897

1898+
QgsPolyline {#qgis_api_break_3_0_QgsPolyline}
1899+
-----------
1900+
1901+
- QgsPolyline now consists of a list of QgsPoint, instead of 2d QgsPointXY objects. The 2d polyline variant has
1902+
been renamed to QgsPolylineXY
1903+
1904+
18951905
QgsProject {#qgis_api_break_3_0_QgsProject}
18961906
----------
18971907

‎python/core/geometry/qgsgeometry.sip

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616

1717

18-
typedef QVector<QgsPointXY> QgsPolyline;
18+
typedef QVector<QgsPointXY> QgsPolylineXY;
19+
20+
typedef QVector<QgsPoint> QgsPolyline;
1921

2022
typedef QVector<QVector<QgsPointXY>> QgsPolygon;
2123

@@ -122,11 +124,35 @@ Creates a new geometry from a QgsPointXY object
122124
Creates a new geometry from a QgsMultiPoint object
123125
:rtype: QgsGeometry
124126
%End
127+
128+
static QgsGeometry fromPolylineXY( const QgsPolylineXY &polyline );
129+
%Docstring
130+
Creates a new LineString geometry from a list of QgsPointXY points.
131+
132+
Using fromPolyline() is preferred, as fromPolyline() is more efficient
133+
and will respect any Z or M dimensions present in the input points.
134+
135+
.. note::
136+
137+
In QGIS 2.x this method was available as fromPolyline().
138+
139+
.. versionadded:: 3.0
140+
.. seealso:: fromPolyline()
141+
:rtype: QgsGeometry
142+
%End
143+
125144
static QgsGeometry fromPolyline( const QgsPolyline &polyline );
126145
%Docstring
127-
Creates a new geometry from a QgsPolyline object
146+
Creates a new LineString geometry from a list of QgsPoint points.
147+
148+
This method will respect any Z or M dimensions present in the input points.
149+
E.g. if input points are PointZ type, the resultant linestring will be
150+
a LineStringZ type.
151+
152+
.. versionadded:: 3.0
128153
:rtype: QgsGeometry
129154
%End
155+
130156
static QgsGeometry fromMultiPolyline( const QgsMultiPolyline &multiline );
131157
%Docstring
132158
Creates a new geometry from a QgsMultiPolyline object
@@ -1065,11 +1091,11 @@ Returns an extruded version of this geometry.
10651091
:rtype: QgsPointXY
10661092
%End
10671093

1068-
QgsPolyline asPolyline() const;
1094+
QgsPolylineXY asPolyline() const;
10691095
%Docstring
10701096
Returns contents of the geometry as a polyline
10711097
if wkbType is WKBLineString, otherwise an empty list
1072-
:rtype: QgsPolyline
1098+
:rtype: QgsPolylineXY
10731099
%End
10741100

10751101
QgsPolygon asPolygon() const;
@@ -1349,13 +1375,13 @@ Returns an extruded version of this geometry.
13491375
:rtype: QgsGeometry
13501376
%End
13511377

1352-
static QgsPolyline createPolylineFromQPolygonF( const QPolygonF &polygon ) /Factory/;
1378+
static QgsPolylineXY createPolylineFromQPolygonF( const QPolygonF &polygon ) /Factory/;
13531379
%Docstring
1354-
Creates a QgsPolyline from a QPolygonF.
1380+
Creates a QgsPolylineXY from a QPolygonF.
13551381
\param polygon source polygon
1356-
:return: QgsPolyline
1382+
:return: QgsPolylineXY
13571383
.. seealso:: createPolygonFromQPolygonF
1358-
:rtype: QgsPolyline
1384+
:rtype: QgsPolylineXY
13591385
%End
13601386

13611387
static QgsPolygon createPolygonFromQPolygonF( const QPolygonF &polygon ) /Factory/;
@@ -1371,7 +1397,7 @@ Returns an extruded version of this geometry.
13711397
static bool compare( PyObject *obj1, PyObject *obj2, double epsilon = 4 * DBL_EPSILON );
13721398
%Docstring
13731399
Compares two geometry objects for equality within a specified tolerance.
1374-
The objects can be of type QgsPolyline, QgsPolygon or QgsMultiPolygon.
1400+
The objects can be of type QgsPolylineXY, QgsPolygon or QgsMultiPolygon.
13751401
The 2 types should match.
13761402
\param p1 first geometry object
13771403
\param p2 second geometry object
@@ -1408,10 +1434,10 @@ Returns an extruded version of this geometry.
14081434
sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
14091435
sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
14101436
{
1411-
QgsPolyline *p0;
1412-
QgsPolyline *p1;
1413-
p0 = reinterpret_cast<QgsPolyline *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1414-
p1 = reinterpret_cast<QgsPolyline *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1437+
QgsPolylineXY *p0;
1438+
QgsPolylineXY *p1;
1439+
p0 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1440+
p1 = reinterpret_cast<QgsPolylineXY *>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
14151441
if ( sipIsErr )
14161442
{
14171443
sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );

0 commit comments

Comments
 (0)
Please sign in to comment.