[QGIS-Developer] QGIS 3 - QgsPoint vs. QgsPointXY

Nyall Dawson nyall.dawson at gmail.com
Wed Oct 25 14:30:03 PDT 2017


On 26 October 2017 at 02:09, C Hamilton <adenaculture at gmail.com> wrote:
> Did the QGIS 3 API just go back to QgsPoint rather than the QgsPointXY for
>
> QgsGeometry.fromPolyline()

Yes, see [1]. From the PR:


"Rename QgsGeometry::fromPolyline as QgsGeometry::fromPolylineXY
...and add new QgsGeometry::fromPolyline which uses QgsPoint

We want to encourage people not to use the QgsPointXY method, as it
drops Z/M values. So it's moved across to a different name to make way
for a new QgsGeometry::fromPolyline which uses a QgsPoint list instead
of QgsPointXY, thus keeping Z/M values intact.
Similarly, QgsPolyline now is a list of QgsPoint (keeping z/m values)
and the old 2d QgsPolyline type was renamed to QgsPolylineXY.
Making the QgsPoint method the "preferred" method and making
linestrings just as easy to create from z/m dimensioned points as 2d
points is important to push people to write code which does not
discard these important dimensions.

As a bonus, the QgsPoint methods are more efficient anyway, since they
don't require creation of a temporary list."

So you could do a quick change of fromPolyline -> fromPolylineXY. But
if you're working with existing geometries/points, use the QgsPoint
based fromPolyline instead, and all users with Z/M dimensioned data
will thank you!

> When do you expect to have the QGIS 3 API stable?

No sooner than the final release... We'll be stuck with the 3.0 API
for a LOOOOOONG time, so we need to ensure it's as good as we can get
before we hit the final release deadline.

Nyall


More information about the QGIS-Developer mailing list