Class: SnowNasa::Earthimg

Inherits:
Object
  • Object
show all
Includes:
SnowNasa
Defined in:
lib/SnowNasa/earthimg.rb

Constant Summary

Constants included from SnowNasa

VERSION

Instance Attribute Summary

Attributes included from SnowNasa

#nasa_api_key

Class Method Summary collapse

Methods included from SnowNasa

get_nasa_api_key, nasa_api_key

Class Method Details

.getEarthImages(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/SnowNasa/earthimg.rb', line 5

def self.getEarthImages(options = {})
  lat = options[:lat]
  lon = options[:lon]
  dim = options[:dim]
  date = (options[:date].to_date).strftime("%Y-%m-%d")
  cloud_score = options[:cloud_score]
  if cloud_score.nil?
    base_url = "https://api.nasa.gov/planetary/earth/imagery?lon=#{lon}&lat=#{lat}&date=#{date}&api_key=#{@@nasa_api_key}"
  else
    base_url = "https://api.nasa.gov/planetary/earth/imagery?lon=#{lon}&lat=#{lat}&date=#{date}&cloud_score=True&api_key=#{@@nasa_api_key}"
  end
  data = open(base_url).read
  JSON.parse(data)
end