Beispiel #1
0
class TTSnowManagementInfo(TTExtInfo):
    _info_type_ = 'tt-workzone'
    _rel_attrs_ = {
        '_tt': {'key': 'tt_id', 'info_cls': TravelTimeInfo,
                'model_cls': lambda year: model_yearly.get_tt_table(int(year))},
        '_snowmgmt': {'key': 'snowmgmt_id', 'info_cls': SnowManagementInfo, 'model_cls': model.SnowManagement}}

    def __init__(self, **kwargs):
        super().__init__()
        self.id = None
        """:type: int """
        self.tt_id = None
        """:type: int """
        self.snowmgmt_id = None
        """:type: int """
        self._tt = None
        """:type: TravelTimeInfo """
        self._snowmgmt = None
        """:type: SnowManagementInfo """
        self.loc_type = None
        """:type: int """
        self.distance = None
        """:type: float """
        self.off_distance = None
        """:type: float """
        self.road_status = None
        """:type: int """
        self.recovery_level = None
        """:type: int """

    def __str__(self):
        return '<TTSnowManagementInfo id="%s" tt_id="%d" snowmgmt_id="%d" loc_type="%d" distance="%.2f" off_distance="%.2f" road_status="%d">' % (
            self.id, self.tt_id, self.snowmgmt_id, self.loc_type,
            self.distance, self.off_distance, self.road_status)
Beispiel #2
0
class TTSpecialeventInfo(TTExtInfo):
    _info_type_ = 'tt-specialevent'
    _rel_attrs_ = {
        '_tt': {'key': 'tt_id', 'info_cls': TravelTimeInfo,
                'model_cls': lambda year: model_yearly.get_tt_table(int(year))},
        '_specialevent': {'key': 'specialevent_id', 'info_cls': SpecialEventInfo, 'model_cls': model.Specialevent}}

    def __init__(self, **kwargs):
        super().__init__()
        self.id = None
        """:type: int """
        self.tt_id = None
        """:type: int """
        self.specialevent_id = None
        """:type: int """
        self._tt = None
        """:type: TravelTimeInfo """
        self._specialevent = None
        """:type: SpecialEventInfo """
        self.distance = None
        """:type: float """
        self.event_type = None
        """:type: str """

    def __str__(self):
        return '<TTSpecialEvent id="%d" tt_id="%d" specialevent_id="%d" distance="%d" event_type="%s">' % (
            self.id, self.tt_id, self.specialevent_id, self.distance, self.event_type)
 def __init__(self, year, dbModel, extModel, dataInfoType, **kwargs):
     """
     :param dbModel: DB model for tt_<ext data> table defined in `pyticas_tetres.db.model`
     :param extModel: DB model for external data defined in `pyticas_tetres.db.model`
     :param dataInfoType:  corresponding class to DB model defined in `pyticas_tetres.ttrms_types`
     """
     super().__init__(dbModel, dataInfoType, **kwargs)
     self.year = year
     self.extModel = extModel
     self.ttModel = model_yearly.get_tt_table(year)
     self.ttDA = TravelTimeDataAccess(year)
Beispiel #4
0
class TTWorkzoneInfo(TTExtInfo):
    _info_type_ = 'tt-workzone'
    _rel_attrs_ = {
        '_tt': {'key': 'tt_id', 'info_cls': TravelTimeInfo,
                'model_cls': lambda year: model_yearly.get_tt_table(int(year))},
        '_workzone': {'key': 'workzone_id', 'info_cls': WorkZoneInfo, 'model_cls': model.WorkZone},
        # '_feature': {'key': 'feature_id', 'info_cls': WorkZoneFeatureInfo, 'model_cls': model.WorkZoneFeature},
        # '_laneconfig': {'key': 'laneconfig_id', 'info_cls': WorkZoneLaneConfigInfo, 'model_cls': model.WorkZoneLaneConfig},
    }

    def __init__(self, **kwargs):
        super().__init__()
        self.id = None
        """:type: int """
        self.tt_id = None
        """:type: int """
        self.workzone_id = None
        """:type: int """
        # self.feature_id = None
        # """:type: int """
        # self.laneconfig_id = None
        # """:type: int """
        self._tt = None
        """:type: TravelTimeInfo """
        self._workzone = None
        """:type: WorkZoneInfo """
        # self._feature = None
        # """:type: WorkZoneFeatureInfo """
        # self._laneconfig = None
        # """:type: WorkZoneLaneConfigInfo """
        self.loc_type = None
        """:type: int """
        self.distance = None
        """:type: float """
        self.off_distance = None
        """:type: float """
        # self.characteristics = None
        # """:type: str """

    def __str__(self):
        return '<TTWorkzoneInfo id="%d" tt_id="%d" workzone_id="%d" loc_type="%d" distance="%.2f" off_distance="%.2f>' % (
            self.id, self.tt_id, self.workzone_id, self.loc_type,
            self.distance, self.off_distance)
