Method: Navaid#getRunways

Defined in:
lib/navaid.rb

#getRunways(box) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/navaid.rb', line 150

def getRunways(box)
  i = @rwlatSort.bsearch_lower_boundary {|x| x[0] <=> box[1][0]}
  j = @rwlatSort.bsearch_upper_boundary {|x| x[0] <=> box[1][1]}
  latCandidates = @rwlatSort[i...j].collect do |a|
    a[1] # return its array index
  end
  # protect against excessive CPU load
  return [] if j-i > 1000

  i = @rwlonSort.bsearch_lower_boundary {|x| x[0] <=> box[0][0]}
  j = @rwlonSort.bsearch_upper_boundary {|x| x[0] <=> box[0][1]}
  lonCandidates = @rwlonSort[i...j].collect do |a|
    a[1] # return its array index
  end
  # protect against excessive CPU load
  return [] if j-i > 1000
  
  cross=latCandidates.find_all do |a|
    lonCandidates.include?(a)
  end

  cross.collect do |a|
    @runways[a]
  end
end