Bug report #19941

QgsLineString unexpected behaviour when constructed

Added by Ivan Majic almost 6 years ago. Updated almost 6 years ago.

Status:Rejected
Priority:Normal
Assignee:-
Category:Geometry
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

Description

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]).

In short:
Expected = QgsLineString([x1, y1], [x2, y2])
Actual = QgsLineString([x1, x2], [y1, y2])

History

#1 Updated by Alessandro Pasotti almost 6 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.

#2 Updated by Harrissou Santanna almost 6 years ago

Can you point the place in the documentation where arrays of coordinates as in QgsLineString([x1, y1], [x2, y2]) is mentioned, please? Thanks.

Also available in: Atom PDF