Permalink
Browse files

Add a Point model and code to import/cache data, tidy up use of tidy_…

…text and include updated database schema
  • Loading branch information...
1 parent e4b661a commit 04439d90022dac366bdce500ea6f8267813bc2e8 @poggs committed May 7, 2012
View
@@ -3,4 +3,3 @@ db/*.sqlite3
log/*.log
tmp/
config/database.yml
-data/static/*
View
19 LICENCE
@@ -0,0 +1,19 @@
+This code includes additional data licenced as follows:
+
+
+Location data
+-------------
+
+Filename:
+ data/static/locations.csv
+
+Author:
+ Tom Cairns of www.railmiles.org
+
+Licence:
+ CC BY-SA 3.0
+
+Comments:
+ Tom has added latitude and longitude data for all known STANOXes. This
+ data is under continual development, and will be kept up-to-date for use
+ with TSDBExplorer.
@@ -169,16 +169,16 @@ def decode_tiploc(obj)
decoded_tiploc = nil
if obj.is_a? Tiploc
- decoded_tiploc = tidy_text((obj.tps_description.blank? || obj.tps_description.nil?) ? obj.tiploc_code : obj.tps_description)
+ decoded_tiploc = obj.tps_description
elsif (obj.is_a? Location) || (obj.is_a? DailyScheduleLocation)
decoded_tiploc = $REDIS.hget('TIPLOC:' + obj.tiploc_code, 'description')
if decoded_tiploc.nil?
logger.warn "ApplicationHelper::decode_tiploc() failed to find #{obj.tiploc_code}"
- decoded_tiploc = obj.tiploc.nil? ? obj.tiploc_code : obj.tiploc.tps_description
+ decoded_tiploc = obj.tiploc.tps_description unless obj.tiploc.nil?
end
end
- return decoded_tiploc
+ return decoded_tiploc.nil? ? obj.tiploc_code : tidy_text(decoded_tiploc)
end
@@ -437,10 +437,10 @@ def show_location_name(loc, type)
tiploc = loc.tiploc_code
else
if type == :from
- text = "<strong>" + tidy_text(decode_tiploc(loc.basic_schedule.origin)) + "</strong>"
+ text = "<strong>" + decode_tiploc(loc.basic_schedule.origin) + "</strong>"
tiploc = loc.basic_schedule.origin.tiploc_code
else
- text = "<strong>" + tidy_text(decode_tiploc(loc.basic_schedule.terminate)) + "</strong>"
+ text = "<strong>" + decode_tiploc(loc.basic_schedule.terminate) + "</strong>"
tiploc = loc.basic_schedule.terminate.tiploc_code
end
end
View
@@ -0,0 +1,26 @@
+#
+# This file is part of TSDBExplorer.
+#
+# TSDBExplorer is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# TSDBExplorer is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with TSDBExplorer. If not, see <http://www.gnu.org/licenses/>.
+#
+# $Id$
+#
+
+class Point < ActiveRecord::Base
+
+ attr_accessible :full_name, :short_name, :stanox, :stanme, :tiploc, :latitude, :longitude
+
+ validates_presence_of :full_name, :stanox, :stanme, :tiploc
+
+end
@@ -26,7 +26,7 @@
<% if advanced_mode? %>
<td><%= s.train_identity %></td>
<% end %>
- <td><%= s.origin.departure %> <%= tidy_text(decode_tiploc(s.origin)) %> to <%= tidy_text(decode_tiploc(s.terminate)) %></td>
+ <td><%= s.origin.departure %> <%= decode_tiploc(s.origin) %> to <%= decode_tiploc(s.terminate) %></td>
<% if advanced_mode? %>
<td><%= s.power_type %><%= s.speed %></td>
<% end %>
@@ -1,6 +1,6 @@
<div id="service_detail">
<div id="mode"><%= mode_icon_for(@schedule.status) %></div>
- <div id="headline"><%= time_only(@schedule.origin.public_departure) || @schedule.origin.departure %> <%= tidy_text(decode_tiploc(@schedule.origin)) %> to <%= tidy_text(decode_tiploc(@schedule.terminate)) %></div>
+ <div id="headline"><%= time_only(@schedule.origin.public_departure) || @schedule.origin.departure %> <%= decode_tiploc(@schedule.origin) %> to <%= decode_tiploc(@schedule.terminate) %></div>
<% unless @schedule.atoc_code == 'ZZ' %>
<div id="operator"><%= display_toc(@schedule.atoc_code) %></div>
<% end %>
@@ -14,7 +14,7 @@
<% if @schedule.departed_origin? %>
<p>Showing actual running data from <%= @schedule.runs_on %></p>
<% else %>
- <p>Real-time information will be available once the train has left <%= tidy_text(decode_tiploc(@schedule.origin)) %>.</p>
+ <p>Real-time information will be available once the train has left <%= decode_tiploc(@schedule.origin) %>.</p>
<% end %>
<% if @schedule.cancelled? %>
@@ -3,7 +3,7 @@
<% if advanced_mode? %>
<tr>
- <td><%= tidy_text(decode_tiploc(schedule_point)) %></td>
+ <td><%= decode_tiploc(schedule_point) %></td>
<td style="text-align: center;"><%= schedule_point.platform %></td>
<td style="text-align: center;"><%= schedule_point.arrival %></td>
<td style="text-align: center;"><%= schedule_point.public_arrival %></td>
@@ -16,7 +16,7 @@
<% elsif schedule_point.is_public? %>
<tr>
- <td><%= tidy_text(decode_tiploc(schedule_point)) %></td>
+ <td><%= decode_tiploc(schedule_point) %></td>
<td style="text-align: center;"><%= schedule_point.platform %></td>
<td style="text-align: center;"><%= schedule_point.public_arrival %></td>
<td style="text-align: center;"><%= schedule_point.public_departure %></td>
@@ -29,7 +29,7 @@
<% if advanced_mode? %>
<tr>
- <td><%= tidy_text(decode_tiploc(schedule_point)) %></td>
+ <td><%= decode_tiploc(schedule_point) %></td>
<td style="text-align: center;"><%= schedule_point.platform %></td>
<td style="text-align: center;"><%= schedule_point.actual_platform %></td>
<td style="text-align: center;"><%= time_only(schedule_point.arrival) %></td>
@@ -69,7 +69,7 @@
<% if schedule_point.is_public? %>
<tr>
- <td><%= tidy_text(decode_tiploc(schedule_point)) %></td>
+ <td><%= decode_tiploc(schedule_point) %></td>
<td style="text-align: center;"><%= schedule_point.platform %></td>
<td style="text-align: center;">
<% unless schedule_point.activity_tb == true || schedule_point.activity_u == true %>
@@ -13,7 +13,7 @@
<tbody>
<% @schedule.locations.each do |l| %>
<%= content_tag('tr', '', { :style => l.pass.nil? ? nil : 'background: #eee;' }) do %>
- <td><%= tidy_text(decode_tiploc(l)) %><% if advanced_mode? %>&nbsp;<%= raw format_activities(l) %><% end %></td>
+ <td><%= decode_tiploc(l) %><% if advanced_mode? %>&nbsp;<%= raw format_activities(l) %><% end %></td>
<td><%= l.path %></td>
<td><%= l.platform %></td>
<td><%= l.line %></td>
@@ -10,7 +10,7 @@
<% @schedule.locations.each do |l| %>
<% if l.is_public? %>
<tr>
- <td style="text-align: left;"><%= tidy_text(decode_tiploc(l)) %>&nbsp;<%= raw format_activities(l) %></td>
+ <td style="text-align: left;"><%= decode_tiploc(l) %>&nbsp;<%= raw format_activities(l) %></td>
<td><%=raw l.platform || "&nbsp;" %></td>
<td><%= l.public_arrival %></td>
<td><%= l.public_departure %></td>
@@ -4,7 +4,7 @@
<% if mode == 'schedule' %>
<%= schedule.data_source %> Schedule <%= schedule.train_uid %>
<% else %>
- <% if advanced_mode? %><span style="train_identity"><%= @schedule.train_identity %></span><% end %> <%= raw time_only(schedule.origin.public_departure) || tidy_wtt_time(schedule.origin.departure) %> <%= tidy_text(decode_tiploc(schedule.origin)) %> to <%= tidy_text(decode_tiploc(schedule.terminate)) %>
+ <% if advanced_mode? %><span style="train_identity"><%= @schedule.train_identity %></span><% end %> <%= raw time_only(schedule.origin.public_departure) || tidy_wtt_time(schedule.origin.departure) %> <%= decode_tiploc(schedule.origin) %> to <%= decode_tiploc(schedule.terminate) %>
<% end %>
</div>
<div class="subtitle"><%= display_operator(schedule.atoc_code) %></div>
@@ -2,7 +2,7 @@
<% if @as_run.departed_origin? %>
Real-time information is available for this train, and is shown below
<% else %>
- Real-time information will be shown for this train after it has departed <%= tidy_text(decode_tiploc(@as_run.origin)) %>
+ Real-time information will be shown for this train after it has departed <%= decode_tiploc(@as_run.origin) %>
<% end %>
</div>
@@ -27,7 +27,7 @@
<tbody>
<% @as_run.locations.each do |l| %>
<tr>
- <td><%= tidy_text(decode_tiploc(l)) %></td>
+ <td><%= decode_tiploc(l) %></td>
<td><%= l.platform %></td>
<td><%= l.line %></td>
<td><%= l.path %></td>
@@ -55,7 +55,7 @@
<% @as_run.locations.each do |l| %>
<% if l.is_public? %>
<tr>
- <td><%= tidy_text(decode_tiploc(l)) %></td>
+ <td><%= decode_tiploc(l) %></td>
<td style="text-align: center;"><%=raw l.platform || "&nbsp;" %></td>
<td><%= format_time(l, 'arrival', :public) %></td>
<td><%= format_time(l, 'departure', :public) %></td>
@@ -30,7 +30,7 @@
<% end %>
</td>
<td>
- <strong><%= raw format_location_time(s.origin, :departure) %> <%= tidy_text(decode_tiploc(s.origin)) %> to <%= tidy_text(decode_tiploc(s.terminate)) %></strong>
+ <strong><%= raw format_location_time(s.origin, :departure) %> <%= decode_tiploc(s.origin) %> to <%= decode_tiploc(s.terminate) %></strong>
<br />
Runs <%= run_details(s) %>
</td>
View
@@ -0,0 +1,39 @@
+#
+# This file is part of TSDBExplorer.
+#
+# TSDBExplorer is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# TSDBExplorer is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with TSDBExplorer. If not, see <http://www.gnu.org/licenses/>.
+#
+# $Id$
+#
+
+AMQP_SERVER:
+ hostname: 'moorgate.lon2.poggs.net'
+ username: 'tdnet.dev'
+ password: 'test123'
+ vhost: 'tdnet'
+
+REDIS_SERVER:
+ hostname: 'localhost'
+ port: '6379'
+
+ANALYTICS:
+ tracking_id: 'UA-28424358-1'
+ domain_name: 'opentraintimes.com'
+
+DATA:
+ path: 'import'
+
+RESTRICTIONS:
+ category: ['QQ']
+ toc: ['QQ']
Oops, something went wrong.

0 comments on commit 04439d9

Please sign in to comment.