2018-11-15 12:44:15 +00:00
|
|
|
from typing import Tuple
|
|
|
|
|
2018-11-14 13:40:05 +00:00
|
|
|
from shapely.geometry import Point
|
2018-11-15 12:44:15 +00:00
|
|
|
from shapely.geometry import Polygon
|
2018-11-14 13:40:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Area:
|
|
|
|
|
|
|
|
def __init__(self, coords, name=''):
|
|
|
|
self.rectangle = Polygon(coords)
|
|
|
|
self.name = name
|
|
|
|
self.emissions = 0.0
|
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
return self.rectangle.__eq__(other)
|
|
|
|
|
2018-11-15 11:20:19 +00:00
|
|
|
def __contains__(self, item):
|
2018-11-15 12:44:15 +00:00
|
|
|
return self.rectangle.contains(item)
|
2018-11-15 11:20:19 +00:00
|
|
|
|
2018-11-14 13:40:05 +00:00
|
|
|
@property
|
|
|
|
def bounds(self):
|
|
|
|
return self.rectangle.bounds
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_bounds(cls, xmin, ymin, xmax, ymax):
|
|
|
|
return cls((
|
|
|
|
(xmin, ymin),
|
|
|
|
(xmin, ymax),
|
|
|
|
(xmax, ymax),
|
|
|
|
(xmax, ymin)))
|
2018-11-15 12:44:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Vehicle:
|
|
|
|
|
|
|
|
def __init__(self, id: int, pos: Tuple[float, float]):
|
|
|
|
self.id = id
|
|
|
|
self.pos = Point(pos)
|
|
|
|
|
|
|
|
def __repr__(self) -> str:
|
|
|
|
return str(self.__dict__)
|