Exemple #1
0
 def trust(self, trust_report):
     self.headcode = trust_report['headcode']
     self.cif_uid = db_queries.cif_uidFromHeadcode(self.headcode)
     self.origin_location = trust_report['origin_location']
     self.origin_departure = trust_report['origin_departure']
     self.matching.append({
         'gps': None,
         'trust': trust_report,
         'dist_error': None
     })
Exemple #2
0
def checkPotentialMatches(segment, potential_matches):
    if len(potential_matches) > globals.min_matching:
        globals.lock.acquire()
        segment.headcode = potential_matches[0]["trust"]["headcode"]
        segment.cif_uid = db_queries.cif_uidFromHeadcode(segment.headcode)
        segment.origin_location = potential_matches[0]["trust"]["origin_location"]
        segment.origin_departure = potential_matches[0]["trust"]["origin_departure"]
        for match in potential_matches:
            segment.matching[match["index"]]["trust"] = match["trust"]
        socket_io.emitSegment("update", segment)
        globals.lock.release()
Exemple #3
0
def checkPotentialMatches(segment, potential_matches):
    if len(potential_matches) > globals.min_matching:
        globals.lock.acquire()
        segment.headcode = potential_matches[0]['trust']['headcode']
        segment.cif_uid = db_queries.cif_uidFromHeadcode(segment.headcode)
        segment.origin_location = potential_matches[0]['trust']['origin_location']
        segment.origin_departure = potential_matches[0]['trust']['origin_departure']
        for match in potential_matches:
            segment.matching[match['index']]['trust'] = match['trust']
        socket_io.emitSegment('update', segment)
        globals.lock.release()
Exemple #4
0
def getBestStop(segments1, trust, with_seq):
    segments = filter(lambda x: x['segment'].gps_car_id is not None, segments1)
    segments.sort(key=lambda x: isBetterSegment(x), reverse=True)
    for segment1 in segments:
        segment = segment1['segment']
        segment.matching.sort(key=lambda x: getTimeForMatching(x), reverse=True)
        matching = segment.matching[0: globals.backmatches]
        best = getBestStopHelper(matching, trust, True)
        if best is not None:
            best['match']['trust'] = trust
            best['match']['dist_error'] = best['dist_error']
            if segment.headcode is None:
                segment.headcode = trust['headcode']
                segment.cif_uid = db_queries.cif_uidFromHeadcode(trust['headcode'])
                segment.isPlanned = db_queries.isPlanned(segment.gps_car_id, trust['headcode'])
                segment.origin_location = trust['origin_location']
                segment.origin_departure = trust['origin_departure']
            socket_io.emitSegment('update', segment)
            return True
    return False
 def testcif_uidFromHeadcode3(self):
     result = db_queries.cif_uidFromHeadcode('0')
     self.assertEqual(result, None)