Class: Flickr::Photos::Geo

Inherits:
Base show all
Defined in:
lib/flickr/geo.rb

Constant Summary

Constants inherited from Base

Base::AUTH_ENDPOINT, Base::REST_ENDPOINT, Base::UPLOAD_ENDPOINT

Instance Attribute Summary

Attributes inherited from Base

#api_key, #api_secret, #token, #token_cache

Instance Method Summary collapse

Methods inherited from Base

#auth, #contacts, #people, #photos, #photosets, #send_request, #sign_request, #test, #uploader, #urls

Constructor Details

#initialize(flickr) ⇒ Geo

Returns a new instance of Geo.



3
4
5
# File 'lib/flickr/geo.rb', line 3

def initialize(flickr)
  @flickr = flickr
end

Instance Method Details

#get_location(photo_id) ⇒ Object

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.



14
15
16
17
18
19
# File 'lib/flickr/geo.rb', line 14

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

#remove_location(photo_id) ⇒ Object



37
38
39
40
41
# File 'lib/flickr/geo.rb', line 37

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

#set_location(photo_id, lat, lon, accuracy = nil) ⇒ Object

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.



30
31
32
33
34
35
# File 'lib/flickr/geo.rb', line 30

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