|
|
|
|
@ -77,7 +77,10 @@ class lcl:
|
|
|
|
|
else: |
|
|
|
|
return False |
|
|
|
|
def get_poffsets(self,LCD): |
|
|
|
|
return self.poffsets[LCD] |
|
|
|
|
if self.poffsets.has_key(LCD): |
|
|
|
|
return self.poffsets[LCD] |
|
|
|
|
else: |
|
|
|
|
return "" |
|
|
|
|
def get_segment(self,LCD): |
|
|
|
|
return self.segments[LCD] |
|
|
|
|
def get_road(self,LCD): |
|
|
|
|
@ -317,56 +320,68 @@ class tmc_location:
|
|
|
|
|
self.loc_dict={} |
|
|
|
|
self.has_koord=False |
|
|
|
|
self.linRef=None |
|
|
|
|
if self.lcl_obj.lcn_allocated(lcn) and self.lcl_obj.points.has_key(lcn): |
|
|
|
|
try: |
|
|
|
|
self.point=self.lcl_obj.get_point(lcn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.ltype=self.point.CLASS+self.point.TCD |
|
|
|
|
self.loctype=None |
|
|
|
|
if self.lcl_obj.lcn_allocated(lcn): |
|
|
|
|
if self.lcl_obj.points.has_key(lcn): |
|
|
|
|
self.loctype="point" |
|
|
|
|
try: |
|
|
|
|
self.subtype=int(self.point.STCD) |
|
|
|
|
except ValueError:#should not happen, all rows have int |
|
|
|
|
self.subtype=0 |
|
|
|
|
print("location subtype %s is invalid in location %i"%(self.point.STCD,lcn)) |
|
|
|
|
if not self.point.RNID==u"": |
|
|
|
|
self.roadname=self.lcl_obj.get_name(int(self.point.RNID)) |
|
|
|
|
else: |
|
|
|
|
self.roadname="" |
|
|
|
|
if not self.point.N1ID==u"": |
|
|
|
|
self.first_name=self.lcl_obj.get_name(int(self.point.N1ID)) |
|
|
|
|
else: |
|
|
|
|
self.first_name="" |
|
|
|
|
if not self.point.N2ID==u"": |
|
|
|
|
self.second_name=self.lcl_obj.get_name(int(self.point.N2ID)) |
|
|
|
|
else: |
|
|
|
|
self.second_name="" |
|
|
|
|
self.point=self.lcl_obj.get_point(lcn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.ltype=self.point.CLASS+self.point.TCD |
|
|
|
|
try: |
|
|
|
|
self.subtype=int(self.point.STCD) |
|
|
|
|
except ValueError:#should not happen, all rows have int |
|
|
|
|
self.subtype=0 |
|
|
|
|
print("location subtype %s is invalid in location %i"%(self.point.STCD,lcn)) |
|
|
|
|
if not self.point.RNID==u"": |
|
|
|
|
self.roadname=self.lcl_obj.get_name(int(self.point.RNID)) |
|
|
|
|
else: |
|
|
|
|
self.roadname="" |
|
|
|
|
if not self.point.N1ID==u"": |
|
|
|
|
self.first_name=self.lcl_obj.get_name(int(self.point.N1ID)) |
|
|
|
|
else: |
|
|
|
|
self.first_name="" |
|
|
|
|
if not self.point.N2ID==u"": |
|
|
|
|
self.second_name=self.lcl_obj.get_name(int(self.point.N2ID)) |
|
|
|
|
else: |
|
|
|
|
self.second_name="" |
|
|
|
|
|
|
|
|
|
if not self.point.SEG_LCD==u"": |
|
|
|
|
self.linRef=tmc_segment(int(self.point.SEG_LCD),tableobj) |
|
|
|
|
elif not self.point.ROA_LCD==u"": |
|
|
|
|
self.linRef=tmc_segment(int(self.point.ROA_LCD),tableobj) |
|
|
|
|
if not self.point.POL_LCD==u"": |
|
|
|
|
self.reflocs=self.__ref_locs(int(self.point.POL_LCD),self.first_name.encode('utf-8')) |
|
|
|
|
self.negative_offset=self.lcl_obj.get_poffsets(lcn).NEG_OFF_LCD |
|
|
|
|
self.positive_offset=self.lcl_obj.get_poffsets(lcn).POS_OFF_LCD |
|
|
|
|
try: |
|
|
|
|
#koords stored in WGS84 format with decimal degrees multiplied with 10^5 |
|
|
|
|
self.xkoord=int(self.point.XCOORD)/100000.0 |
|
|
|
|
self.ykoord=int(self.point.YCOORD)/100000.0 |
|
|
|
|
self.koord_str="%f,%f"%(self.ykoord,self.xkoord) |
|
|
|
|
self.koord_str_google="{lat: %f, lng: %f}"%(self.ykoord,self.xkoord) |
|
|
|
|
self.google_maps_link="https://www.google.de/maps/place/%f,%f"%(self.ykoord,self.xkoord) |
|
|
|
|
self.has_koord=True |
|
|
|
|
except ValueError: |
|
|
|
|
self.has_koord=False |
|
|
|
|
self.is_valid=True |
|
|
|
|
if not self.point.POL_LCD=="":#Europe (lcn==34196) does not have an area reference |
|
|
|
|
self.aref=tmc_area(int(self.point.POL_LCD),tableobj) |
|
|
|
|
except KeyError as e: |
|
|
|
|
print(e) |
|
|
|
|
print("error making point '%i'"%lcn) |
|
|
|
|
if not self.point.SEG_LCD==u"": |
|
|
|
|
self.linRef=tmc_segment(int(self.point.SEG_LCD),tableobj) |
|
|
|
|
elif not self.point.ROA_LCD==u"": |
|
|
|
|
self.linRef=tmc_segment(int(self.point.ROA_LCD),tableobj) |
|
|
|
|
if not self.point.POL_LCD==u"": |
|
|
|
|
self.reflocs=self.__ref_locs(int(self.point.POL_LCD),self.first_name.encode('utf-8')) |
|
|
|
|
self.negative_offset=self.lcl_obj.get_poffsets(lcn).NEG_OFF_LCD |
|
|
|
|
self.positive_offset=self.lcl_obj.get_poffsets(lcn).POS_OFF_LCD |
|
|
|
|
try: |
|
|
|
|
#koords stored in WGS84 format with decimal degrees multiplied with 10^5 |
|
|
|
|
self.xkoord=int(self.point.XCOORD)/100000.0 |
|
|
|
|
self.ykoord=int(self.point.YCOORD)/100000.0 |
|
|
|
|
self.koord_str="%f,%f"%(self.ykoord,self.xkoord) |
|
|
|
|
self.koord_str_google="{lat: %f, lng: %f}"%(self.ykoord,self.xkoord) |
|
|
|
|
self.google_maps_link="https://www.google.de/maps/place/%f,%f"%(self.ykoord,self.xkoord) |
|
|
|
|
self.has_koord=True |
|
|
|
|
except ValueError: |
|
|
|
|
self.has_koord=False |
|
|
|
|
self.is_valid=True |
|
|
|
|
if not self.point.POL_LCD=="":#Europe (lcn==34196) does not have an area reference |
|
|
|
|
self.aref=tmc_area(int(self.point.POL_LCD),tableobj) |
|
|
|
|
except KeyError as e: |
|
|
|
|
print(e) |
|
|
|
|
print("error making point '%i'"%lcn) |
|
|
|
|
elif self.lcl_obj.areas.has_key(lcn) and self.tableobj.debug: |
|
|
|
|
print("lcn is area %i"%lcn) |
|
|
|
|
elif self.lcl_obj.segments.has_key(lcn) and self.tableobj.debug: |
|
|
|
|
print("lcn is segment %i"%lcn) |
|
|
|
|
elif self.lcl_obj.roads.has_key(lcn) and self.tableobj.debug: |
|
|
|
|
print("lcn is road %i"%lcn) |
|
|
|
|
else: |
|
|
|
|
print("lcn not found %i"%lcn) |
|
|
|
|
|
|
|
|
|
elif self.tableobj.log or self.tableobj.debug: |
|
|
|
|
print("lcn not allocated or not point %i"%lcn) |
|
|
|
|
print("lcn not allocated %i"%lcn) |
|
|
|
|
def get_extent_location(self,loc,extent,direction): #direction: 0:pos, 1:neg |
|
|
|
|
if extent==0 or not loc.is_valid: |
|
|
|
|
return loc |
|
|
|
|
|