Bug report #19941
QgsLineString unexpected behaviour when constructed
|Affected QGIS version:||3.2.1||Regression?:||No|
|Operating System:||Ubuntu 18.10||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||invalid|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||27763|
While developing a plugin I have been using creating lines between two points with QgsLineString(). The documentation states that it can be constructed from two points as in QgsLineString(QgsPoint1, QgsPoint2), or from arrays of coordinates as in QgsLineString([x1, y1], [x2, y2]).
I was getting unexpected results until I realized that coordinated get mixed up somewhere in the process. The only way in which I was able to create the expected results is if I used QgsLineString([x1, x2], [y1, y2]).
Expected = QgsLineString([x1, y1], [x2, y2])
Actual = QgsLineString([x1, x2], [y1, y2])
#1 Updated by Alessandro Pasotti about 4 years ago
- Resolution set to invalid
- Status changed from Open to Rejected
This is the signature you are calling by passing two arrays:
QgsLineString(x: Iterable[float], y: Iterable[float], z: Iterable[float] = , m: Iterable[float] = )
Construct a linestring from arrays of coordinates. If the z or m
arrays are non-empty then the resultant linestring will have
z and m types accordingly.