trace = Trace.find(params[:id])
send_data(trace.icon_picture, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') if trace.public
end
-
end
set_table_name 'gpx_files'
belongs_to :user
- has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id'
+ has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id', :dependent => :destroy
def tagstring=(s)
self.tags = s.split().collect {|tag|
-trace <%= @trace.name %>
-<br>
-icon <img src="<%= url_for :controller => 'trace', :action => 'icon', :id => @trace.id, :user_login => @trace.user.display_name %>" border="0">
-<br>
-
-picture <img src="<%= url_for :controller => 'trace', :action => 'picture', :id => @trace.id, :user_login => @trace.user.display_name %>" border="0">
-
-<br>
-time <%= @trace.timestamp %>
-<br>
-dec <%= @trace.description %>
-
-
-
-
+<h2>Viewing trace <%= @trace.name %></h2>
+
+<img src="<%= url_for :controller => 'trace', :action => 'picture', :id => @trace.id, :user_login => @trace.user.display_name %>">
+
+<table border="0">
+ <tr><td>filename:</td><td><%= @trace.name %></td></tr>
+ <tr><td>uploaded at:</td><td><%= @trace.timestamp %></td></tr>
+ <tr><td>points:</td><td><%= @trace.size %></td></tr>
+ <tr><td>start coordinate:</td><td><%= @trace.latitude %>, <%= @trace.longitude %></td></tr>
+ <tr><td>owner:</td><td><%= link_to @trace.user.display_name, {:controller => 'trace', :action => 'by_user'} %></td></tr>
+ <tr><td>description:</td><td><%= @trace.description %></td></tr>
+ <tr><td>tags:</td><td><%= @trace.tags.collect {|tag| tag.tag} %></td></tr>
+</table>
end
gpx = OSM::GPXImporter.new("/tmp/#{trace.id}.gpx")
+ f_lat = 0
+ l_lon = 0
+ first = true
+
gpx.points do |point|
+ if first
+ f_lat = point['latitude']
+ f_lon = point['longitude']
+ end
+
tp = Tracepoint.new
tp.latitude = point['latitude']
tp.longitude = point['longitude']
min_lat = Tracepoint.minimum('latitude', :conditions => ['gpx_id = ?', trace.id])
max_lon = Tracepoint.maximum('longitude', :conditions => ['gpx_id = ?', trace.id])
min_lon = Tracepoint.minimum('longitude', :conditions => ['gpx_id = ?', trace.id])
- #logger.info("bbox: #{min_lat} #{max_lat} #{min_lon} #{max_lon}")
+
+ trace.latitude = f_lat
+ trace.longitude = f_lat
trace.large_picture = gpx.get_picture(min_lat, min_lon, max_lat, max_lon, gpx.actual_points)
trace.icon_picture = gpx.get_icon(min_lat, min_lon, max_lat, max_lon)
trace.size = gpx.actual_points