diff options
| author | Luc Donnet | 2012-05-21 11:12:06 +0200 |
|---|---|---|
| committer | Luc Donnet | 2012-05-21 11:12:06 +0200 |
| commit | 63dbf0e73aa7e32eca6bcab41f970efdd8e441d6 (patch) | |
| tree | f02d444d19ce1d8eb7fedadb04056e17467fd7e5 | |
| parent | 41dc5c3cbcdf7cea46561b8223bd57a1bb4377cb (diff) | |
| download | chouette-core-63dbf0e73aa7e32eca6bcab41f970efdd8e441d6.tar.bz2 | |
Add ffi for georuby ext and update stop area map Refs #18 #20 #22
| -rw-r--r-- | Gemfile | 9 | ||||
| -rw-r--r-- | Gemfile.lock | 57 | ||||
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 4 | ||||
| -rw-r--r-- | app/maps/application_map.rb | 3 | ||||
| -rw-r--r-- | app/maps/connection_link_map.rb | 2 | ||||
| -rw-r--r-- | app/maps/line_map.rb | 2 | ||||
| -rw-r--r-- | app/maps/network_map.rb | 2 | ||||
| -rw-r--r-- | app/maps/stop_area_map.rb | 10 | ||||
| -rw-r--r-- | app/maps/style_map/edit_stop_area_style_map.rb | 93 | ||||
| -rw-r--r-- | app/maps/style_map/stop_areas_style_map.rb | 79 | ||||
| -rw-r--r-- | app/views/stop_areas/show.kml.erb | 2 | ||||
| -rw-r--r-- | db/schema.rb | 27 |
12 files changed, 134 insertions, 156 deletions
@@ -4,6 +4,9 @@ gem 'rails', '3.1.3' gem 'jquery-rails' gem 'devise' +gem "ffi-proj4", :git => 'git://github.com/dryade/ffi-proj4.git' + + platforms :jruby do gem 'activerecord-jdbcpostgresql-adapter', :git => 'git://github.com/dryade/activerecord-jdbc-adapter.git' gem 'activerecord-jdbcsqlite3-adapter' @@ -11,13 +14,13 @@ platforms :jruby do gem 'warbler' end -platforms :ruby do +platforms :ruby do gem 'pg', '~> 0.11.0' gem 'sqlite3' - gem 'capybara-webkit' end gem "map_layers", "~> 0.0.4" +gem "georuby-ext", :git => 'git://github.com/dryade/georuby-ext.git' gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' gem 'json' @@ -31,7 +34,7 @@ gem 'RedCloth' gem "acts_as_tree", :git => "git://github.com/dryade/acts_as_tree.git" gem 'apartment', :git => 'git://github.com/dryade/apartment.git' -gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe' #, :path => '~/Projects/Ninoxe' +gem 'ninoxe', :path => '~/projects/ninoxe' #, :git => 'git://chouette.dryade.priv/ninoxe' #, :path => '~/Projects/Ninoxe' gem 'acts_as_list', '0.1.6' gem 'composite_primary_keys', '4.1.2' diff --git a/Gemfile.lock b/Gemfile.lock index e61074d42..662e94b06 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,16 +1,4 @@ GIT - remote: git://chouette.dryade.priv/ninoxe - revision: 9deb81a3121fdf295512f875a91ba7b5d0d106a4 - specs: - ninoxe (0.0.8) - GeoRuby - activerecord (~> 3.1.3) - acts_as_list (= 0.1.6) - composite_primary_keys (= 4.1.2) - geokit - rails (= 3.1.3) - -GIT remote: git://github.com/dryade/activerecord-jdbc-adapter.git revision: 0bf424bc3bcaf9f44646976cc4c1a8e9e57f11b4 specs: @@ -34,6 +22,25 @@ GIT apartment (0.14.1) GIT + remote: git://github.com/dryade/ffi-proj4.git + revision: b3d868126f939030912dcf048c9fe1b54a2ad761 + specs: + ffi-proj4 (0.0.1) + ffi (~> 1.0.0) + +GIT + remote: git://github.com/dryade/georuby-ext.git + revision: 809e03122b9e7d6881f7132b90b90720eaaab766 + specs: + georuby-ext (0.0.1) + activesupport + ffi-geos (~> 0.0.4) + geokit + georuby + json_pure + rgeo (~> 0.3.13) + +GIT remote: git://github.com/thoughtbot/shoulda.git revision: 269edccc7df8f2eb94a96a6a6d248a5960d7fe1f specs: @@ -48,11 +55,21 @@ GIT user_interface (0.0.1) rails (~> 3.1.0) +PATH + remote: ~/projects/ninoxe + specs: + ninoxe (0.0.8) + GeoRuby + activerecord (~> 3.1.3) + acts_as_list (= 0.1.6) + composite_primary_keys (= 4.1.2) + geokit + rails (= 3.1.3) + 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.1.3) @@ -89,7 +106,6 @@ GEM acts_as_list (0.1.6) addressable (2.2.8) arel (2.2.3) - bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1-java) bouncy-castle-java (1.5.0146.1) builder (3.0.0) @@ -140,12 +156,14 @@ 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) formtastic (2.0.2) rails (~> 3.0) geokit (1.6.5) multi_json + georuby (1.9.7) guard (1.0.2) ffi (>= 0.5.0) thor (~> 0.14.6) @@ -166,10 +184,8 @@ GEM jruby-openssl (0.7.6.1) bouncy-castle-java (>= 1.5.0146.1) jruby-rack (1.1.5) - json (1.7.3) json (1.7.3-java) - launchy (2.1.0) - addressable (~> 2.2.6) + json_pure (1.7.3) launchy (2.1.0-java) addressable (~> 2.2.6) ffi (~> 1.0.9) @@ -190,7 +206,6 @@ GEM net-ssh (2.3.0) net-ssh-gateway (1.1.0) net-ssh (>= 1.99.1) - nokogiri (1.5.2) nokogiri (1.5.2-java) orm_adapter (0.0.7) polyamorous (0.5.0) @@ -238,6 +253,7 @@ GEM rspec (>= 2.0.0.alpha11) responders (0.9.1) railties (~> 3.1) + rgeo (0.3.13) rspec (2.10.0) rspec-core (~> 2.10.0) rspec-expectations (~> 2.10.0) @@ -311,7 +327,6 @@ DEPENDENCIES capistrano capistrano-ext capybara - capybara-webkit cocoon coffee-rails (~> 3.1.1) coffee-script-source @@ -320,7 +335,9 @@ DEPENDENCIES delayed_job_active_record devise factory_girl_rails (= 1.7) + ffi-proj4! formtastic (= 2.0.2) + georuby-ext! guard guard-rspec inherited_resources diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index e0d5a161c..8fc9191a1 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -32,7 +32,7 @@ class StopAreasController < ChouetteController def show @map = StopAreaMap.new referential, stop_area show! do |format| - unless stop_area.geometry + unless stop_area.position or params[:default] format.kml { render :nothing => true, :status => :not_found } @@ -42,7 +42,7 @@ class StopAreasController < ChouetteController end def edit - #stop_area.position ||= stop_area.default_position + stop_area.position ||= stop_area.default_position @map = StopAreaMap.new referential, stop_area @map.editable = true diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index ed523eebe..a4d8a84ab 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -14,8 +14,7 @@ class ApplicationMap OpenLayers::Control::ScaleLine.new, OpenLayers::Control::Navigation.new, OpenLayers::Control::PanZoomBar.new, - OpenLayers::Control::Attribution.new - ] + OpenLayers::Control::Attribution.new] end def id diff --git a/app/maps/connection_link_map.rb b/app/maps/connection_link_map.rb index fe79ce9a4..e915c3ae2 100644 --- a/app/maps/connection_link_map.rb +++ b/app/maps/connection_link_map.rb @@ -18,7 +18,7 @@ class ConnectionLinkMap < ApplicationMap page << map.add_layer(google_satellite) #page << map.add_layer(kml_layer(connection_link, :styleMap => StyleMap::ConnectionLinkStyleMap.new( :style => connection_link_style).style_map)) - page << map.add_layer(kml_layer(polymorphic_path([referential, connection_link, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new(true).style_map)) + page << map.add_layer(kml_layer(polymorphic_path([referential, connection_link, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new.style_map)) page << map.zoom_to_extent(bounds) if bounds end end diff --git a/app/maps/line_map.rb b/app/maps/line_map.rb index d0df83fed..128b98dd2 100644 --- a/app/maps/line_map.rb +++ b/app/maps/line_map.rb @@ -18,7 +18,7 @@ class LineMap < ApplicationMap page << map.add_layer(google_satellite) #page << map.add_layer(kml_layer(line, :styleMap => StyleMap::LineStyleMap.new( :style => line_style).style_map)) - page << map.add_layer(kml_layer(polymorphic_path([referential, line, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new(true).style_map)) + page << map.add_layer(kml_layer(polymorphic_path([referential, line, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new.style_map)) page << map.zoom_to_extent(bounds) if bounds end end diff --git a/app/maps/network_map.rb b/app/maps/network_map.rb index 4135322ac..cedabdf6e 100644 --- a/app/maps/network_map.rb +++ b/app/maps/network_map.rb @@ -17,7 +17,7 @@ class NetworkMap < ApplicationMap page << map.add_layer(google_satellite) #page << map.add_layer(kml_layer(network, :styleMap => StyleMap::NetworkStyleMap.new( :style => network_style).style_map)) - page << map.add_layer(kml_layer(polymorphic_path([referential, network, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new(true).style_map)) + page << map.add_layer(kml_layer(polymorphic_path([referential, network, :stop_areas], :format => :kml), :styleMap => StyleMap::StopAreasStyleMap.new.style_map)) page << map.zoom_to_extent(bounds) if bounds end end diff --git a/app/maps/stop_area_map.rb b/app/maps/stop_area_map.rb index b5a339e87..37ba77121 100644 --- a/app/maps/stop_area_map.rb +++ b/app/maps/stop_area_map.rb @@ -36,18 +36,12 @@ EOF end - page << map.zoom_to_extent(bounds) if bounds - #page << map.set_center(center.to_google.to_openlayers, 16, false, true) + page << map.set_center(center.to_google.to_openlayers, 16, false, true) end end - def bounds - wgs84_bounds = Chouette::StopArea.bounds - @bounds ||= OpenLayers::Bounds.new(wgs84_bounds.lower_corner.x, wgs84_bounds.lower_corner.y, wgs84_bounds.upper_corner.x, wgs84_bounds.upper_corner.y).transform(OpenLayers::Projection.new("EPSG:4326"), OpenLayers::Projection.new("EPSG:900913")) - end - def center - stop_area.position or stop_area.default_position + stop_area.geometry or stop_area.default_position end end diff --git a/app/maps/style_map/edit_stop_area_style_map.rb b/app/maps/style_map/edit_stop_area_style_map.rb index 7095cb2f3..263950d62 100644 --- a/app/maps/style_map/edit_stop_area_style_map.rb +++ b/app/maps/style_map/edit_stop_area_style_map.rb @@ -1,72 +1,49 @@ class StyleMap::EditStopAreaStyleMap < StyleMap::GenericStyleMap + attr_accessor :default_style, :select_style, :context - attr_accessor :styles, :display_label + @@default_style_class = { + #:label => "${label}", + :fontColor => "black", + :fontSize => "11px", + :fontWeight => "bold", + :labelAlign => "ct", + :labelXOffset => 0, + :labelYOffset => -15, + :pointRadius => 4, + :fillColor => "white", + :fillOpacity => 1, + :strokeColor => "black", + :strokeOpacity => 1, + :strokeWidth => 2 + } - def initialize(display_label = false, styles = {}) - @display_label = display_label - @styles = styles - end + @@select_style_class = { + :fontColor => "black", + :fontSize => "11px", + :fontWeight => "bold", + :pointRadius => 4, + :fillColor => "#86b41d", + :fillOpacity => 1, + :strokeColor => "black", + :strokeOpacity => 1, + :strokeWidth => 2 + } - def default_style - style = { - :label => ("${label}" if display_label), - :fontColor => "black", - :fontSize => "11px", - :fontWeight => "bold", - :labelAlign => "ct", - :labelXOffset => 0, - :labelYOffset => -15, - :pointRadius => 4, - :fillColor => "white", - :fillOpacity => 1, - :strokeColor => "black", - :strokeOpacity => 1, - :strokeWidth => 2, - :display => true - } - - if styles["default"].present? - style.merge styles["default"] - else - style - end + def initialize(options = {}) + @default_style = options[:default_style].present? ? options[:default_style].merge(@@default_style_class) : @@default_style_class + @select_style = options[:select_style].present? ? options[:select_style].merge(@@select_style_class) : @@select_style_class end - def select_style - select_style = { - :label => ("${label}" if display_label), - :fontColor => "black", - :fontSize => "11px", - :fontWeight => "bold", - :labelAlign => "ct", - :labelXOffset => 0, - :labelYOffset => -15, - :pointRadius => 4, - :fillColor => "white", - :fillOpacity => 1, - :strokeColor => "black", - :strokeOpacity => 1, - :strokeWidth => 2, - :display => true - } - - if styles["select"].present? - select_style.merge styles["select"] - else - select_style - end - end - def context - context = { - :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ", - :areaType => :" function(feature) { console.log(feature); return feature.attributes.stop_area_type.toLowerCase();} " + { + :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} " } end def style_map - OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(default_style, { :context => context}), - :select => OpenLayers::Style.new(select_style, { :context => context}) + OpenLayers::StyleMap.new( + :default => OpenLayers::Style.new(default_style, { :context => context}), + :select => OpenLayers::Style.new(select_style) ) end diff --git a/app/maps/style_map/stop_areas_style_map.rb b/app/maps/style_map/stop_areas_style_map.rb index a1aec906d..c27f1fb65 100644 --- a/app/maps/style_map/stop_areas_style_map.rb +++ b/app/maps/style_map/stop_areas_style_map.rb @@ -1,74 +1,37 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap + attr_accessor :default_style, :context - attr_accessor :styles, :display_label + @@default_style_class = { + :label => "${label}", + :fontColor => "black", + :fontSize => "11px", + :fontWeight => "bold", + :labelAlign => "ct", + :labelXOffset => 0, + :labelYOffset => -40, + :pointRadius => 1, + :externalGraphic => "/assets/map/${areaType}.png", + :graphicWidth => 25, + :graphicHeight => 25, + :graphicOpacity => 1, + :graphicXOffset => -12.5, + :graphicYOffset => 12.5 + } - def initialize(display_label = false, styles = {}) - @display_label = display_label - @styles = styles + def initialize(options = {}) + @default_style = options[:default_style].present? ? options[:default_style].merge(@@default_style_class) : @@default_style_class end - def default_style - style = { - :label => ("${label}" if display_label), - :fontColor => "black", - :fontSize => "11px", - :fontWeight => "bold", - :labelAlign => "ct", - :labelXOffset => 0, - :labelYOffset => -40, - :pointRadius => 1, - :externalGraphic => "/assets/map/${areaType}.png", - :graphicWidth => 25, - :graphicHeight => 25, - :graphicOpacity => 1, - :graphicXOffset => -12.5, - :graphicYOffset => 12.5, - :display => true - } - - if styles["default"].present? - style.merge styles["default"] - else - style - end - end - - def select_style - select_style = { - :label => ("${label}" if display_label), - :fontColor => "black", - :fontSize => "11px", - :fontWeight => "bold", - :labelAlign => "ct", - :labelXOffset => 0, - :labelYOffset => -15, - :externalGraphic => "/assets/map/${areaType}.png", - :graphicWidth => 25, - :graphicHeight => 25, - :graphicOpacity => 1, - :graphicXOffset => 12.5, - :graphicYOffset => 12.5, - :display => true - } - - if styles["select"].present? - select_style.merge styles["select"] - else - select_style - end - end def context - context = { + { :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ", :areaType => :" function(feature) { return feature.attributes.stop_area_type.toLowerCase();} " } end def style_map - OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(default_style, { :context => context}), - :select => OpenLayers::Style.new(select_style, { :context => context}) - ) + OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(default_style, { :context => context}) ) end end diff --git a/app/views/stop_areas/show.kml.erb b/app/views/stop_areas/show.kml.erb index 60ea5f612..16613b6bc 100644 --- a/app/views/stop_areas/show.kml.erb +++ b/app/views/stop_areas/show.kml.erb @@ -4,7 +4,7 @@ <Placemark id="<%= @stop_area.id %>" > <name><%= @stop_area.name %></name> <stop_area_type><%= @stop_area.type %></stop_area_type> - <%= @stop_area.geometry.kml_representation.html_safe %> + <%= (@stop_area.position or @stop_area.default_position).kml_representation.html_safe %> </Placemark> </Document> </kml> diff --git a/db/schema.rb b/db/schema.rb index 7666b10bf..86aebcd98 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120426141032) do +ActiveRecord::Schema.define(:version => 20120516172252) do create_table "company", :force => true do |t| t.string "objectid" @@ -54,6 +54,31 @@ ActiveRecord::Schema.define(:version => 20120426141032) do add_index "connectionlink", ["objectid"], :name => "connectionlink_objectid_key", :unique => true + create_table "delayed_jobs", :force => true do |t| + t.integer "priority", :default => 0 + t.integer "attempts", :default => 0 + t.text "handler" + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + + create_table "imports", :force => true do |t| + t.integer "referential_id" + t.string "status" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "imports", ["referential_id"], :name => "index_imports_on_referential_id" + create_table "line", :force => true do |t| t.integer "ptnetworkid", :limit => 8 t.integer "companyid", :limit => 8 |
