File: Taxi.py

package info (click to toggle)
sumo 0.28.0+dfsg1-1~bpo8+1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 103,616 kB
  • sloc: xml: 534,021; cpp: 183,697; python: 66,271; java: 43,017; ansic: 36,466; sh: 11,391; makefile: 1,411; perl: 450
file content (79 lines) | stat: -rw-r--r-- 2,011 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
# -*- coding: Latin-1 -*-
"""
@file    CalcTime.py
@author  Sascha Krieg
@author  Daniel Krajzewicz
@author  Michael Behrisch
@date    2008-04-17
@version $Id: Taxi.py 20433 2016-04-13 08:00:14Z behrisch $

Represents a single Taxi.

SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
Copyright (C) 2008-2016 DLR (http://www.dlr.de/) and contributors

This file is part of SUMO.
SUMO is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
"""

# Constants
SOURCE_VTYPE = 'vtypeProbe'
SOURCE_FCD = 'FCD'
SOURCE_SIMFCD = 'simFCD'


class Step(object):

    """Represents a single Step like its used in the analysis File."""

    def __init__(self, time, source, speed, rawSpeed, edge, lat, lon):
        self.time = int(time)
        self.source = source
        self.speed = int(speed)
        if rawSpeed == 'None':
            self.rawSpeed = None
        else:
            self.rawSpeed = int(rawSpeed)
        self.edge = edge
        if lat == 'None':
            self.lat = None
        else:
            self.lat = lat
        if lon == 'None':
            self.lon = None
        else:
            self.lon = lon

    def __str__(self):
        return "(%s, %s, %s, %s, %s, %s, %s)" % (self.time, self.source, self.speed, self.rawSpeed, self.edge, self.lat, self.lon)

    def __repr__(self):
        return self.__str__()


class Taxi(object):

    """Represents a Taxi (with ID and all available Data form the analysis File)."""

    def __init__(self, id):
        self.id = id
        self.steps = []

    def addStep(self, step):
        self.steps.append(step)

    def getSteps(self):
        return self.steps

    def __str__(self):
        return "%s, %s" % (self.id, self.steps)

    def __repr__(self):
        return self.__str__()

    def __eq__(self, id):
        return self.id == id