aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/access_points.js.coffee10
-rw-r--r--app/assets/javascripts/stop_areas.js.coffee10
-rw-r--r--app/maps/access_point_map.rb4
-rw-r--r--app/maps/stop_area_map.rb4
-rw-r--r--app/models/referential.rb111
-rw-r--r--app/views/access_points/_form.html.erb4
-rw-r--r--app/views/access_points/show.html.erb14
-rw-r--r--app/views/api/kml/stop_areas/_stop_area.kml.erb6
-rw-r--r--app/views/api/v1/access_points/show.rabl2
-rw-r--r--app/views/api/v1/stop_areas/show.rabl2
-rw-r--r--app/views/stop_areas/_form.html.erb4
-rw-r--r--app/views/stop_areas/show.html.erb14
12 files changed, 128 insertions, 57 deletions
diff --git a/app/assets/javascripts/access_points.js.coffee b/app/assets/javascripts/access_points.js.coffee
index 74c5e926f..5cff80b7c 100644
--- a/app/assets/javascripts/access_points.js.coffee
+++ b/app/assets/javascripts/access_points.js.coffee
@@ -3,8 +3,8 @@ jQuery ->
if referential_projection != undefined
referential_point = new OpenLayers.Geometry.Point($('input#access_point_longitude').val(), $('input#access_point_latitude').val()).transform(new OpenLayers.Projection("EPSG:4326"), referential_projection )
- $('input#access_point_x').val(referential_point.x)
- $('input#access_point_y').val(referential_point.y)
+ $('input#access_point_projection_x').val(referential_point.x)
+ $('input#access_point_projection_y').val(referential_point.y)
feature = map.getLayersByName("access_point")[0].getFeatureByFid($('input#access_point_id').val())
google_point = new OpenLayers.LonLat($('input#access_point_longitude').val(), $('input#access_point_latitude').val()).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())
@@ -16,7 +16,7 @@ jQuery ->
lon_lat_change = (event) ->
if referential_projection != undefined
- wgs84_point = new OpenLayers.Geometry.Point($('input#access_point_x').val(), $('input#access_point_y').val()).transform(referential_projection, new OpenLayers.Projection("EPSG:4326"))
+ wgs84_point = new OpenLayers.Geometry.Point($('input#access_point_projection_x').val(), $('input#access_point_projection_y').val()).transform(referential_projection, new OpenLayers.Projection("EPSG:4326"))
$('input#access_point_longitude').val( wgs84_point.x)
$('input#access_point_latitude').val( wgs84_point.y)
@@ -26,8 +26,8 @@ jQuery ->
feature.move(google_point)
map.setCenter(google_point, 16, false, true)
- $('input#access_point_x').change(lon_lat_change)
- $('input#access_point_y').change(lon_lat_change)
+ $('input#access_point_projection_x').change(lon_lat_change)
+ $('input#access_point_projection_y').change(lon_lat_change)
# switch visibility of access_links
diff --git a/app/assets/javascripts/stop_areas.js.coffee b/app/assets/javascripts/stop_areas.js.coffee
index aae8d4885..255c4c707 100644
--- a/app/assets/javascripts/stop_areas.js.coffee
+++ b/app/assets/javascripts/stop_areas.js.coffee
@@ -3,8 +3,8 @@ jQuery ->
if referential_projection != undefined
referential_point = new OpenLayers.Geometry.Point($('input#stop_area_longitude').val(), $('input#stop_area_latitude').val()).transform(new OpenLayers.Projection("EPSG:4326"), referential_projection )
- $('input#stop_area_x').val(referential_point.x)
- $('input#stop_area_y').val(referential_point.y)
+ $('input#stop_area_projection_x').val(referential_point.x)
+ $('input#stop_area_projection_y').val(referential_point.y)
feature = map.getLayersByName("stop_area")[0].getFeatureByFid($('input#stop_area_id').val())
google_point = new OpenLayers.LonLat($('input#stop_area_longitude').val(), $('input#stop_area_latitude').val()).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject())
@@ -16,7 +16,7 @@ jQuery ->
lon_lat_change = (event) ->
if referential_projection != undefined
- wgs84_point = new OpenLayers.Geometry.Point($('input#stop_area_x').val(), $('input#stop_area_y').val()).transform(referential_projection, new OpenLayers.Projection("EPSG:4326"))
+ wgs84_point = new OpenLayers.Geometry.Point($('input#stop_area_projection_x').val(), $('input#stop_area_projection_y').val()).transform(referential_projection, new OpenLayers.Projection("EPSG:4326"))
$('input#stop_area_longitude').val( wgs84_point.x)
$('input#stop_area_latitude').val( wgs84_point.y)
@@ -26,8 +26,8 @@ jQuery ->
feature.move(google_point)
map.setCenter(google_point, 16, false, true)
- $('input#stop_area_x').change(lon_lat_change)
- $('input#stop_area_y').change(lon_lat_change)
+ $('input#stop_area_projection_x').change(lon_lat_change)
+ $('input#stop_area_projection_y').change(lon_lat_change)
# switch visibility of access_links
switch_generics = (event) ->
diff --git a/app/maps/access_point_map.rb b/app/maps/access_point_map.rb
index bf763e6c6..8cacdc8c0 100644
--- a/app/maps/access_point_map.rb
+++ b/app/maps/access_point_map.rb
@@ -36,8 +36,8 @@ class AccessPointMap < ApplicationMap
if(referential_projection != undefined)
{
projection_geometry = event.feature.geometry.clone().transform(new OpenLayers.Projection("EPSG:900913"), referential_projection );
- $('#access_point_x').val(projection_geometry.x);
- $('#access_point_y').val(projection_geometry.y); }
+ $('#access_point_projection_x').val(projection_geometry.x);
+ $('#access_point_projection_y').val(projection_geometry.y); }
}
});
EOF
diff --git a/app/maps/stop_area_map.rb b/app/maps/stop_area_map.rb
index ab254bf73..b2e04779a 100644
--- a/app/maps/stop_area_map.rb
+++ b/app/maps/stop_area_map.rb
@@ -40,8 +40,8 @@ class StopAreaMap < ApplicationMap
if(referential_projection != undefined)
{
projection_geometry = event.feature.geometry.clone().transform(new OpenLayers.Projection("EPSG:900913"), referential_projection );
- $('#stop_area_x').val(projection_geometry.x);
- $('#stop_area_y').val(projection_geometry.y); }
+ $('#stop_area_projection_x').val(projection_geometry.x);
+ $('#stop_area_projection_y').val(projection_geometry.y); }
}
});
EOF
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 2e49e844b..608b0c8fc 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -192,6 +192,9 @@ Rails.application.config.after_initialize do
Chouette::StopArea
class Chouette::StopArea
+
+ attr_accessible :projection_x,:projection_y
+
# 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
@@ -206,24 +209,59 @@ Rails.application.config.after_initialize do
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
+# 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
+ end
+
+ def projection
+ if self.referential.projection_type.nil? || self.referential.projection_type.empty?
+ nil
else
- self.projection_type = nil
- self.x = nil
- self.y = nil
+ self.referential.projection_type
end
end
+ @point = nil
+
+ def projection_x
+ if self.long_lat_type.nil? || self.projection.nil?
+ nil
+ else
+ @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
+
+ @point.x
+ end
+ end
+ def projection_y
+ if self.long_lat_type.nil? || self.projection.nil?
+ nil
+ else
+ @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
+ @point.y
+ end
+ end
+ def projection_x=(dummy)
+ # dummy method
+ end
+ def projection_y=(dummy)
+ # dummy method
+ end
+
end
Chouette::AccessPoint
class Chouette::AccessPoint
-
+ attr_accessible :projection_x,:projection_y
+
# add projection_type set on pre-insert and pre_update action
before_validation :set_projections
def set_projections
@@ -232,18 +270,51 @@ Rails.application.config.after_initialize do
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
+# 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
+ end
+
+ def projection
+ if self.referential.projection_type.nil? || self.referential.projection_type.empty?
+ nil
else
- self.projection_type = nil
- self.x = nil
- self.y = nil
+ self.referential.projection_type
end
end
- end
+ @point = nil
+ def projection_x
+ if self.long_lat_type.nil? || self.projection.nil?
+ nil
+ else
+ @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
+
+ @point.x
+ end
+ end
+ def projection_y
+ if self.long_lat_type.nil? || self.projection.nil?
+ nil
+ else
+ @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
+ @point.y
+ end
+ end
+ def projection_x=(dummy)
+ # dummy method
+ end
+ def projection_y=(dummy)
+ # dummy method
+ end
+ end
+
end
diff --git a/app/views/access_points/_form.html.erb b/app/views/access_points/_form.html.erb
index cd728f0d6..8e546a878 100644
--- a/app/views/access_points/_form.html.erb
+++ b/app/views/access_points/_form.html.erb
@@ -26,8 +26,8 @@
<%= form.inputs :name => t('access_points.show.geographic_data') do %>
<% if ! @referential.projection_type_label.empty? %>
<%= form.inputs :name => @referential.projection_type_label do %>
- <%= form.input :x %>
- <%= form.input :y %>
+ <%= form.input :projection_x %>
+ <%= form.input :projection_y %>
<% end %>
<% end %>
<%= form.inputs :name => "WGS84" do %>
diff --git a/app/views/access_points/show.html.erb b/app/views/access_points/show.html.erb
index 6361e2115..7f34ed0e0 100644
--- a/app/views/access_points/show.html.erb
+++ b/app/views/access_points/show.html.erb
@@ -56,18 +56,18 @@
<% if @access_point.projection_type == nil && @access_point.long_lat_type == nil %>
<span class='geo_data'><%= t('access_points.show.no_geographic_data') %></span>
<% else %>
- <% if !@access_point.projection_type.nil? %>
+ <% if !@access_point.projection.nil? %>
<p>
- <span class='geo_data'><%= @access_point.human_attribute_name("projection_type") %>: </span>
- <%= @access_point.projection_type %>
+ <span class='geo_data'><%= @access_point.human_attribute_name("projection") %>: </span>
+ <%= @access_point.projection %>
</p>
<p>
- <span class='geo_data'><%= @access_point.human_attribute_name("x") %>: </span>
- <%= @access_point.x %>
+ <span class='geo_data'><%= @access_point.human_attribute_name("projection_x") %>: </span>
+ <%= @access_point.projection_x %>
</p>
<p>
- <span class='geo_data'><%= @access_point.human_attribute_name("y") %>: </span>
- <%= @access_point.y %>
+ <span class='geo_data'><%= @access_point.human_attribute_name("projection_y") %>: </span>
+ <%= @access_point.projection_y %>
</p>
<% end %>
<% if !@access_point.long_lat_type.nil? %>
diff --git a/app/views/api/kml/stop_areas/_stop_area.kml.erb b/app/views/api/kml/stop_areas/_stop_area.kml.erb
index 1383fbf66..401bff052 100644
--- a/app/views/api/kml/stop_areas/_stop_area.kml.erb
+++ b/app/views/api/kml/stop_areas/_stop_area.kml.erb
@@ -11,9 +11,9 @@
<longitude><%= stop_area.longitude.to_s.html_safe %></longitude>
<latitude><%= stop_area.latitude.to_s.html_safe %></latitude>
<long_lat_type><%= stop_area.long_lat_type.to_s.html_safe %></long_lat_type>
- <x><%= stop_area.x.to_s.html_safe %></x>
- <y><%= stop_area.y.to_s.html_safe %></y>
- <projection_type><%= stop_area.projection_type.to_s.html_safe %></projection_type>
+ <x><%= stop_area.projection_x.to_s.html_safe %></x>
+ <y><%= stop_area.projection_y.to_s.html_safe %></y>
+ <projection_type><%= stop_area.projection.to_s.html_safe %></projection_type>
<country_code><%= stop_area.country_code.to_s.html_safe %></country_code>
<street_name><%= stop_area.street_name.to_s.html_safe %></street_name>
diff --git a/app/views/api/v1/access_points/show.rabl b/app/views/api/v1/access_points/show.rabl
index 07daffb44..1d413fb7c 100644
--- a/app/views/api/v1/access_points/show.rabl
+++ b/app/views/api/v1/access_points/show.rabl
@@ -2,7 +2,7 @@ object @access_point
extends "api/v1/trident_objects/show"
[ :longitude, :latitude, :long_lat_type, :street_name, :country_code,
- :x , :y , :projection_type, :name, :access_type,
+ :projection_x , :projection_y , :projection, :name, :access_type,
:openning_time, :closing_time,
:mobility_restricted_suitability, :stairs_availability, :lift_availability, :comment].each do |attr|
attributes attr, :unless => lambda { |m| m.send( attr).nil?}
diff --git a/app/views/api/v1/stop_areas/show.rabl b/app/views/api/v1/stop_areas/show.rabl
index 976d96342..1a0acecc5 100644
--- a/app/views/api/v1/stop_areas/show.rabl
+++ b/app/views/api/v1/stop_areas/show.rabl
@@ -3,7 +3,7 @@ extends "api/v1/trident_objects/show"
[ :name, :area_type,:nearest_topic_name, :fare_code, :registration_number,
:longitude, :latitude, :long_lat_type,
- :country_code, :street_name, :x, :y, :projection_type, :comment
+ :country_code, :street_name, :projection_x, :projection_y, :projection, :comment
].each do |attr|
attributes attr, :unless => lambda { |m| m.send( attr).nil?}
end
diff --git a/app/views/stop_areas/_form.html.erb b/app/views/stop_areas/_form.html.erb
index 5fca012f3..e649070ab 100644
--- a/app/views/stop_areas/_form.html.erb
+++ b/app/views/stop_areas/_form.html.erb
@@ -15,8 +15,8 @@
<%= form.inputs :name => t('stop_areas.show.geographic_data') do %>
<% if ! @referential.projection_type_label.empty? %>
<%= form.inputs :name => @referential.projection_type_label do %>
- <%= form.input :x %>
- <%= form.input :y %>
+ <%= form.input :projection_x %>
+ <%= form.input :projection_y %>
<% end %>
<% end %>
<%= form.inputs :name => "WGS84" do %>
diff --git a/app/views/stop_areas/show.html.erb b/app/views/stop_areas/show.html.erb
index 9d0db8af8..b98378d71 100644
--- a/app/views/stop_areas/show.html.erb
+++ b/app/views/stop_areas/show.html.erb
@@ -42,18 +42,18 @@
<% 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.nil? %>
<p>
- <span class='geo_data'><%= @stop_area.human_attribute_name("projection_type") %>: </span>
- <%= @stop_area.projection_type %>
+ <span class='geo_data'><%= @stop_area.human_attribute_name("projection") %>: </span>
+ <%= @stop_area.projection %>
</p>
<p>
- <span class='geo_data'><%= @stop_area.human_attribute_name("x") %>: </span>
- <%= @stop_area.x %>
+ <span class='geo_data'><%= @stop_area.human_attribute_name("projection_x") %>: </span>
+ <%= @stop_area.projection_x %>
</p>
<p>
- <span class='geo_data'><%= @stop_area.human_attribute_name("y") %>: </span>
- <%= @stop_area.y %>
+ <span class='geo_data'><%= @stop_area.human_attribute_name("projection_y") %>: </span>
+ <%= @stop_area.projection_y %>
</p>
<% end %>
<% if !@stop_area.long_lat_type.nil? %>