aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/referential.rb
diff options
context:
space:
mode:
authorMichel Etienne2012-08-08 15:10:06 +0200
committerMichel Etienne2012-08-08 15:10:06 +0200
commit6af59bfcf56718a9c7d207946f0e962283857214 (patch)
treef245eb4222fcbc755832ed0a13f4bd90777015f6 /app/models/referential.rb
parent62168dbda36bf760045bbfe6499c538880172a18 (diff)
downloadchouette-core-6af59bfcf56718a9c7d207946f0e962283857214.tar.bz2
manage presence and label for second projection
Diffstat (limited to 'app/models/referential.rb')
-rw-r--r--app/models/referential.rb37
1 files changed, 28 insertions, 9 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb
index c78658b2a..a6910f66a 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -90,6 +90,15 @@ class Referential < ActiveRecord::Base
]
end
+ def projection_type_label
+ self.class.available_srids.each do |a|
+ if a.last.to_s == projection_type
+ return a.first.split('(').first.rstrip
+ end
+ end
+ projection_type || ""
+ end
+
before_create :create_schema
def create_schema
Apartment::Database.create slug
@@ -148,15 +157,19 @@ end
Rails.application.config.after_initialize do
- Chouette::ActiveRecord
+ Chouette::TridentActiveRecord
- class Chouette::ActiveRecord
+ class Chouette::TridentActiveRecord
# add referential relationship for objectid and localization functions
def referential
@referential ||= Referential.where(:slug => Apartment::Database.current_database).first!
end
+ def prefix
+ self.referential.prefix
+ end
+
end
Chouette::StopArea
@@ -172,15 +185,21 @@ Rails.application.config.after_initialize do
before_validation :set_projections
def set_projections
if ! self.latitude.nil? && ! self.longitude.nil?
- Rails.logger.info "update long_lat_type"
self.long_lat_type = 'WGS84'
+ else
+ self.long_lat_type = nil
+ end
+ if ! self.referential.projection_type.nil? && !self.referential.projection_type.empty?
+ if ! self.x.nil? && ! self.y.nil?
+ self.projection_type = referential.projection_type_label
+ else
+ self.projection_type = nil
+ end
+ else
+ self.projection_type = nil
+ self.x = nil
+ self.y = nil
end
- #if ! self.referential.projection_type.nil?
- # if ! self.x.nil? && ! self.y.nil?
- # Rails.logger.info "update projection_type"
- # self.projection_type = referential.projection_type.to_s
- # end
- #end
end
end
end