Module: PanoramioRb

Defined in:
lib/panoramio-rb.rb,
lib/panoramio-rb/version.rb

Constant Summary collapse

URL =
'http://www.panoramio.com/map/get_panoramas.php'
DEFAULT_OPTIONS =
{
  :set => :public,  # Cant be :public, :full, or a USER ID number
  :size => :medium, # Cant be :original, :medium (default value), :small, :thumbnail, :square, :mini_square
  :from => 0,
  :to => 20,
  :mapfilter => true
}
VERSION =
"1.1.2"

Class Method Summary collapse

Class Method Details

.get_panoramas(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/panoramio-rb.rb', line 18

def self.get_panoramas(options = {})
  panoramio_options = DEFAULT_OPTIONS
  panoramio_options = panoramio_options.merge(options)
  response = RestClient.get URL, :params => panoramio_options
  if response.code == 200
    parse_data = JSON.parse(response.to_str)
    Hashie::Mash.new(parse_data)
  else
    raise "Panoramio API error: #{response.code}. Response #{response.to_str}"
  end
end

.get_panoramas_from_point(point, radius = 10, unit = :mi, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/panoramio-rb.rb', line 30

def self.get_panoramas_from_point(point, radius = 10, unit = :mi, options = {})
  points = Geocoder::Calculations.bounding_box(point, radius, { :units => unit })
  options.merge!({
    :miny => points[0],
    :minx => points[1],
    :maxy => points[2],
    :maxx => points[3] 
  })
  self.get_panoramas(options)
end