various gpx rails things
This commit is contained in:
parent
a7e3b58b41
commit
6559db51df
4 changed files with 24 additions and 16 deletions
|
@ -47,5 +47,4 @@ class TraceController < ApplicationController
|
|||
trace = Trace.find(params[:id])
|
||||
send_data(trace.icon_picture, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') if trace.public
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ class Trace < ActiveRecord::Base
|
|||
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|
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
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>
|
||||
|
|
|
@ -33,7 +33,16 @@ while($running) do
|
|||
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']
|
||||
|
@ -49,7 +58,9 @@ while($running) do
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue