-# The node model represents a current existing node, that is, the latest version. Use OldNode for historical nodes.
-
-class Node < GeoRecord
+class Node < ActiveRecord::Base
require 'xml/libxml'
+ include GeoRecord
+
set_table_name 'current_nodes'
validates_presence_of :user_id, :timestamp
has_many :way_nodes
has_many :ways, :through => :way_nodes
- has_many :containing_relation_members, :as => :member
- has_many :containing_relations, :through => :containing_relation_members
+ has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
+ has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
# Sanity check the latitude and longitude and add an error if it's broken
def validate_position
-class OldNode < GeoRecord
+class OldNode < ActiveRecord::Base
+ include GeoRecord
+
set_table_name 'nodes'
validates_presence_of :user_id, :timestamp
has_many :relation_members, :foreign_key => 'id'
has_many :relation_tags, :foreign_key => 'id'
- has_many :containing_relation_members, :as => :member
- has_many :containing_relations, :through => :containing_relation_members
+ has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
+ has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
def self.from_xml(xml, create=false)
begin
-class Tracepoint < GeoRecord
+class Tracepoint < ActiveRecord::Base
+ include GeoRecord
+
set_table_name 'gps_points'
validates_numericality_of :trackid, :only_integer => true
-class GeoRecord < ActiveRecord::Base
- before_save :update_tile
+module GeoRecord
+ def before_save
+ self.update_tile
+ end
# Is this node within -90 >= latitude >= 90 and -180 >= longitude >= 180
# * returns true/false