]> git.openstreetmap.org Git - rails.git/commitdiff
various gpx rails things
authorSteve Coast <steve@asklater.com>
Wed, 6 Dec 2006 17:55:22 +0000 (17:55 +0000)
committerSteve Coast <steve@asklater.com>
Wed, 6 Dec 2006 17:55:22 +0000 (17:55 +0000)
app/controllers/trace_controller.rb
app/models/trace.rb
app/views/trace/view.rhtml
lib/daemons/gpx_import.rb

index f7f323e9c5af550a7284b7c63f6f4598a82c102e..41802a89ba113429871287732fb53c9bee248e03 100644 (file)
@@ -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
     trace = Trace.find(params[:id])
     send_data(trace.icon_picture, :filename => "#{trace.id}.gif", :type => 'image/gif', :disposition => 'inline') if trace.public
   end
-
 end
 end
index 06e3dc1a12acd20974dba790080a535bffbef2df..7c4b5de18d4580de1de4ecbe6903762e5cc33f34 100644 (file)
@@ -2,7 +2,7 @@ class Trace < ActiveRecord::Base
   set_table_name 'gpx_files'
 
   belongs_to :user
   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|
 
   def tagstring=(s)
     self.tags = s.split().collect {|tag|
index 28ef095aba52dadb23cddb27d62e0baeb8acc2b7..661f5866fb588ca3f61766c6031c2b46a4c35b57 100644 (file)
@@ -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>
index 70764dd38c8a3f9b23979f6e1ba77aec0a30573a..427edd121db40741d5f434b5078e2464dc720972 100755 (executable)
@@ -33,7 +33,16 @@ while($running) do
         end
         gpx = OSM::GPXImporter.new("/tmp/#{trace.id}.gpx")
 
         end
         gpx = OSM::GPXImporter.new("/tmp/#{trace.id}.gpx")
 
+        f_lat = 0
+        l_lon = 0
+        first = true
+
         gpx.points do |point|
         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']
           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])
           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
           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