Sha256: 188a19aeca25ddf58b82d5780f2ece6cce5139a3b26cf718ef6a67d7ba32d81c

Contents?: true

Size: 476 Bytes

Versions: 5

Compression:

Stored size: 476 Bytes

Contents

module GTFS
  class Realtime
    module Nearby
      def nearby(latitude, longitude)
        # TODO: this math is terrible! It'll fail for various edge cases.
        # (e.g. close to the poles, overlapping to the prime meridian)
        # That said, it's an okay approximation within the United States.

        all.select do |stop|
          (stop.latitude - latitude).abs < 0.01 &&
            (stop.longitude - longitude).abs < 0.01
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gtfs-realtime-0.2.3 lib/gtfs/realtime/nearby.rb
gtfs-realtime-0.2.2 lib/gtfs/realtime/nearby.rb
gtfs-realtime-0.2.1 lib/gtfs/realtime/nearby.rb
gtfs-realtime-0.2.0 lib/gtfs/realtime/nearby.rb
gtfs-realtime-0.1.0 lib/gtfs/realtime/nearby.rb