|
|
|
@ -83,6 +83,7 @@ class lcl: |
|
|
|
self.roads=self.dat_to_tuple_dict(lcldir,'ROADS.DAT','ISO 8859-15','Road') |
|
|
|
self.roads=self.dat_to_tuple_dict(lcldir,'ROADS.DAT','ISO 8859-15','Road') |
|
|
|
self.segments=self.dat_to_tuple_dict(lcldir,'SEGMENTS.DAT','ISO 8859-15','Segment') |
|
|
|
self.segments=self.dat_to_tuple_dict(lcldir,'SEGMENTS.DAT','ISO 8859-15','Segment') |
|
|
|
self.areas=self.dat_to_tuple_dict(lcldir,'ADMINISTRATIVEAREA.DAT','ISO 8859-15','Area') |
|
|
|
self.areas=self.dat_to_tuple_dict(lcldir,'ADMINISTRATIVEAREA.DAT','ISO 8859-15','Area') |
|
|
|
|
|
|
|
self.subtypes=self.subtypesDat_to_dict(lcldir,'SUBTYPES.DAT','ISO 8859-15') |
|
|
|
self.init_done=True |
|
|
|
self.init_done=True |
|
|
|
|
|
|
|
|
|
|
|
print("lcl time:\t"+str(time.time()-self.start)) |
|
|
|
print("lcl time:\t"+str(time.time()-self.start)) |
|
|
|
@ -90,6 +91,7 @@ class lcl: |
|
|
|
except IOError as e: |
|
|
|
except IOError as e: |
|
|
|
print(e) |
|
|
|
print(e) |
|
|
|
print("location table not found") |
|
|
|
print("location table not found") |
|
|
|
|
|
|
|
|
|
|
|
def lcn_allocated(self,LCN): |
|
|
|
def lcn_allocated(self,LCN): |
|
|
|
self.thr.join() |
|
|
|
self.thr.join() |
|
|
|
if self.allocated_codes.has_key(LCN): |
|
|
|
if self.allocated_codes.has_key(LCN): |
|
|
|
@ -146,7 +148,7 @@ class lcl: |
|
|
|
pickle.dump( ret_dict, open( lcldir+"/cache/"+md5_hash, "wb" ) ) |
|
|
|
pickle.dump( ret_dict, open( lcldir+"/cache/"+md5_hash, "wb" ) ) |
|
|
|
pickle.dump( header, open( lcldir+"/cache/"+md5_hash+"_header", "wb" ) ) |
|
|
|
pickle.dump( header, open( lcldir+"/cache/"+md5_hash+"_header", "wb" ) ) |
|
|
|
#print("pickle_end\t"+str(time.time()-self.start)) |
|
|
|
#print("pickle_end\t"+str(time.time()-self.start)) |
|
|
|
return ret_dict |
|
|
|
return ret_dict |
|
|
|
def dat_to_dict(self,lcldir,filename,encoding,id_col_name): |
|
|
|
def dat_to_dict(self,lcldir,filename,encoding,id_col_name): |
|
|
|
#print("datbegin\t"+str(time.time()-self.start)) |
|
|
|
#print("datbegin\t"+str(time.time()-self.start)) |
|
|
|
csv_reader = csv.reader(open(lcldir+filename), delimiter=';', quotechar='"') |
|
|
|
csv_reader = csv.reader(open(lcldir+filename), delimiter=';', quotechar='"') |
|
|
|
@ -160,6 +162,27 @@ class lcl: |
|
|
|
ret_dict[id_num]=linedict |
|
|
|
ret_dict[id_num]=linedict |
|
|
|
#print("datend\t"+str(time.time()-self.start)) |
|
|
|
#print("datend\t"+str(time.time()-self.start)) |
|
|
|
return ret_dict |
|
|
|
return ret_dict |
|
|
|
|
|
|
|
def subtypesDat_to_dict(self,lcldir,filename,encoding): |
|
|
|
|
|
|
|
#print("datbegin\t"+str(time.time()-self.start)) |
|
|
|
|
|
|
|
csv_reader = csv.reader(open(lcldir+filename), delimiter=';', quotechar='"') |
|
|
|
|
|
|
|
header=csv_reader.next() |
|
|
|
|
|
|
|
ret_dict={} |
|
|
|
|
|
|
|
for row in csv_reader: |
|
|
|
|
|
|
|
# decode ISO 8859-15 back to Unicode, cell by cell: #TODO read encoding from README.DAT |
|
|
|
|
|
|
|
unirow=[unicode(cell, encoding) for cell in row] |
|
|
|
|
|
|
|
linedict=dict(zip(header,unirow)) |
|
|
|
|
|
|
|
index_tuple=(linedict["CLASS"],linedict["TCD"],linedict["STCD"]) |
|
|
|
|
|
|
|
ret_dict[index_tuple]=linedict |
|
|
|
|
|
|
|
#print("datend\t"+str(time.time()-self.start)) |
|
|
|
|
|
|
|
return ret_dict |
|
|
|
|
|
|
|
def get_loctype_name(self,index_tuple): |
|
|
|
|
|
|
|
name="" |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
name=self.subtypes[index_tuple]["SNATDESC"] |
|
|
|
|
|
|
|
except KeyError: |
|
|
|
|
|
|
|
name="" |
|
|
|
|
|
|
|
return name |
|
|
|
|
|
|
|
|
|
|
|
class tmc_event: |
|
|
|
class tmc_event: |
|
|
|
def __init__(self,ecn,tableobj): |
|
|
|
def __init__(self,ecn,tableobj): |
|
|
|
self.tableobj=tableobj |
|
|
|
self.tableobj=tableobj |
|
|
|
@ -380,14 +403,19 @@ class tmc_location: |
|
|
|
self.has_koord=False |
|
|
|
self.has_koord=False |
|
|
|
self.linRef=None |
|
|
|
self.linRef=None |
|
|
|
self.loctype=None |
|
|
|
self.loctype=None |
|
|
|
|
|
|
|
self.loctype_str="" |
|
|
|
|
|
|
|
self.loctype_name="" |
|
|
|
if self.lcl_obj.lcn_allocated(lcn): |
|
|
|
if self.lcl_obj.lcn_allocated(lcn): |
|
|
|
if self.lcl_obj.points.has_key(lcn): |
|
|
|
if self.lcl_obj.points.has_key(lcn): |
|
|
|
self.loctype="point" |
|
|
|
self.loctype="point"#point |
|
|
|
try: |
|
|
|
try: |
|
|
|
self.point=self.lcl_obj.get_point(lcn) |
|
|
|
self.point=self.lcl_obj.get_point(lcn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.ltype=self.point.CLASS+self.point.TCD |
|
|
|
self.ltype=self.point.CLASS+self.point.TCD |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.loctype_name=self.lcl_obj.get_loctype_name((self.point.CLASS,self.point.TCD,self.point.STCD)) |
|
|
|
|
|
|
|
self.loctype_str=str(self.point.CLASS+self.point.TCD+","+self.point.STCD) |
|
|
|
try: |
|
|
|
try: |
|
|
|
self.subtype=int(self.point.STCD) |
|
|
|
self.subtype=int(self.point.STCD) |
|
|
|
except ValueError:#should not happen, all rows have int |
|
|
|
except ValueError:#should not happen, all rows have int |
|
|
|
@ -796,7 +824,7 @@ class tmc_message: |
|
|
|
def log_string(self): |
|
|
|
def log_string(self): |
|
|
|
retstr="" |
|
|
|
retstr="" |
|
|
|
try: |
|
|
|
try: |
|
|
|
retstr=str(self.event.updateClass)+": "+self.getTime()+": "+self.location_text()+": "+self.events_string()+"; "+self.info_str()+"; "+str(list(self.psns))+"x%i"%self.confirmations |
|
|
|
retstr=str(self.event.updateClass)+": "+self.getTime()+": "+self.location.loctype_str+": "+self.location.loctype_name.encode('utf-8')+": "+self.location_text()+": "+self.events_string()+"; "+self.info_str()+"; "+str(list(self.psns))+"x%i"%self.confirmations |
|
|
|
except UnicodeDecodeError as e: |
|
|
|
except UnicodeDecodeError as e: |
|
|
|
print e |
|
|
|
print e |
|
|
|
code.interact(local=locals()) |
|
|
|
code.interact(local=locals()) |
|
|
|
|