From b6ca062670b342344df08b53fb216db619ef42bc Mon Sep 17 00:00:00 2001 From: Nicolas Braud-Santoni Date: Sun, 7 Aug 2016 16:39:42 +0200 Subject: Import legacy manman source Copied from www.ffgraz.net --- app/models/location.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/models/location.rb (limited to 'app/models/location.rb') diff --git a/app/models/location.rb b/app/models/location.rb new file mode 100644 index 0000000..5171e5d --- /dev/null +++ b/app/models/location.rb @@ -0,0 +1,38 @@ +class Location < ActiveRecord::Base + set_table_name "location" + belongs_to :person + belongs_to :town + belongs_to :nets + has_many :node + + validates_presence_of :name, :person_id + validates_uniqueness_of :name + + validates_format_of :name, + :with => /^([0-9a-z]*)$/, + :on => :create + validates_format_of :name, + :with => /^([0-9a-z]*)$/, + :on => :save + + @@x_zero = 4080 + @@lon_zero = 15.43844103813 + @@dx_dlon = 50675.5176 + @@y_zero = 4806 + @@lat_zero = 47.07177327969 + @@dy_dlat = 75505.521 + + def lon + @@lon_zero + (self.pixel_x.to_f - @@x_zero) / @@dx_dlon + end + + def lat + @@lat_zero + (@@y_zero - self.pixel_y.to_f) / @@dy_dlat + end + + def comment + # nl2br + read_attribute(:comment).gsub("\n\r","
").gsub("\r", "").gsub("\n", "
") + end + +end -- cgit v1.2.1