]> git.openstreetmap.org Git - rails.git/blob - app/models/tracepoint.rb
Get the timestamp outside the transactionso everything can see it.
[rails.git] / app / models / tracepoint.rb
1 class Tracepoint < ActiveRecord::Base
2 set_table_name 'gps_points'
3
4 #  validates_numericality_of :latitude
5 #  validates_numericality_of :longitude
6
7   belongs_to :user
8   belongs_to :trace, :foreign_key => 'gpx_id'
9
10   def lat=(l)
11     self.latitude = l * 1000000
12   end
13
14   def lng=(l)
15     self.longitude = l * 1000000
16   end
17
18   def lat
19     return self.latitude.to_f / 1000000
20   end
21
22   def lon
23     return self.longitude.to_f / 1000000
24   end
25
26   def to_xml_node
27     el1 = XML::Node.new 'trkpt'
28     el1['lat'] = self.lat.to_s
29     el1['lon'] = self.lon.to_s
30     return el1
31   end
32
33 end