The QgsPoint class has an azimuth() method but the new QgsPointV2 class does not. What's the best way to compute the azimuth between QgsPointV2s? I couldn't find a convenient way to convert V2 to the old version, so my fallback is to construct a QgsPoint from the V2's x and y:
self.traj = QgsLineStringV2(...)
p_i = self.traj.pointN(self.i) # this returns a QgsPointV2
p_j = self.traj.pointN(self.j)
a = QgsPoint(p_i.x(),p_i.y()).azimuth(QgsPoint(p_j.x(),p_j.y()))
Is there a better way?
Answer
azimuth()
has been added to QgsPointV2 in a recent commit from 2016-11-05.
Guess I'll stick to the code outlined in the question until this change appears in the releases.
No comments:
Post a Comment