ЮЗ = a - 180
испрвавленный листинг
Код: Выделить всё
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
def rumb(x1,y1,x2,y2, feature, parent):
p1 = QgsPoint(x1,y1)
p2 = QgsPoint(x2,y2)
a = p1.azimuth(p2)
if a <= 0:
a += 360
if a < 90:
if a > 0:
d = math.floor(a)
c = round(a,1)
e = round(((c - d)*60),0)
b = u'СВ ' + str(int(d)) + u'°' + str(int(e)) + u'`'
if a == 90:
b = 'СВ 0°0`'
if a > 270:
if a < 360:
d = math.floor(360 - a)
c = round((360 - a),1)
e = round(((c - d)*60),0)
b = u'СЗ ' + str(int(d)) + u'°' + str(int(e)) + u'`'
if a == 360:
b = u'СЗ 0°0`'
if a > 180:
if a < 270:
d = math.floor(a - 180)
c = round((a - 180),1)
e = round(((c - d)*60),0)
b = u'ЮЗ ' + str(int(d)) + u'°' + str(int(e)) + u'`'
if a == 270:
b = u'ЮЗ 0°0`'
if a > 90:
if a < 180:
d = math.floor(180 - a)
c = round((180 - a),1)
e = round(((c - d)*60),0)
b = u'ЮВ ' + str(int(d)) + u'°' + str(int(e)) + u'`'
if a == 180:
b = u'ЮВ 0°0`'
b.encode( "cp866" )
return b