Beispiel #5
0
def run(start_date, end_date):
    """

    :type start_date: datetime.date
    :type end_date: datetime.date
    """

    years = _years(start_date, end_date)
    for y in years:
        tt_table = model_yearly.get_tt_table(y)
        tt_table.drop(conn.engine)

        noaa_table = model_yearly.get_noaa_table(y)
        noaa_table.drop(conn.engine)

    da = IncidentDataAccess()
    da.delete_range_all(
        datetime.datetime.combine(start_date, datetime.time(0, 0, 0)),
        datetime.datetime.combine(end_date, datetime.time(23, 59, 59)))
    da.commit()
    da.close_session()
Beispiel #6
0
class TTIncidentInfo(TTExtInfo):
    _info_type_ = 'tt-incident'
    _rel_attrs_ = {
        '_tt': {'key': 'tt_id', 'info_cls': TravelTimeInfo,
                'model_cls': lambda year: model_yearly.get_tt_table(int(year))},
        '_incident': {'key': 'incident_id', 'info_cls': IncidentInfo, 'model_cls': model.Incident}}

    def __init__(self, **kwargs):
        super().__init__()
        self.id = None
        """:type: int """
        self.tt_id = None
        """:type: int """
        self.incident_id = None
        """:type: int """
        self._tt = None
        """:type: TravelTimeInfo """
        self._incident = None
        """:type: IncidentInfo """
        self.distance = None  # distance in mile from the upstream boundary of TTR route, negative value means incident is occure in upstream
        """:type: float """
        self.off_distance = None  # distance in mile from boundary of TTR route
        """:type: float """

    def get_incident(self):
        """
        :rtype: IncidentInfo
        """
        return self._incident

    def get_tt_info(self):
        """
        :rtype: TravelTimeInfo
        """
        return self._tt

    def __str__(self):
        return '<TTIncidentInfo id="%d" tt_id="%d" incident_id="%d" distance="%.2f" off_distance="%.2f">' % (
            self.id, self.tt_id, self.incident_id, self.distance, self.off_distance)
Beispiel #7
0
class TTWeatherInfo(TTExtInfo):
    _info_type_ = 'tt-weather'
    _rel_attrs_ = {
        '_tt': {'key': 'tt_id', 'info_cls': TravelTimeInfo,
                'model_cls': lambda year: model_yearly.get_tt_table(int(year))},
        '_weather': {'key': 'weather_id', 'info_cls': NoaaWeatherInfo,
                     'model_cls': lambda year: model_yearly.get_noaa_table(int(year))}}

    def __init__(self, **kwargs):
        super(TTWeatherInfo, self).__init__()
        self.id = None
        """:type: int """
        self.tt_id = None
        """:type: int """
        self.weather_id = None
        """:type: int """
        self._tt = None
        """:type: TravelTimeInfo """
        self._weather = None
        """:type: NoaaWeatherInfo """

    def __str__(self):
        return '<TTWeatherInfo id="%d" tt_id="%d" weather_id="%d">' % (self.id, self.tt_id, self.weather_id)
Beispiel #8
0
 def __init__(self, year, **kwargs):
     super().__init__(**kwargs)
     self.da_base = DataAccessBase(model_yearly.get_tt_table(year), TravelTimeInfo,
                                   **kwargs)