]> git.openstreetmap.org Git - rails.git/blob - app/models/tracepoint.rb
8797028221ce32d01b7e0b3ef202fb5b2b007af5
[rails.git] / app / models / tracepoint.rb
1 class Tracepoint < ActiveRecord::Base
2   include GeoRecord
3
4   self.table_name = "gps_points"
5
6   validates_numericality_of :trackid, :only_integer => true
7   validates_numericality_of :latitude, :only_integer => true
8   validates_numericality_of :longitude, :only_integer => true
9   validates_associated :trace
10   validates_presence_of :timestamp
11
12   belongs_to :trace, :foreign_key => 'gpx_id'
13
14   def to_xml_node(print_timestamp = false)
15     el1 = XML::Node.new 'trkpt'
16     el1['lat'] = lat.to_s
17     el1['lon'] = lon.to_s
18     el1 << (XML::Node.new("time") << timestamp.xmlschema) if print_timestamp
19     el1
20   end
21 end