def listconnections(self, wpid,wplat,wplon): # Return list of connecting airway legs connect = [] # Check from-list first if wpid in self.awfromwpid: idx = findall(self.awfromwpid,wpid) for i in idx: newitem = [self.awid[i],self.awtowpid[i]] if (newitem not in connect) and \ geo.kwikdist(self.awfromlat[i],self.awfromlon[i], wplat,wplon) < 10.: connect.append(newitem) # Check to-list nextt if wpid in self.awtowpid: idx = findall(self.awtowpid,wpid) for i in idx: newitem = [self.awid[i],self.awfromwpid[i]] if (newitem not in connect) and \ geo.kwikdist(self.awtolat[i],self.awtolon[i], wplat,wplon) < 10.: connect.append(newitem) return connect # return list of [awid,wpid]
def listconnections(self, wpid, wplat, wplon): # Return list of connecting airway legs connect = [] # Check from-list first if wpid in self.awfromwpid: idx = findall(self.awfromwpid, wpid) for i in idx: newitem = [self.awid[i], self.awtowpid[i]] if (newitem not in connect) and \ geo.kwikdist(self.awfromlat[i],self.awfromlon[i], wplat,wplon) < 10.: connect.append(newitem) # Check to-list nextt if wpid in self.awtowpid: idx = findall(self.awtowpid, wpid) for i in idx: newitem = [self.awid[i], self.awfromwpid[i]] if (newitem not in connect) and \ geo.kwikdist(self.awtolat[i],self.awtolon[i], wplat,wplon) < 10.: connect.append(newitem) return connect # return list of [awid,wpid]
def getwpindices(self, txt, reflat=999999., reflon=999999, crit=1852.0): """Get waypoint index to access data""" name = txt.upper() try: i = self.wpid.index(name) except: return [-1] # if no pos is specified, get first occurence if not reflat < 99999.: return [i] # If pos is specified check for more and return closest else: idx = findall(self.wpid, name) # find indices of al occurences if len(idx) == 1: return [idx[0]] else: imin = idx[0] dmin = geo.kwikdist(reflat, reflon, self.wplat[imin], self.wplon[imin]) for i in idx[1:]: d = geo.kwikdist(reflat, reflon, self.wplat[i], self.wplon[i]) if d < dmin: imin = i dmin = d # Find co-located indices = [imin] for i in idx: if i != imin: dist = nm*geo.kwikdist(self.wplat[i], self.wplon[i], \ self.wplat[imin], self.wplon[imin]) if dist <= crit: indices.append(i) return indices
def getwpindices(self, txt, reflat=999999., reflon=999999,crit=1852.0): """Get waypoint index to access data""" name = txt.upper() try: i = self.wpid.index(name) except: return [-1] # if no pos is specified, get first occurence if not reflat < 99999.: return [i] # If pos is specified check for more and return closest else: idx = findall(self.wpid,name) # find indices of al occurences if len(idx) == 1: return [idx[0]] else: imin = idx[0] dmin = geo.kwikdist(reflat, reflon, self.wplat[imin], self.wplon[imin]) for i in idx[1:]: d = geo.kwikdist(reflat, reflon, self.wplat[i], self.wplon[i]) if d < dmin: imin = i dmin = d # Find co-located indices = [imin] for i in idx: if i!=imin: dist = nm*geo.kwikdist(self.wplat[i], self.wplon[i], \ self.wplat[imin], self.wplon[imin]) if dist<=crit: indices.append(i) return indices
def listairway(self, airwayid): awkey = airwayid.upper() airway = [] # identifier of waypoint 0 .. N-1 # Does this airway exist? if self.awid.count(awkey)>0: # Collect leg indices i = 0 found = True legs = [] # Alle leg incl. duplicate legs left = [] # wps in left column in file right = [] # wps in right coumn in file idx = findall(self.awid,awkey) for i in idx: newleg = self.awfromwpid[i]+"-"+self.awtowpid[i] if newleg not in legs: legs.append(newleg) left.append(self.awfromwpid[i]) right.append(self.awtowpid[i]) # Not found: return if len(legs)==0: return [] # Count wps to see when we have all segments unused = len(left)+len(right) while unused>0 and not left==len(left)*[""]: # Find start of a segment wps = left+right iwps = 0 while iwps<len(wps) and wps.count(wps[iwps])>1: iwps = iwps + 1 i = iwps%len(left) j = int(iwps/len(left)) # Catch single lost wps if j>1 or iwps>len(wps): break # Sort wps = [left,right] segment = [] segready = False while not segready: # Get leg curwp = wps[j][i] nextwp = wps[1-j][i] # Update admin of to do wplist unused = unused - 2 wps[j][i] = "" wps[1-j][i] = "" # Add first wp to segment segment.append(curwp) # Find next lef with nextwp if wps[0].count(nextwp)>0: j = 0 i = wps[0].index(nextwp) found = True elif wps[1].count(nextwp)>0: i = wps[1].index(nextwp) j = 1 found = True else: found = False # This segemnt done? segready = (not found) or curwp=="" or nextwp=="" # Also add final nextwp of this segment segment.append(nextwp) # Airway cab have multiple separate segments airway.append(segment) # Ready for next segment left = wps[0] right = wps[1] return airway #,connect
def listairway(self, airwayid): awkey = airwayid.upper() airway = [] # identifier of waypoint 0 .. N-1 # Does this airway exist? if self.awid.count(awkey) > 0: # Collect leg indices i = 0 found = True legs = [] # Alle leg incl. duplicate legs left = [] # wps in left column in file right = [] # wps in right coumn in file idx = findall(self.awid, awkey) for i in idx: newleg = self.awfromwpid[i] + "-" + self.awtowpid[i] if newleg not in legs: legs.append(newleg) left.append(self.awfromwpid[i]) right.append(self.awtowpid[i]) # Not found: return if len(legs) == 0: return [] # Count wps to see when we have all segments unused = len(left) + len(right) while unused > 0 and not left == len(left) * [""]: # Find start of a segment wps = left + right iwps = 0 while iwps < len(wps) and wps.count(wps[iwps]) > 1: iwps = iwps + 1 i = iwps % len(left) j = int(iwps / len(left)) # Catch single lost wps if j > 1 or iwps > len(wps): break # Sort wps = [left, right] segment = [] segready = False while not segready: # Get leg curwp = wps[j][i] nextwp = wps[1 - j][i] # Update admin of to do wplist unused = unused - 2 wps[j][i] = "" wps[1 - j][i] = "" # Add first wp to segment segment.append(curwp) # Find next lef with nextwp if wps[0].count(nextwp) > 0: j = 0 i = wps[0].index(nextwp) found = True elif wps[1].count(nextwp) > 0: i = wps[1].index(nextwp) j = 1 found = True else: found = False # This segemnt done? segready = (not found) or curwp == "" or nextwp == "" # Also add final nextwp of this segment segment.append(nextwp) # Airway cab have multiple separate segments airway.append(segment) # Ready for next segment left = wps[0] right = wps[1] return airway #,connect