-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathosc_models.py
97 lines (75 loc) · 2.82 KB
/
osc_models.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
94
95
96
97
"""osc_models module contains all the application level models"""
# pylint: disable=R0902
from typing import Optional
from common.models import CameraProjection
class Sequence:
"""Sequence is a model class containing a list of visual items"""
def __init__(self):
self.path: str = ""
self.online_id: str = ""
self.progress: [str] = []
self.visual_items: [VisualData] = []
self.osc_metadata: str = ""
self.visual_data_type: str = ""
self.latitude: float = None
self.longitude: float = None
self.platform: Optional[str] = None
self.device: Optional[str] = None
@property
def description(self) -> str:
"""this method returns a string description of a sequence"""
return self.online_id + self.osc_metadata + self.visual_data_type
def visual_data_count(self) -> int:
"""this method returns the count of visual data"""
return len(self.visual_items)
def __eq__(self, other):
"""Overrides the default implementation"""
if isinstance(other, Sequence):
return self.path == other.path
return False
def __hash__(self):
return hash(self.path)
class VisualData:
"""VisualData is a model class for a visual item"""
def __init__(self, path):
self.path: str = path
self.index: int = None
def __eq__(self, other):
if isinstance(other, VisualData):
return self.path == other.path and \
self.index == other.index
return False
def __hash__(self):
return hash((self.path, self.index))
class Photo(VisualData):
"""Photo is a VisualData model for a photo item"""
def __init__(self, path):
super().__init__(path)
self.latitude: float = None
self.longitude: float = None
self.exif_timestamp: float = None
self.gps_timestamp: float = None
self.gps_speed: float = None
self.gps_altitude: float = None
self.gps_compass: float = None
self.fov: Optional[float] = None
self.projection: CameraProjection = None
def __eq__(self, other):
if isinstance(other, Photo):
return self.gps_timestamp == other.gps_timestamp and \
self.latitude == other.path and \
self.longitude == other.longitude
return False
def __hash__(self):
return hash((self.gps_timestamp,
self.latitude,
self.longitude))
class Video(VisualData):
"""Video is a VisualData model for a video item"""
def __eq__(self, other):
if isinstance(other, Video):
return self.path == other.path and self.index == other.index
return False
def __hash__(self):
return hash((self.path, self.index))
# pylint: enable=R0902