Mercurial Hosting > traffic-intelligence
comparison python/storage.py @ 908:b297525b2cbf
added options to the prototype cluster algorithm, work in progress
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 26 Jun 2017 00:10:35 -0400 |
parents | 753a081989e2 |
children | cd038493f8c6 |
comparison
equal
deleted
inserted
replaced
907:9fd7b18f75b4 | 908:b297525b2cbf |
---|---|
16 delimiterChar = '%'; | 16 delimiterChar = '%'; |
17 | 17 |
18 ngsimUserTypes = {'twowheels':1, | 18 ngsimUserTypes = {'twowheels':1, |
19 'car':2, | 19 'car':2, |
20 'truck':3} | 20 'truck':3} |
21 | |
22 tableNames = {'feature':'positions', | |
23 'object': 'objects', | |
24 'objectfeatures': 'positions'} | |
21 | 25 |
22 ######################### | 26 ######################### |
23 # Sqlite | 27 # Sqlite |
24 ######################### | 28 ######################### |
25 | 29 |
409 if dbFilenames is not None: | 413 if dbFilenames is not None: |
410 dbfn = dbFilenames[i] | 414 dbfn = dbFilenames[i] |
411 else: | 415 else: |
412 dbfn = filename | 416 dbfn = filename |
413 cursor.execute('INSERT INTO prototypes (id, dbfilename, trajectory_type, nMatchings) VALUES ({},\"{}\",\"{}\",{})'.format(protoId, dbfn, trajectoryType, n)) | 417 cursor.execute('INSERT INTO prototypes (id, dbfilename, trajectory_type, nMatchings) VALUES ({},\"{}\",\"{}\",{})'.format(protoId, dbfn, trajectoryType, n)) |
418 cursor.execute('SELECT * from sqlite_master WHERE type = \"table\" and name = \"{}\"'.format(tableNames[trajectoryType])) | |
419 if len(cursor.fetchall) == 0: | |
420 pass # save prototype trajectory data | |
414 except sqlite3.OperationalError as error: | 421 except sqlite3.OperationalError as error: |
415 printDBError(error) | 422 printDBError(error) |
416 connection.commit() | 423 connection.commit() |
417 connection.close() | 424 connection.close() |
418 | 425 |