Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ GEM
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
arel (7.1.4)
autoprefixer-rails (7.1.2.1)
autoprefixer-rails (7.1.2.2)
execjs
awesome_print (1.8.0)
better_errors (2.1.1)
Expand Down
12 changes: 7 additions & 5 deletions app/controllers/forecast_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ def coords_to_weather
# The longitude the user input is in the string @lng.
# ==========================================================================

url = "https://api.darksky.net/forecast/a52814fad0486c985720046e82a2e4fa/" + @lat + "," + @lng

parsed_data = JSON.parse(open(url).read)

@current_temperature = "Replace this string with your answer."
@current_temperature = parsed_data["currently"]["temperature"].round(2)

@current_summary = "Replace this string with your answer."
@current_summary = parsed_data["currently"]["summary"]

@summary_of_next_sixty_minutes = "Replace this string with your answer."
@summary_of_next_sixty_minutes = parsed_data["minutely"]["summary"]

@summary_of_next_several_hours = "Replace this string with your answer."
@summary_of_next_several_hours = parsed_data["hourly"]["summary"]

@summary_of_next_several_days = "Replace this string with your answer."
@summary_of_next_several_days = parsed_data["daily"]["summary"]

render("forecast/coords_to_weather.html.erb")
end
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/geocoding_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ def street_to_coords
# The street address that the user typed is in the variable @street_address.
# ==========================================================================

url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + @street_address.gsub(" ", "+")

parsed_data = JSON.parse(open(url).read)

@latitude = "Replace this string with your answer."
@latitude = parsed_data["results"][0]["geometry"]["location"]["lat"]

@longitude = "Replace this string with your answer."
@longitude = parsed_data["results"][0]["geometry"]["location"]["lng"]

render("geocoding/street_to_coords.html.erb")
end
Expand Down
34 changes: 26 additions & 8 deletions app/controllers/meteorologist_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,37 @@ def street_to_weather
#
# The street address that the user typed is in the variable @street_address.
# ==========================================================================

# Get coordinates from Google maps
#
google_maps_url = "https://maps.googleapis.com/maps/api/geocode/json?address=" + @street_address.gsub(" ", "+")

maps_results = JSON.parse(open(google_maps_url).read)

@lat = maps_results["results"][0]["geometry"]["location"]["lat"].to_s

@lng = maps_results["results"][0]["geometry"]["location"]["lng"].to_s

# Get coordinates from dark sky
#
dark_sky_url = "https://api.darksky.net/forecast/a52814fad0486c985720046e82a2e4fa/" + @lat + "," + @lng

dark_sky_results = JSON.parse(open(dark_sky_url).read)

# Return data for the page
#
@current_temperature = dark_sky_results["currently"]["temperature"].round(2)

@current_summary = dark_sky_results["currently"]["summary"]

@summary_of_next_sixty_minutes = dark_sky_results["minutely"]["summary"]

@current_temperature = "Replace this string with your answer."

@current_summary = "Replace this string with your answer."

@summary_of_next_sixty_minutes = "Replace this string with your answer."

@summary_of_next_several_hours = "Replace this string with your answer."
@summary_of_next_several_hours = dark_sky_results["hourly"]["summary"]

@summary_of_next_several_days = "Replace this string with your answer."
@summary_of_next_several_days = dark_sky_results["daily"]["summary"]

# Render the page
#
render("meteorologist/street_to_weather.html.erb")
end
end