1
0
mirror of https://github.com/Ahp06/SUMO_Emissions.git synced 2024-11-22 11:36:29 +00:00
sumo-emissions/sumo_project/area.py

29 lines
652 B
Python
Raw Normal View History

2018-11-14 13:40:05 +00:00
from shapely.geometry import Polygon
from shapely.geometry import Point
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)
def __contains__(self, item):
return self.rectangle.contains(Point(item))
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)))