diff options
| -rw-r--r-- | Gemfile.lock | 92 | ||||
| -rw-r--r-- | app/assets/stylesheets/common.css.scss | 7 | ||||
| -rw-r--r-- | app/assets/stylesheets/lines.css.scss | 1 | ||||
| -rw-r--r-- | app/models/referential.rb | 65 | ||||
| -rw-r--r-- | app/views/referentials/_form.erb | 18 | ||||
| -rw-r--r-- | config/initializers/apartment.rb | 2 | ||||
| -rw-r--r-- | config/locales/referentials.yml | 2 | ||||
| -rw-r--r-- | db/migrate/20120615102714_add_the_geom_to_referential.rb | 7 | ||||
| -rw-r--r-- | db/schema.rb | 28 |
9 files changed, 135 insertions, 87 deletions
diff --git a/Gemfile.lock b/Gemfile.lock index 255b14eb8..0f62f8ecc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,14 +30,14 @@ GIT GIT remote: git://github.com/dryade/ffi-proj4.git - revision: b3d868126f939030912dcf048c9fe1b54a2ad761 + revision: 7ae89176e8ddc1c2175192ecbff0e9cffbedcb99 specs: ffi-proj4 (0.0.1) ffi (~> 1.0.0) GIT remote: git://github.com/dryade/georuby-ext.git - revision: 809e03122b9e7d6881f7132b90b90720eaaab766 + revision: be03b9d2e43f970eb368ab52c19b9dbfc68cc540 specs: georuby-ext (0.0.1) activesupport @@ -45,7 +45,7 @@ GIT geokit georuby json_pure - rgeo (~> 0.3.13) + rgeo (~> 0.3.8) GIT remote: git://github.com/dryade/ninoxe.git @@ -61,7 +61,7 @@ GIT GIT remote: git://github.com/dryade/user-interface.git - revision: 6931e642037ffef9d3818669a5f5167a0298b30b + revision: 6e4654e6805091cb8b485e36730176af3dc4e581 specs: user_interface (0.0.1) rails (> 3.1.0) @@ -70,7 +70,6 @@ GEM remote: http://rubygems.org/ specs: GeoRuby (1.3.4) - RedCloth (4.2.9) RedCloth (4.2.9-java) SyslogLogger (1.4.1) actionmailer (3.2.6) @@ -106,7 +105,6 @@ GEM acts_as_list (0.1.6) addressable (2.2.8) arel (3.0.2) - bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1-java) bouncy-castle-java (1.5.0146.1) builder (3.0.0) @@ -125,8 +123,8 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.3.2) - ffi (~> 1.0.6) + childprocess (0.3.4) + ffi (~> 1.0, >= 1.0.6) cocoon (1.0.22) coffee-rails (3.2.2) coffee-script (>= 2.2.0) @@ -142,11 +140,11 @@ GEM delayed_job_active_record (0.3.2) activerecord (> 2.1.0) delayed_job (~> 3.0.0) - devise (2.1.0) + devise (2.1.2) bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.0.7) + orm_adapter (~> 0.1) railties (~> 3.1) - warden (~> 1.1.1) + warden (~> 1.2.1) diff-lcs (1.1.3) erubis (2.7.0) execjs (1.4.0) @@ -156,7 +154,6 @@ GEM factory_girl_rails (1.7.0) factory_girl (~> 2.6.0) railties (>= 3.0.0) - ffi (1.0.11) ffi (1.0.11-java) ffi-geos (0.0.4) ffi (~> 1.0.0) @@ -165,13 +162,13 @@ GEM geokit (1.6.5) multi_json georuby (1.9.7) - guard (1.1.1) + guard (1.2.3) listen (>= 0.4.2) thor (>= 0.14.6) - guard-rspec (1.0.1) + guard-rspec (1.2.0) guard (>= 1.1) has_scope (0.5.1) - highline (1.6.12) + highline (1.6.13) hike (1.2.1) i18n (0.6.0) inherited_resources (1.3.1) @@ -179,28 +176,24 @@ GEM responders (~> 0.6) jdbc-postgres (9.0.801) journey (1.0.4) - jquery-rails (1.0.19) - railties (~> 3.0) + jquery-rails (2.0.2) + railties (>= 3.2.0, < 5.0) thor (~> 0.14) jruby-jars (1.6.7.2) jruby-openssl (0.7.7) bouncy-castle-java (>= 1.5.0146.1) - jruby-rack (1.1.6) - jruby-rack-worker (0.3-java) - jruby-rack (>= 1.0.1) - json (1.7.3) + jruby-rack (1.1.7) + jruby-rack-worker (0.4-java) + jruby-rack (>= 1.1.1) json (1.7.3-java) json_pure (1.7.3) - launchy (2.1.0) - addressable (~> 2.2.6) launchy (2.1.0-java) addressable (~> 2.2.6) ffi (~> 1.0.9) spoon (~> 0.0.1) - libv8 (3.3.10.4) - libwebsocket (0.1.3) + libwebsocket (0.1.4) addressable - listen (0.4.5) + listen (0.4.7) rb-fchange (~> 0.0.5) rb-fsevent (~> 0.9.1) rb-inotify (~> 0.8.8) @@ -219,10 +212,8 @@ GEM net-ssh (2.5.2) net-ssh-gateway (1.1.0) net-ssh (>= 1.99.1) - nokogiri (1.5.4) - nokogiri (1.5.4-java) - orm_adapter (0.0.7) - pg (0.11.0) + nokogiri (1.5.5-java) + orm_adapter (0.4.0) polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) @@ -269,48 +260,44 @@ GEM remarkable (~> 4.0.0.alpha4) remarkable_activemodel (~> 4.0.0.alpha4) rspec (>= 2.0.0.alpha11) - responders (0.9.1) + responders (0.9.2) railties (~> 3.1) - rgeo (0.3.13) - rspec (2.10.0) - rspec-core (~> 2.10.0) - rspec-expectations (~> 2.10.0) - rspec-mocks (~> 2.10.0) - rspec-core (2.10.1) - rspec-expectations (2.10.0) + rgeo (0.3.14) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.1) diff-lcs (~> 1.1.3) - rspec-mocks (2.10.1) - rspec-rails (2.10.1) + rspec-mocks (2.11.1) + rspec-rails (2.11.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.10.0) - rubyzip (0.9.8) + rspec (~> 2.11.0) + rubyzip (0.9.9) sass (3.1.20) sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - selenium-webdriver (2.22.2) + selenium-webdriver (2.25.0) childprocess (>= 0.2.5) - ffi (~> 1.0) libwebsocket (~> 0.1.3) multi_json (~> 1.0) rubyzip - shoulda-matchers (1.1.0) + shoulda-matchers (1.2.0) activesupport (>= 3.0.0) spoon (0.0.1) sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) - squeel (1.0.5) + squeel (1.0.7) activerecord (~> 3.0) activesupport (~> 3.0) polyamorous (~> 0.5.0) - therubyracer (0.10.1) - libv8 (~> 3.3.10) therubyrhino (1.73.4) thor (0.15.4) tilt (1.3.3) @@ -318,15 +305,15 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.33) - uglifier (1.2.4) + uglifier (1.2.6) execjs (>= 0.3.0) - multi_json (>= 1.0.2) + multi_json (~> 1.3) warbler (1.3.5) jruby-jars (>= 1.4.0) jruby-rack (>= 1.0.0) rake (>= 0.8.7) rubyzip (>= 0.9.4) - warden (1.1.1) + warden (1.2.1) rack (>= 1.0) will_paginate (3.0.3) xpath (0.1.4) @@ -334,7 +321,6 @@ GEM PLATFORMS java - ruby DEPENDENCIES RedCloth diff --git a/app/assets/stylesheets/common.css.scss b/app/assets/stylesheets/common.css.scss index b6d91a318..94da51a76 100644 --- a/app/assets/stylesheets/common.css.scss +++ b/app/assets/stylesheets/common.css.scss @@ -1,5 +1,10 @@ @mixin div_for_object { - margin-bottom: 20px; + margin-bottom: 10px; + background-color: #DEFFA8; + padding-top: 10px; + padding-bottom: 10px; + margin-right: 10px; + padding-left: 10px; .color { width: 64px; diff --git a/app/assets/stylesheets/lines.css.scss b/app/assets/stylesheets/lines.css.scss index f2009c141..160c87c6b 100644 --- a/app/assets/stylesheets/lines.css.scss +++ b/app/assets/stylesheets/lines.css.scss @@ -27,6 +27,7 @@ position: relative; .color { + background-color: white; width: 64px; height: 64px; float: left; diff --git a/app/models/referential.rb b/app/models/referential.rb index fd418a9ab..758e3f9eb 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -1,26 +1,25 @@ # -*- coding: utf-8 -*- class Referential < ActiveRecord::Base - validates_presence_of :name validates_presence_of :slug validates_presence_of :prefix validates_presence_of :time_zone + validates_presence_of :upper_corner + validates_presence_of :lower_corner validates_uniqueness_of :slug 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} + + attr_accessor :resources + attr_accessor :upper_corner + attr_accessor :lower_corner has_many :imports, :dependent => :destroy has_many :exports, :dependent => :destroy - after_initialize :init_time_zone - - def init_time_zone - if time_zone.nil? - self.time_zone = "Paris" - end - end - def human_attribute_name(*args) self.class.human_attribute_name(*args) end @@ -57,6 +56,7 @@ 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 @@ -71,30 +71,55 @@ class Referential < ActiveRecord::Base [ "NTF Lambert Zone 2 (27562)", 27562 ], [ "NTF Lambert Zone 3 (27563)", 27563 ], [ "NTF Lambert Zone 4 (27564)", 27564 ], - [ "NTF Lambert 2 étendu (27572)", 27582 ], - ["RGF 93 Lambert 93 (2154)", 2154 ] + [ "NTF Lambert 1 (27571)", 27571 ], + [ "NTF Lambert 2 étendu (27572)", 27572 ], + [ "NTF Lambert 3 (27573)", 27573 ], + [ "NTF Lambert 4 (27574)", 27574 ], + [ "RGF 93 Lambert 93 (2154)", 2154 ] ] end before_create :create_schema - before_destroy :destroy_schema - - after_create :import_resources + def create_schema + Apartment::Database.create slug + end - attr_accessor :resources + before_destroy :destroy_schema + def destroy_schema + Apartment::Database.drop slug + end + after_create :import_resources def import_resources imports.create(:resources => resources) if resources end - def create_schema - Apartment::Database.create slug + 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 destroy_schema - Apartment::Database.drop slug + def upper_corner + "#{envelope.upper_corner.x}, #{envelope.upper_corner.y}" end - + + def upper_corner=(upper_corner) + @upper_corner = GeoRuby::SimpleFeatures::Point.from_coordinates( upper_corner.split(",") ) + end + + def lower_corner + "#{envelope.lower_corner.x}, #{envelope.lower_corner.y}" + end + + def lower_corner=(lower_corner) + @lower_corner = GeoRuby::SimpleFeatures::Point.from_coordinates( lower_corner.split(",") ) + end + + def envelope + GeoRuby::SimpleFeatures::Geometry.from_ewkt(read_attribute(:bounds)).envelope + end + end Rails.application.config.after_initialize do diff --git a/app/views/referentials/_form.erb b/app/views/referentials/_form.erb index f9beb480e..5b59ad5f8 100644 --- a/app/views/referentials/_form.erb +++ b/app/views/referentials/_form.erb @@ -11,15 +11,17 @@ <% end %> <%= form.input :prefix %> <%= form.input :projection_type, :as => :select, :collection => Referential.available_srids %> - <%= form.input :time_zone %> + <%= form.input :time_zone %> + <%= form.input :upper_corner %> + <%= form.input :lower_corner %> <% if @referential.new_record? %> - <%= form.input :resources, :as => :file %> + <%= form.input :resources, :as => :file %> <% end %> - <% end %> + <% end %> - <%= form.actions do %> - <%= form.action :submit, :as => :button %> - <%= form.action :cancel, :as => :link %> - <% end %> -<% end %> + <%= form.actions do %> + <%= form.action :submit, :as => :button %> + <%= form.action :cancel, :as => :link %> + <% end %> +<% end %>
\ No newline at end of file diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb index 4d9b11b3c..7d1e93622 100644 --- a/config/initializers/apartment.rb +++ b/config/initializers/apartment.rb @@ -3,5 +3,5 @@ Apartment.configure do |config| config.excluded_models = ["Referential", "User", "Import", "ImportLogMessage", "Export", "ExportLogMessage", "Delayed::Backend::ActiveRecord::Job"] # these models will not be multi-tenanted, but remain in the global (public) namespace # Dynamically get database names to migrate - config.database_names = lambda{ Referential.select(:slug).map(&:slug) } + config.database_names = lambda{ Referential.pluck(:slug) } end diff --git a/config/locales/referentials.yml b/config/locales/referentials.yml index 0d6327c6b..b5e882d3a 100644 --- a/config/locales/referentials.yml +++ b/config/locales/referentials.yml @@ -78,6 +78,8 @@ fr: prefix: Préfixe des identifiants Neptune projection_type: Système de référence spatiale optionnel (SRID) time_zone: Fuseau horaire + upper_corner: Point haut/droite emprise par défaut + lower_corner: Point bas/gauche emprise par défaut validity_period: Période de validité no_validity_period: non définie start_validity_period: du diff --git a/db/migrate/20120615102714_add_the_geom_to_referential.rb b/db/migrate/20120615102714_add_the_geom_to_referential.rb new file mode 100644 index 000000000..01dd74c88 --- /dev/null +++ b/db/migrate/20120615102714_add_the_geom_to_referential.rb @@ -0,0 +1,7 @@ +class AddTheGeomToReferential < ActiveRecord::Migration + + change_table :referentials do |t| + t.string :bounds + end + +end diff --git a/db/schema.rb b/db/schema.rb index 93b26a89f..944588d55 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -182,8 +182,8 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.string "arguments", :limit => 1000 t.integer "position" t.string "severity" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "file_validation_log_messages", ["file_validation_id"], :name => "index_file_validation_log_messages_on_file_validation_id" @@ -193,8 +193,18 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.string "options", :limit => 2000 t.string "file_name" t.string "file_type" - t.datetime "created_at" - t.datetime "updated_at" + 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 end create_table "group_of_lines", :force => true do |t| @@ -321,6 +331,8 @@ ActiveRecord::Schema.define(:version => 20120620081755) do t.string "prefix" t.string "projection_type" t.string "time_zone" + t.string "the_geom" + t.string "bounds" end create_table "routes", :force => true do |t| @@ -345,6 +357,14 @@ 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 + create_table "stop_areas", :force => true do |t| t.integer "parent_id", :limit => 8 t.string "objectid", :null => false |
