~awuerl/blitzortung-python/master

« back to all changes in this revision

Viewing changes to blitzortung/builder.py

  • Committer: Andreas Würl
  • Date: 2013-08-23 20:30:43 UTC
  • Revision ID: git-v1:1a508e2edcac3abeaea1a0bcc22f551e5061f94b
updated builder tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
        super(Stroke, self).__init__()
79
79
        self.id_value = -1
80
80
        self.altitude = None
81
 
        self.participants = []
 
81
        self.stations = []
82
82
 
83
83
    def set_id(self, id_value):
84
84
        self.id_value = id_value
104
104
        self.station_count = station_count
105
105
        return self
106
106
 
107
 
    def set_participants(self, participants):
108
 
        self.participants = participants
 
107
    def set_stations(self, stations):
 
108
        self.stations = stations
109
109
        return self
110
110
 
111
111
    def build(self):
112
112
        return blitzortung.data.Stroke(self.id_value, self.timestamp, self.x_coord, self.y_coord, self.amplitude,
113
113
                                       self.altitude, self.lateral_error, self.type_val, self.station_count,
114
 
                                       self.participants)
 
114
                                       self.stations)
115
115
 
116
116
    def from_data(self, data):
117
117
        """ Construct stroke from new blitzortung text format data line """
123
123
        self.set_amplitude(float(data['str']))
124
124
        self.set_lateral_error(float(data['dev']))
125
125
        self.set_type(int(data['typ']))
126
 
        self.set_station_count(int(data['sta'][1]))
 
126
        stations = data['sta']
 
127
        self.set_station_count(int(stations[0]))
 
128
        self.set_stations([int(station) for station in stations[2].split(',')])
127
129
        return self
128
130
 
129
131