azimuth.py
1 |
"""
|
---|---|
2 |
Define new functions using @qgsfunction. feature and parent must always be the
|
3 |
last args. Use args=-1 to pass a list of values as arguments
|
4 |
"""
|
5 |
|
6 |
from qgis.core import * |
7 |
from qgis.gui import * |
8 |
|
9 |
@qgsfunction(args='auto', group='Custom') |
10 |
def azimuth(x1,y1,x2,y2, feature, parent): |
11 |
p1 = QgsPoint(x1,y1) |
12 |
p2 = QgsPoint(x2,y2) |
13 |
a = p1.azimuth(p2) |
14 |
if a < 0: |
15 |
|
16 |
a += 360
|
17 |
return a
|