# HG changeset patch # User Nicolas Saunier # Date 1550874124 18000 # Node ID e23828659a66e8ca88a91321365ea32c002f6944 # Parent 1e833fd8490d1c46ff10334c612a8a8628d5a8a6 bug fixes diff -r 1e833fd8490d -r e23828659a66 trafficintelligence/ubc_utils.py --- a/trafficintelligence/ubc_utils.py Wed Feb 20 16:16:19 2019 -0500 +++ b/trafficintelligence/ubc_utils.py Fri Feb 22 17:22:04 2019 -0500 @@ -1,7 +1,7 @@ #! /usr/bin/env python '''Various utilities to load data saved by the UBC tool(s)''' -from trafficintelligence import utils, events, storage +from trafficintelligence import utils, events, storage, indicators from trafficintelligence.moving import MovingObject, TimeInterval, Trajectory @@ -60,10 +60,10 @@ infile = utils.openCheck(inFilename) outfile = utils.openCheck(outFilename,'w') - if (inFilename.find('features') >= 0) or (not infile) or (not outfile): + if (inFilename.find('features') >= 0) or infile is None or outfile is None: return - lines = storage.getLines(infile) + lines = utils.getLines(infile) objNum = 0 # in inFilename while lines != []: # find object in objects (index i) @@ -80,7 +80,7 @@ outfile.write(utils.delimiterChar+'\n') # next object objNum += 1 - lines = storage.getLines(infile) + lines = utils.getLines(infile) print('read {0} objects'.format(objNum)) @@ -89,7 +89,7 @@ fileIn = utils.openCheck(filenameIn, 'r', True) fileOut = utils.openCheck(filenameOut, "w", True) - lines = storage.getLines(fileIn) + lines = utils.getLines(fileIn) trajNum = 0 while (lines != []): modifiedLines = modifyLines(trajNum, lines) @@ -97,7 +97,7 @@ for l in modifiedLines: fileOut.write(l+"\n") fileOut.write(utils.delimiterChar+"\n") - lines = storage.getLines(fileIn) + lines = utils.getLines(fileIn) trajNum += 1 fileIn.close() @@ -109,14 +109,14 @@ fileIn = utils.openCheck(filenameIn, 'r', True) fileOut = utils.openCheck(filenameOut, "w", True) - lines = storage.getLines(fileIn) + lines = utils.getLines(fileIn) trajNum = 0 while (lines != []): if keepTrajectory(trajNum, lines): for l in lines: fileOut.write(l+"\n") fileOut.write(utils.delimiterChar+"\n") - lines = storage.getLines(fileIn) + lines = utils.getLines(fileIn) trajNum += 1 fileIn.close() @@ -125,14 +125,14 @@ def loadTrajectories(filename, nObjects = -1): '''Loads trajectories''' - file = utils.openCheck(filename) - if (not file): + f = utils.openCheck(filename) + if f is None: return [] objects = [] objNum = 0 objectType = getFileType(filename) - lines = storage.getLines(file) + lines = utils.getLines(f) while (lines != []) and ((nObjects<0) or (objNum