diff options
| -rw-r--r-- | app/models/referential.rb | 37 | ||||
| -rw-r--r-- | app/views/stop_areas/_form.html.erb | 14 | ||||
| -rw-r--r-- | app/views/stop_areas/show.html.erb | 4 |
3 files changed, 40 insertions, 15 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 diff --git a/app/views/stop_areas/_form.html.erb b/app/views/stop_areas/_form.html.erb index 237b98134..a3b17c4b3 100644 --- a/app/views/stop_areas/_form.html.erb +++ b/app/views/stop_areas/_form.html.erb @@ -12,10 +12,16 @@ <%= form.input :comment %> <%= form.input :objectid, :input_html => { :disabled => !@stop_area.new_record? } %> <%= form.inputs :name => t('stop_areas.show.geographic_data') do %> - <%= form.input :x %> - <%= form.input :y %> - <%= form.input :longitude %> - <%= form.input :latitude %> + <% if ! @referential.projection_type_label.empty? %> + <%= form.inputs :name => @referential.projection_type_label do %> + <%= form.input :x %> + <%= form.input :y %> + <% end %> + <% end %> + <%= form.inputs :name => "WGS84" do %> + <%= form.input :longitude %> + <%= form.input :latitude %> + <% end %> <% end %> <% end %> diff --git a/app/views/stop_areas/show.html.erb b/app/views/stop_areas/show.html.erb index 5f4bdb0d1..bbaa418cf 100644 --- a/app/views/stop_areas/show.html.erb +++ b/app/views/stop_areas/show.html.erb @@ -39,7 +39,7 @@ <% if @stop_area.projection_type == nil && @stop_area.long_lat_type == nil %> <span class='geo_data'><%= t('stop_areas.show.no_geographic_data') %></span> <% else %> - <% if @stop_area.projection_type != nil %> + <% if !@stop_area.projection_type.nil? %> <p> <span class='geo_data'><%= @stop_area.human_attribute_name("projection_type") %>: </span> <%= @stop_area.projection_type %> @@ -53,7 +53,7 @@ <%= @stop_area.y %> </p> <% end %> - <% if @stop_area.long_lat_type != nil %> + <% if !@stop_area.long_lat_type.nil? %> <p> <span class='geo_data'><%= @stop_area.human_attribute_name("long_lat_type") %>: </span> <%= @stop_area.long_lat_type %> |
