forked from anitagraser/TimeManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimelayer.py
93 lines (66 loc) · 2.06 KB
/
timelayer.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import abc
import conf
import time_util
class TimeLayer:
"""Manages the properties of a managed (managable) layer."""
__metaclass__ = abc.ABCMeta # this class cannot be instantiated directly
def __init__(self, layer, enabled=True):
self.layer = layer
self.timeEnabled = enabled
def getOriginalSubsetString(self):
return ''
def determine_format(self, val, fmtGiven):
if fmtGiven != time_util.PENDING:
return fmtGiven
else:
res = time_util.get_format_of_timeval(val)
return res
@abc.abstractmethod
def hasSubsetStr(self):
pass
def isInterpolationEnabled(self):
return False
def interpolationMode(self):
return conf.NO_INTERPOLATION
@abc.abstractmethod
def getOffset(self):
pass
@abc.abstractmethod
def getTimeFormat(self):
pass
@abc.abstractmethod
def getTimeAttributes(self):
pass
def hasIdAttribute(self):
return False
def getIdAttribute(self):
return None
def getLayer(self):
"""Get the layer associated with the current timeLayer"""
return self.layer
def getName(self):
"""Get the layer name as it is shown in the layers dock"""
return self.layer.name()
def getLayerId(self):
"""returns the layerID as registered in QgisMapLayerRegistry"""
try:
return self.layer.id() # function call for QGIS >= 1.7
except AttributeError:
return self.layer.getLayerID()
def geometriesCountForExport(self):
return True
def isEnabled(self):
"""whether timeManagement is enabled for this layer"""
return self.timeEnabled
class NotATimeAttributeError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class InvalidTimeLayerError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)