Skip to content

Commit

Permalink
Merge pull request #27 from 306-san/feature/23
Browse files Browse the repository at this point in the history
Feature/#23 駅すぱあとのリンクを追加
  • Loading branch information
306-san authored May 29, 2018
2 parents 80be61a + f8011d3 commit ff0ade5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/controllers/onestrokes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def show
@onestrokes = []
@transfer_stations_array = []
@stations_array = []
@ekixpert_url_array = []
has_passed_through_via_station = false
p params[:first_end_station]
p params[:first_end_station]
Expand All @@ -16,6 +17,7 @@ def show
transfer_stations = []
transfer_route_names = []
stations = []
ekixpert_urls = []
has_passed_through_via_station = false
transfer_station_ids=OnestrokeStation.where(onestroke_id: onestroke_id).group(:station_id).having("count(station_id) >= ?", 2).count.keys
transfer_lines = OnestrokeLine.where(id: OnestrokeStation.where(onestroke_id: onestroke_id).where(station_id: transfer_station_ids).ids.sort)
Expand Down Expand Up @@ -47,10 +49,22 @@ def show
OnestrokeStation.where(onestroke_id: onestroke_id).sort.each do |onestroke_station|
stations << onestroke_station.station.get_latlng
end
# https://api.ekispert.jp/v1/json/search/course/light?key=LE_mz7vyp6na6S2U&from=東京&to=取手&via=仙台&plane=false
body=open(URI.encode("https://api.ekispert.jp/v1/json/search/course/light?key=#{ENV['EKISPERT_API']}&from=#{params[:first_end_station]}&to=#{params[:via_station]}&plane=false&bus=false"))
if body.status[0] == "200"
return_json_data = JSON.parse(body.read)
ekixpert_urls << return_json_data['ResultSet']['ResourceURI']
end
body=open(URI.encode("https://api.ekispert.jp/v1/json/search/course/light?key=#{ENV['EKISPERT_API']}&from=#{params[:via_station]}&to=#{params[:first_end_station]}&via=#{transfer_stations.last(2)[0].name}&plane=false&bus=false"))
if body.status[0] == "200"
return_json_data = JSON.parse(body.read)
ekixpert_urls << return_json_data['ResultSet']['ResourceURI']
end
@stations_array << stations
transfer_stations << transfer_lines.last.line.stations.first
@onestrokes << transfer_stations
@transfer_stations_array << transfer_route_names
@storoke_ids = onestroke_ids
@ekixpert_url_array << ekixpert_urls
end
end
6 changes: 6 additions & 0 deletions app/views/onestrokes/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ head
.ui.stackable.two.column.grid
.column
.ui.embed id="map#{i}"
| ここにGoogleMapが入る予定
= onestroke[2]
.
= link_to "行きの経路(駅すぱあとのリンクへ飛びます)", @ekixpert_url_array[i-1][0]
.
= link_to "帰りの経路(駅すぱあとのリンクへ飛びます)", @ekixpert_url_array[i-1][1]
javascript:
initialize("map#{i}","#{i}")
.column
Expand Down

0 comments on commit ff0ade5

Please sign in to comment.