diff options
| -rw-r--r-- | app/models/referential.rb | 27 | ||||
| -rw-r--r-- | config/locales/referentials.yml | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb index 88e472ca7..c78658b2a 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -147,13 +147,40 @@ class Referential < ActiveRecord::Base end Rails.application.config.after_initialize do + Chouette::ActiveRecord class Chouette::ActiveRecord + # add referential relationship for objectid and localization functions def referential @referential ||= Referential.where(:slug => Apartment::Database.current_database).first! end end + + Chouette::StopArea + + class Chouette::StopArea + # override default_position method to add referential envelope when no stoparea is positioned + def default_position + # for first StopArea ... the bounds is nil , set to referential center + Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center + end + + # add projection_type set on pre-insert and pre_update action + 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' + 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 diff --git a/config/locales/referentials.yml b/config/locales/referentials.yml index 281b0f131..5fb5cf3bb 100644 --- a/config/locales/referentials.yml +++ b/config/locales/referentials.yml @@ -24,6 +24,9 @@ en: slug: pg_excluded: "code can't begins with pg_" public_excluded: "public is reserved value" + attributes: + name: + taken: duplicate name models: referential: zero: Data space @@ -89,6 +92,9 @@ fr: slug: pg_excluded: "code ne peut commencer par pg_" public_excluded: "public est une valeur réservée" + attributes: + name: + taken: "déjà utilisé pour un autre référentiel" models: referential: zero: Espace de Données |
