Sha256: 24be7f0e7955c6bc7ea2dff01aa37473ea5e102d0cb5be2d07447ef05c6f9ef0

Contents?: true

Size: 1.35 KB

Versions: 35

Compression:

Stored size: 1.35 KB

Contents

class Flickr::Photos::Geo < Flickr::Base

  def initialize(flickr)
    @flickr = flickr
  end

  # Get the geo data (latitude and longitude and the accuracy level) of a photo.
  #
  # Params
  # * photo_id (Required)
  #
  # Returns Flickr::Photos::Location object containing photo location
  # or nil if photo is not geotagged.
  def get_location(photo_id)
    # begin
    rsp = @flickr.send_request('flickr.photos.geo.getLocation', {:photo_id => photo_id})
    Flickr::Photos::Location.new(:latitude => rsp.photo.location[:latitude].to_f,
      :longitude => rsp.photo.location[:longitude].to_f, :accuracy => rsp.photo.location[:accuracy].to_i)
  end

  # Sets the geo data(latitude and longitude and the accuracy level) of a photo.
  #
  # Params
  # * photo_id (Required)
  # * latittude (Requried)
  # * longitude (Required)
  # * accuracy (Optional)
  #
  # Returns true if successful, raises an error otherwise.
  def set_location(photo_id, lat, lon, accuracy = nil)
    request_options = {:photo_id => photo_id, :lat => lat, :lon => lon}
    request_options[:accuracy] = accuracy if !accuracy.nil?
    @flickr.send_request('flickr.photos.geo.setLocation', request_options, :post)
    true
  end

  def remove_location(photo_id)
    request_options = {:photo_id => photo_id}
    @flickr.send_request('flickr.photos.geo.removeLocation', request_options, :post)
    true
  end
end

Version data entries

35 entries across 35 versions & 11 rubygems

Version Path
fotonauts-flickr_fu-0.3.2 lib/flickr/geo.rb
flickr_fu-0.3.1 lib/flickr/geo.rb
tomk32-flickr_fu-0.3.4.1 lib/flickr/geo.rb
userharmony-flickr_fu-0.3.6 lib/flickr/geo.rb
tomk32-flickr_fu-0.3.3 lib/flickr/geo.rb
tomk32-flickr_fu-0.3.2 lib/flickr/geo.rb
tomk32-flickr_fu-0.3.1 lib/flickr/geo.rb
robsharp-flickr_fu-0.3.0 lib/flickr/geo.rb
mrpunkin-flickr_fu-0.3.0 lib/flickr/geo.rb
flickr_fu-0.3.0 lib/flickr/geo.rb
tomk32-flickr_fu-0.3.0 lib/flickr/geo.rb
rmm5t-flickr_fu-0.3.5 lib/flickr/geo.rb
rmm5t-flickr_fu-0.3.4 lib/flickr/geo.rb
rmm5t-flickr_fu-0.3.3 lib/flickr/geo.rb
rmm5t-flickr_fu-0.3.2 lib/flickr/geo.rb