Ejemplo n.º 1
0
                print("Waiting for message or event/error in poll()")
                continue
            elif msg.error():
                print('error: {}'.format(msg.error()))
            else:
                # Check for Kafka message
                record_value = msg.value()
                data = json.loads(record_value)
                velocity = v.validateVelocity(data)
                lat = v.validateLatitude(data)
                long = v.validateLongitude(data)
                opd = v.validateOperationDay(data)
                dir = v.validateDirection(data)
                meters = v.validateMeters(data)
                rq = v.validateRadioQuality(data)
                hdop = v.validateHDOP(data)
                sat = v.validateSatellites(data)
                stdev = v.validateScheduleDeviation(data)
                act_time = v.validateActTime(data)
                vID = v.validateVehicleID(data)
                sID = v.validateStopID(data)
                tID = v.validateTripID(data)

                # discard rows with invalid fields
                if act_time is False or opd is False or lat is False or long is False or dir is False or velocity is False or tID is False or vID is False:
                    continue

                breadcrumb_val = getBreadcrumbVal(act_time, opd, lat, long,
                                                  dir, velocity, tID)
                trip_val = getTripVal(tID, 0, vID, 'Weekday', 'Out')