-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmap_setup.py
More file actions
39 lines (31 loc) · 1.18 KB
/
map_setup.py
File metadata and controls
39 lines (31 loc) · 1.18 KB
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
"""This module contains the MapArea and Midpoint classes.
Together they represent the points of the map that we are working with.
"""
from typing import Tuple
from dataclasses import dataclass
@dataclass
class MapArea:
"""A map of a certain area.
Instance Attributes:
- latitude: the range of the map in latitude
- longitude: the range of the map in longitude
Representation Invariants:
- all(-90 <= l <= 90 for l in self.latitude)
- self.latitude[0] < self.latitude[1]
- all(-180 <= l <= 180 for l in self.longitude)
- self.longitude[0] < self.longitude[1]
"""
latitude: Tuple[float, float]
longitude: Tuple[float, float]
@dataclass
class Midpoint:
"""A midpoint in a grid.
Instance Attributes:
- coords: the coordinates of this point (latitude, longitude)
- map: the MapArea that this midpoint is on
Representation Invariants:
- self.map_area.latitude[1] <= self.coords[0] <= self.map_area.latitude[1]
- self.map_area.longitude[1] <= self.coords[1] <= self.map_area.longitude[1]
"""
coords: Tuple[float, float]
map_area: MapArea