-
Notifications
You must be signed in to change notification settings - Fork 2
/
funcs.py
43 lines (32 loc) · 1.41 KB
/
funcs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from math import floor
from PyQt5.Qt import QLocale, QCoreApplication
from qgis.core import QgsMessageLog
def coordinatorDmsStringsToDecimal(deg, minute, sec):
result = 0.0
if(len(deg)>0): result += QLocale().toFloat(deg)[0]
if(len(minute)>0): result += QLocale().toFloat(minute)[0]/60
if(len(sec)>0): result += QLocale().toFloat(sec)[0]/3600
return result
def coordinatorDecimalToDms(deg):
isNegative = deg < 0
degree = int(floor(abs(deg)))
deg2 = abs(deg)-degree
minute = int(floor(deg2 * 60))
seconds = ( deg2 % (1/60) ) * 3600
return (isNegative, degree, minute, seconds)
def coordinatorLog(message):
QgsMessageLog.logMessage(message, "Coordinator")
class CoordinatorTranslator:
# noinspection PyMethodMayBeStatic
def tr(message, disambugation = None):
"""Get the translation for a string using Qt translation API.
We implement this ourselves since we do not inherit QObject.
:param message: String for translation.
:type message: str, QString
:param disambugation: an identifying string, for when the same sourceText is used in different roles within the same context
:type disambugation: str, QString
:returns: Translated version of message.
:rtype: QString
"""
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
return QCoreApplication.translate('CT', message, disambugation)