forked from anitagraser/TimeManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimelayer.py
42 lines (34 loc) · 1.2 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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from datetime import datetime, timedelta
from qgis.core import *
class TimeLayer:
"""Manages the properties of a managed (managable) layer."""
def __init__(self,layer,enabled=True):
self.layer = layer
self.timeEnabled = enabled
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 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)