diff options
18 files changed, 111 insertions, 56 deletions
@@ -38,6 +38,7 @@ gem "modernizr-rails", "~> 2.0.6" gem "acts_as_tree", :git => "git://github.com/dryade/acts_as_tree.git" gem 'ninoxe', :git => 'git://github.com/dryade/ninoxe.git' #gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe' #, :path => '~/Projects/Ninoxe' +#gem 'ninoxe', :path => '~/workspace/chouette/ninoxe' gem 'acts_as_list', '0.1.6' #gem 'composite_primary_keys', '~> 5.0.8' diff --git a/Gemfile.lock b/Gemfile.lock index 0f62f8ecc..efaaf4112 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,7 +49,7 @@ GIT GIT remote: git://github.com/dryade/ninoxe.git - revision: 2bbf27be9a282188d31399790d7ba1951cb27a2b + revision: a676372aa170b006c3694110fe63f6d0e6ecbbdc specs: ninoxe (0.0.8) GeoRuby @@ -182,10 +182,11 @@ GEM jruby-jars (1.6.7.2) jruby-openssl (0.7.7) bouncy-castle-java (>= 1.5.0146.1) - jruby-rack (1.1.7) - jruby-rack-worker (0.4-java) - jruby-rack (>= 1.1.1) - json (1.7.3-java) + jruby-rack (1.1.6) + jruby-rack-worker (0.3-java) + jruby-rack (>= 1.0.1) + json (1.7.4) + json (1.7.4-java) json_pure (1.7.3) launchy (2.1.0-java) addressable (~> 2.2.6) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 86507b03e..69d083fe7 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -9,4 +9,5 @@ //= require jquery-ui //= require modernizr //= require cocoon -//= require_tree . +//= require_directory ./public +//= require_directory . diff --git a/app/assets/javascripts/OpenLayers.js b/app/assets/javascripts/public/OpenLayers.js index 9523007df..9523007df 100644 --- a/app/assets/javascripts/OpenLayers.js +++ b/app/assets/javascripts/public/OpenLayers.js diff --git a/app/assets/javascripts/formtastic.qtip2.min.js b/app/assets/javascripts/public/formtastic.qtip2.min.js index 2f81a7a54..2f81a7a54 100644 --- a/app/assets/javascripts/formtastic.qtip2.min.js +++ b/app/assets/javascripts/public/formtastic.qtip2.min.js diff --git a/app/assets/javascripts/jquery.qtip.min.js b/app/assets/javascripts/public/jquery.qtip.min.js index 891523841..891523841 100644 --- a/app/assets/javascripts/jquery.qtip.min.js +++ b/app/assets/javascripts/public/jquery.qtip.min.js diff --git a/app/assets/javascripts/jquery.tokeninput.js b/app/assets/javascripts/public/jquery.tokeninput.js index 87641a57a..87641a57a 100644 --- a/app/assets/javascripts/jquery.tokeninput.js +++ b/app/assets/javascripts/public/jquery.tokeninput.js diff --git a/app/assets/javascripts/jquery.ui.datepicker-i18n.js b/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js index 3d0d55b46..3d0d55b46 100644 --- a/app/assets/javascripts/jquery.ui.datepicker-i18n.js +++ b/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js diff --git a/app/assets/javascripts/proj4js-compressed.js b/app/assets/javascripts/public/proj4js-compressed.js index 3da44ad15..3da44ad15 100644 --- a/app/assets/javascripts/proj4js-compressed.js +++ b/app/assets/javascripts/public/proj4js-compressed.js diff --git a/app/assets/javascripts/public/proj4js-defs.js b/app/assets/javascripts/public/proj4js-defs.js new file mode 100644 index 000000000..fe77a033c --- /dev/null +++ b/app/assets/javascripts/public/proj4js-defs.js @@ -0,0 +1,9 @@ +Proj4js.defs["EPSG:27561"] = "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:27562"] = "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:27563"] = "+proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:27564"] = "+proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.99994471 +x_0=234.358 +y_0=185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:27571"] = "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=1200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:27572"] = "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:27573"] = "+proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.999877499 +x_0=600000 +y_0=3200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:27574"] = "+proj=lcc +lat_1=42.16500000000001 +lat_0=42.16500000000001 +lon_0=0 +k_0=0.99994471 +x_0=234.358 +y_0=4185861.369 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs" +Proj4js.defs["EPSG:2154"] = "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" diff --git a/app/assets/javascripts/stop_areas.js.coffee b/app/assets/javascripts/stop_areas.js.coffee new file mode 100644 index 000000000..a03124169 --- /dev/null +++ b/app/assets/javascripts/stop_areas.js.coffee @@ -0,0 +1,21 @@ +jQuery -> + x_y_change = (event) -> + if referential_projection != undefined + projection_geometry = 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(projection_geometry.x) + $('input#stop_area_y').val(projection_geometry.y) + + #var stop_area = map.getLayersByName("stop_area")[0].getFeatureByFid(645).set + + + $('input#stop_area_longitude').change(x_y_change) + $('input#stop_area_latitude').change(x_y_change) + + lon_lat_change = (event) -> + if referential_projection != undefined + projection_geometry = new OpenLayers.Geometry.Point($('input#stop_area_x').val(), $('input#stop_area_y').val()).transform(referential_projection, new OpenLayers.Projection("EPSG:4326")) + $('input#stop_area_longitude').val(projection_geometry.x) + $('input#stop_area_latitude').val(projection_geometry.y) + + $('input#stop_area_x').change(lon_lat_change) + $('input#stop_area_y').change(lon_lat_change) diff --git a/app/maps/network_map.rb b/app/maps/network_map.rb index 4271133bb..c1104e877 100644 --- a/app/maps/network_map.rb +++ b/app/maps/network_map.rb @@ -1,6 +1,6 @@ class NetworkMap < ApplicationMap - attr_reader :referential, :network, :network_style + attr_reader :network, :network_style def initialize(network, network_style = nil) @network = network diff --git a/app/maps/stop_area_map.rb b/app/maps/stop_area_map.rb index 0e02654e9..65c8b72fd 100644 --- a/app/maps/stop_area_map.rb +++ b/app/maps/stop_area_map.rb @@ -1,6 +1,6 @@ class StopAreaMap < ApplicationMap - attr_reader :referential, :stop_area + attr_reader :stop_area attr_accessor :editable alias_method :editable?, :editable @@ -19,15 +19,23 @@ class StopAreaMap < ApplicationMap page.assign "edit_stop_area_layer", kml_layer(stop_area, { :default => editable? }, :style_map => StyleMap::EditStopAreaStyleMap.new.style_map) page << map.add_layer(:edit_stop_area_layer) - - if editable? - # TODO virer ce code inline + + + if editable? + page.assign "referential_projection", projection_type.present? ? projection("EPSG:" + projection_type) : JsVar.new("undefined") + # TODO virer ce code inline page << <<EOF edit_stop_area_layer.events.on({ 'afterfeaturemodified': function(event) { geometry = event.feature.geometry.clone().transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326")); $('#stop_area_longitude').val(geometry.x); $('#stop_area_latitude').val(geometry.y); + + 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); } } }); EOF @@ -38,6 +46,10 @@ EOF page << map.set_center(center.to_google.to_openlayers, 16, false, true) end end + + def projection_type + stop_area.referential.projection_type + end def ready? center.present? diff --git a/app/models/referential.rb b/app/models/referential.rb index 758e3f9eb..068b1df68 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -10,8 +10,8 @@ class Referential < ActiveRecord::Base validates_uniqueness_of :name validates_format_of :slug, :with => %r{\A[0-9a-z_]+\Z} validates_format_of :prefix, :with => %r{\A[0-9a-zA-Z_]+\Z} - validates_format_of :upper_corner, :with => %r{\A[0-9]+\.?[0-9]*\, [0-9]+\.?[0-9]*\Z} - validates_format_of :lower_corner, :with => %r{\A[0-9]+\.?[0-9]*\, [0-9]+\.?[0-9]*\Z} + validates_format_of :upper_corner, :with => %r{\A-?[0-9]+\.?[0-9]*\,-?[0-9]+\.?[0-9]*\Z} + validates_format_of :lower_corner, :with => %r{\A-?[0-9]+\.?[0-9]*\,-?[0-9]+\.?[0-9]*\Z} attr_accessor :resources attr_accessor :upper_corner @@ -56,7 +56,6 @@ class Referential < ActiveRecord::Base def define_default_attributes self.time_zone ||= Time.zone.name - self.bounds ||= GeoRuby::SimpleFeatures::Envelope.from_coordinates( [ [-5.2, 42.25], [8.23, 51.1] ] ).to_polygon.as_ewkt # bounds for France by default end def switch @@ -94,30 +93,43 @@ class Referential < ActiveRecord::Base imports.create(:resources => resources) if resources end - before_save :update_envelope - before_create :update_envelope - def update_envelope - self.bounds = GeoRuby::SimpleFeatures::Envelope.from_coordinates([ [@lower_corner.x, @lower_corner.y], [ @upper_corner.x, @upper_corner.y ] ]).to_polygon.as_ewkt() - end - def upper_corner - "#{envelope.upper_corner.x}, #{envelope.upper_corner.y}" + envelope.upper_corner end def upper_corner=(upper_corner) - @upper_corner = GeoRuby::SimpleFeatures::Point.from_coordinates( upper_corner.split(",") ) + if String === upper_corner + upper_corner = (upper_corner.blank? ? nil : GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.normalize(upper_corner), 4326)) + end + + envelope.tap do |envelope| + envelope.upper_corner = upper_corner + self.bounds = envelope.to_polygon.as_ewkt + end end def lower_corner - "#{envelope.lower_corner.x}, #{envelope.lower_corner.y}" + envelope.lower_corner end def lower_corner=(lower_corner) - @lower_corner = GeoRuby::SimpleFeatures::Point.from_coordinates( lower_corner.split(",") ) + if String === lower_corner + lower_corner = (lower_corner.blank? ? nil : GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.normalize(lower_corner), 4326)) + end + + envelope.tap do |envelope| + envelope.lower_corner = lower_corner + self.bounds = envelope.to_polygon.as_ewkt + end + end + + def default_bounds + GeoRuby::SimpleFeatures::Envelope.from_coordinates( [ [-5.2, 42.25], [8.23, 51.1] ] ).to_polygon.as_ewkt end - def envelope - GeoRuby::SimpleFeatures::Geometry.from_ewkt(read_attribute(:bounds)).envelope + def envelope + bounds = read_attribute(:bounds) + GeoRuby::SimpleFeatures::Geometry.from_ewkt(bounds.present? ? bounds : default_bounds ).envelope end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 379aaba17..0b39e2b97 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -33,7 +33,7 @@ <ul class="main"> <% if help_page? || test_sheet_page? %> <li><%= link_to "Aide", help_path, :class =>("current" if help_page?) %></li> - <li><%= link_to "Tests de validation", test_sheet_path+"1.1", :class =>("current" if test_sheet_page?) %></li> + <li><%= link_to "Tests de validation", test_sheet_path+"1_1", :class =>("current" if test_sheet_page?) %></li> <% elsif ! selected_referential? %> <li><%= link_to Referential.model_name.human.capitalize.pluralize, referentials_path, :class => ("current" if current_page?(referentials_path) || current_page?(root_url)) %></li> <li><%= tab_link_to FileValidation, file_validations_path %></li> diff --git a/config/environments/development.rb b/config/environments/development.rb index f4936039b..06b340db2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -26,7 +26,7 @@ ChouetteIhm::Application.configure do config.assets.compress = false # Expands the lines which load the assets - config.assets.debug = false + config.assets.debug = true config.active_record.mass_assignment_sanitizer = :strict diff --git a/db/schema.rb b/db/schema.rb index 944588d55..9ad02e4db 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -176,14 +176,16 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.integer "choice_code" end + add_index "facilities_features", ["facility_id"], :name => "idx_facility_id" + create_table "file_validation_log_messages", :force => true do |t| t.integer "file_validation_id" t.string "key" t.string "arguments", :limit => 1000 t.integer "position" t.string "severity" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" end add_index "file_validation_log_messages", ["file_validation_id"], :name => "index_file_validation_log_messages_on_file_validation_id" @@ -193,18 +195,8 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.string "options", :limit => 2000 t.string "file_name" t.string "file_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "geometry_columns", :id => false, :force => true do |t| - t.string "f_table_catalog", :limit => 256, :null => false - t.string "f_table_schema", :limit => 256, :null => false - t.string "f_table_name", :limit => 256, :null => false - t.string "f_geometry_column", :limit => 256, :null => false - t.integer "coord_dimension", :null => false - t.integer "srid", :null => false - t.string "type", :limit => 30, :null => false + t.datetime "created_at" + t.datetime "updated_at" end create_table "group_of_lines", :force => true do |t| @@ -219,10 +211,13 @@ ActiveRecord::Schema.define(:version => 20120620081755) do add_index "group_of_lines", ["objectid"], :name => "group_of_lines_objectid_key", :unique => true create_table "group_of_lines_lines", :id => false, :force => true do |t| - t.integer "group_of_line_id", :limit => 8 - t.integer "line_id", :limit => 8 + t.integer "group_of_line_id", :limit => 8, :null => false + t.integer "line_id", :limit => 8, :null => false end + add_index "group_of_lines_lines", ["group_of_line_id"], :name => "idx_grli_gr" + add_index "group_of_lines_lines", ["line_id"], :name => "idx_grli_li" + create_table "import_log_messages", :force => true do |t| t.integer "import_id" t.string "key" @@ -264,10 +259,11 @@ ActiveRecord::Schema.define(:version => 20120620081755) do add_index "journey_patterns", ["objectid"], :name => "journey_patterns_objectid_key", :unique => true create_table "journey_patterns_stop_points", :id => false, :force => true do |t| - t.integer "journey_pattern_id", :limit => 8 - t.integer "stop_point_id", :limit => 8 + t.integer "journey_pattern_id", :limit => 8, :null => false + t.integer "stop_point_id", :limit => 8, :null => false end + add_index "journey_patterns_stop_points", ["journey_pattern_id"], :name => "idx_jpsp_jpid" add_index "journey_patterns_stop_points", ["journey_pattern_id"], :name => "index_journey_pattern_id_on_journey_patterns_stop_points" create_table "lines", :force => true do |t| @@ -285,6 +281,7 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.string "comment" t.boolean "mobility_restricted_suitability" t.integer "int_user_needs" + t.integer "ptnetwork_id", :limit => 8 end add_index "lines", ["objectid"], :name => "lines_objectid_key", :unique => true @@ -330,8 +327,8 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.datetime "updated_at" t.string "prefix" t.string "projection_type" + t.string "bounding_box", :limit => nil t.string "time_zone" - t.string "the_geom" t.string "bounds" end @@ -357,13 +354,8 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.integer "line_id", :limit => 8 end - create_table "spatial_ref_sys", :id => false, :force => true do |t| - t.integer "srid", :null => false - t.string "auth_name", :limit => 256 - t.integer "auth_srid" - t.string "srtext", :limit => 2048 - t.string "proj4text", :limit => 2048 - end + add_index "routing_constraints_lines", ["line_id"], :name => "idx_rcli_li" + add_index "routing_constraints_lines", ["stop_area_id"], :name => "idx_rcli_st" create_table "stop_areas", :force => true do |t| t.integer "parent_id", :limit => 8 @@ -451,8 +443,8 @@ ActiveRecord::Schema.define(:version => 20120620081755) do add_index "time_tables", ["objectid"], :name => "time_tables_objectid_key", :unique => true create_table "time_tables_vehicle_journeys", :id => false, :force => true do |t| - t.integer "time_table_id", :limit => 8 - t.integer "vehicle_journey_id", :limit => 8 + t.integer "time_table_id", :limit => 8, :null => false + t.integer "vehicle_journey_id", :limit => 8, :null => false end add_index "time_tables_vehicle_journeys", ["time_table_id"], :name => "index_time_tables_vehicle_journeys_on_time_table_id" @@ -486,8 +478,12 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.time "waiting_time" t.time "elapse_duration" t.time "headway_frequency" + t.integer "position", :limit => 8 + t.boolean "is_departure", :default => false + t.boolean "is_arrival", :default => false end + add_index "vehicle_journey_at_stops", ["stop_point_id"], :name => "index_vehicle_journey_at_stops_on_stop_point_id" add_index "vehicle_journey_at_stops", ["stop_point_id"], :name => "index_vehicle_journey_at_stops_on_stop_pointid" add_index "vehicle_journey_at_stops", ["vehicle_journey_id"], :name => "index_vehicle_journey_at_stops_on_vehicle_journey_id" diff --git a/spec/requests/referentials_spec.rb b/spec/requests/referentials_spec.rb index 54e63c33c..9204c76e9 100644 --- a/spec/requests/referentials_spec.rb +++ b/spec/requests/referentials_spec.rb @@ -33,6 +33,8 @@ describe "Referentials" do visit new_referential_path fill_in "Nom", :with => "Test" fill_in "Code", :with => "test" + fill_in "Point haut/droite emprise par défaut", :with => "0.0, 0.0" + fill_in "Point bas/gauche emprise par défaut", :with => "1.0, 1.0" click_button "Créer Espace de données" Referential.where(:name => "Test").should_not be_nil |
