Browse Source

added decoding of areas and roads

dev
Clemens Richter 9 years ago
parent
commit
251d56c226
  1. 1
      .gitignore
  2. 57
      python/tmc_classes.py

1
.gitignore vendored

@ -5,3 +5,4 @@ apps/*.py
apps/*.pyc
build-manlap
*.bak
directory_writable

57
python/tmc_classes.py

@ -194,6 +194,29 @@ class tmc_event:
return("invalid event, ecn:%i"%self.ecn)
def __repr__(self):
return "ecn:%i"%self.ecn
class tmc_area:
def __init__(self,lcn,tableobj):
self.lcn=lcn
self.tableobj=tableobj
self.lcl_obj=tableobj.lcl_obj
self.name=""
self.is_valid=False
if self.lcl_obj.lcn_allocated(lcn):
if self.lcl_obj.areas.has_key(lcn):
loc_dict=self.lcl_obj.areas[lcn]
self.ltype=loc_dict[u'CLASS']+loc_dict[u'TCD']
try:
self.subtype=int(loc_dict[u'STCD'])
except ValueError:#should not happen, all rows have int
self.subtype=0
print("location subtype %s is invalid in location %i"%(loc_dict[u'STCD'],lcn))
loc_dict=self.lcl_obj.areas[lcn]
self.roadnumber=loc_dict['ROADNUMBER']
if not loc_dict['NID']==u"":
self.name=self.lcl_obj.get_name(int(loc_dict['NID']))
self.is_valid=True
elif self.tableobj.log or self.tableobj.debug:
print("lcn not allocated %i"%lcn)
class tmc_segment:
def __init__(self,lcn,tableobj):
self.lcn=lcn
@ -203,18 +226,28 @@ class tmc_segment:
self.roadname=""
self.first_name=""
self.second_name=""
self.is_valid=False
if self.lcl_obj.lcn_allocated(lcn):
try:
self.loc_dict=self.lcl_obj.get_segment(lcn)
self.roadnumber=self.loc_dict['ROADNUMBER']
if not self.loc_dict['RNID']==u"":
self.roadname=self.lcl_obj.get_name(int(self.loc_dict['RNID']))
if not self.loc_dict['N1ID']==u"":
self.first_name=self.lcl_obj.get_name(int(self.loc_dict['N1ID']))
if not self.loc_dict['N2ID']==u"":
self.second_name=self.lcl_obj.get_name(int(self.loc_dict['N2ID']))
except KeyError:
print("segment '%i' not found"%lcn)
loc_dict=None
if self.lcl_obj.segments.has_key(lcn):
loc_dict=self.lcl_obj.segments[lcn]
elif self.lcl_obj.roads.has_key(lcn):
loc_dict=self.lcl_obj.roads[lcn]
if not loc_dict==None:
self.ltype=loc_dict[u'CLASS']+loc_dict[u'TCD']
try:
self.subtype=int(loc_dict[u'STCD'])
except ValueError:#should not happen, all rows have int
self.subtype=0
print("location subtype %s is invalid in location %i"%(loc_dict[u'STCD'],lcn))
self.roadnumber=loc_dict['ROADNUMBER']
if not loc_dict['RNID']==u"":
self.roadname=self.lcl_obj.get_name(int(loc_dict['RNID']))
if not loc_dict['N1ID']==u"":
self.first_name=self.lcl_obj.get_name(int(loc_dict['N1ID']))
if not loc_dict['N2ID']==u"":
self.second_name=self.lcl_obj.get_name(int(loc_dict['N2ID']))
self.is_valid=True
elif self.tableobj.log or self.tableobj.debug:
print("lcn not allocated %i"%lcn)
class tmc_location:
@ -282,7 +315,7 @@ class tmc_location:
self.has_koord=False
self.is_valid=True
if not self.loc_dict['POL_LCD']=="":#Europe (lcn==34196) does not have an area reference
self.aref=tmc_location(int(self.loc_dict['POL_LCD']),tableobj)
self.aref=tmc_area(int(self.loc_dict['POL_LCD']),tableobj)
except KeyError:
print("point '%i' not found"%lcn)
elif self.tableobj.log or self.tableobj.debug:

Loading…
Cancel
Save