aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Florisson2012-05-04 14:07:12 +0200
committerMarc Florisson2012-05-04 14:07:12 +0200
commit09c55792e887dea709df29cae2e4fb8fbd86901c (patch)
tree5ef824a3144995bd1ab552eea4c852b23f99c35f
parentac3a3153fa18da97cc120703f9a62061a211b581 (diff)
downloadchouette-core-09c55792e887dea709df29cae2e4fb8fbd86901c.tar.bz2
add map on route view
-rw-r--r--.gitignore1
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock103
-rw-r--r--app/assets/images/map/arrival.pngbin0 -> 598 bytes
-rw-r--r--app/assets/images/map/departure.pngbin0 -> 568 bytes
-rw-r--r--app/assets/images/map/interstop.pngbin0 -> 937 bytes
-rw-r--r--app/assets/stylesheets/routes.css.scss4
-rw-r--r--app/controllers/routes_controller.rb2
-rw-r--r--app/maps/route_map.rb35
-rw-r--r--app/maps/style_map/route_style_map.rb44
-rw-r--r--app/views/routes/show.html.erb5
-rw-r--r--app/views/routes/show.kml.erb21
-rw-r--r--config/environments/development.rb3
13 files changed, 162 insertions, 58 deletions
diff --git a/.gitignore b/.gitignore
index 953761d7b..4dcf29e87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ public/assets/
# for vim users
*.swp
*.swo
+.DS_Store
diff --git a/Gemfile b/Gemfile
index 15e851710..d9945d472 100644
--- a/Gemfile
+++ b/Gemfile
@@ -21,7 +21,7 @@ gem "map_layers", "~> 0.0.4"
gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface'
gem 'json'
-gem 'formtastic'
+gem 'formtastic', '2.0.2'
gem 'inherited_resources'
gem 'will_paginate', '~> 3.0'
gem 'ransack'
diff --git a/Gemfile.lock b/Gemfile.lock
index 0ca616b56..c889cdef0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: git://chouette.dryade.priv/ninoxe
- revision: 9d0c176c3f86d2dbceb1ad5aa0bd2ed7e725c13a
+ revision: c572eb23f0c9ec2d8857f453935f90986e170870
specs:
ninoxe (0.0.8)
GeoRuby
@@ -34,11 +34,11 @@ GIT
GIT
remote: git://github.com/thoughtbot/shoulda.git
- revision: 80545637b957fc68a3b7be8993033d089913ac66
+ revision: 269edccc7df8f2eb94a96a6a6d248a5960d7fe1f
specs:
- shoulda (3.0.0.beta2)
- shoulda-context (~> 1.0.0.beta1)
- shoulda-matchers (~> 1.0.0.beta1)
+ shoulda (3.0.1)
+ shoulda-context (~> 1.0)
+ shoulda-matchers (~> 1.0)
GIT
remote: git://sim.dryade.priv/user_interface
@@ -53,8 +53,7 @@ GEM
GeoRuby (1.3.4)
RedCloth (4.2.9)
RedCloth (4.2.9-java)
- SyslogLogger (1.4.0)
- hoe (>= 1.2.0)
+ SyslogLogger (1.4.1)
actionmailer (3.1.3)
actionpack (= 3.1.3)
mail (~> 2.3.0)
@@ -86,13 +85,13 @@ GEM
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
- addressable (2.2.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)
- capistrano (2.9.0)
+ capistrano (2.12.0)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
@@ -107,10 +106,7 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- capybara-webkit (0.11.0)
- capybara (>= 1.0.0, < 1.2)
- json
- childprocess (0.3.0)
+ childprocess (0.3.2)
ffi (~> 1.0.6)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
@@ -118,10 +114,10 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
- coffee-script-source (1.1.2)
+ coffee-script-source (1.3.1)
composite_primary_keys (4.1.2)
activerecord (~> 3.1)
- database_cleaner (0.7.1)
+ database_cleaner (0.7.2)
devise (2.0.4)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
@@ -129,7 +125,7 @@ GEM
warden (~> 1.1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
- execjs (1.2.13)
+ execjs (1.3.1)
multi_json (~> 1.0)
factory_girl (2.6.4)
activesupport (>= 2.3.9)
@@ -142,16 +138,14 @@ GEM
rails (~> 3.0)
geokit (1.6.5)
multi_json
- guard (1.0.1)
+ guard (1.0.2)
ffi (>= 0.5.0)
thor (~> 0.14.6)
- guard-rspec (0.6.0)
+ guard-rspec (0.7.0)
guard (>= 0.10.0)
has_scope (0.5.1)
highline (1.6.11)
hike (1.2.1)
- hoe (2.14.0)
- rake (~> 0.8)
i18n (0.6.0)
inherited_resources (1.3.1)
has_scope (~> 0.5.0)
@@ -160,25 +154,27 @@ GEM
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
- jruby-jars (1.6.7)
- jruby-openssl (0.7.4)
- bouncy-castle-java
+ jruby-jars (1.6.7.2)
+ jruby-openssl (0.7.6.1)
+ bouncy-castle-java (>= 1.5.0146.1)
jruby-rack (1.1.5)
json (1.7.0)
json (1.7.0-java)
- launchy (2.0.5)
+ launchy (2.1.0)
addressable (~> 2.2.6)
- launchy (2.0.5-java)
+ launchy (2.1.0-java)
addressable (~> 2.2.6)
ffi (~> 1.0.9)
spoon (~> 0.0.1)
+ libwebsocket (0.1.3)
+ addressable
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
map_layers (0.0.5)
mime-types (1.18)
- multi_json (1.0.4)
+ multi_json (1.3.4)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
@@ -186,10 +182,9 @@ GEM
net-ssh (2.3.0)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
- nokogiri (1.5.0)
- nokogiri (1.5.0-java)
+ nokogiri (1.5.2)
+ nokogiri (1.5.2-java)
orm_adapter (0.0.7)
- pg (0.11.0)
polyamorous (0.5.0)
activerecord (~> 3.0)
polyglot (0.3.3)
@@ -233,53 +228,54 @@ GEM
remarkable (~> 4.0.0.alpha4)
remarkable_activemodel (~> 4.0.0.alpha4)
rspec (>= 2.0.0.alpha11)
- responders (0.9.0)
+ responders (0.9.1)
railties (~> 3.1)
- rspec (2.8.0)
- rspec-core (~> 2.8.0)
- rspec-expectations (~> 2.8.0)
- rspec-mocks (~> 2.8.0)
- rspec-core (2.8.0)
- rspec-expectations (2.8.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.8.0)
- rspec-rails (2.8.1)
+ rspec (2.10.0)
+ rspec-core (~> 2.10.0)
+ rspec-expectations (~> 2.10.0)
+ rspec-mocks (~> 2.10.0)
+ rspec-core (2.10.0)
+ rspec-expectations (2.10.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.10.0)
+ rspec-rails (2.10.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.8.0)
- rubyzip (0.9.7)
- sass (3.1.12)
- sass-rails (3.1.5)
+ rspec (~> 2.10.0)
+ rubyzip (0.9.8)
+ sass (3.1.16)
+ sass-rails (3.1.6)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
- sass (~> 3.1.10)
+ sass (>= 3.1.10)
tilt (~> 1.3.2)
- selenium-webdriver (2.17.0)
+ selenium-webdriver (2.21.2)
childprocess (>= 0.2.5)
- ffi (~> 1.0.9)
- multi_json (~> 1.0.4)
+ ffi (~> 1.0)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
rubyzip
shoulda-context (1.0.0)
- shoulda-matchers (1.0.0)
+ shoulda-matchers (1.1.0)
+ activesupport (>= 3.0.0)
spoon (0.0.1)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
- squeel (0.9.5)
+ squeel (1.0.1)
activerecord (~> 3.0)
activesupport (~> 3.0)
polyamorous (~> 0.5.0)
- therubyrhino (1.73.1)
+ therubyrhino (1.73.3)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
- uglifier (1.2.1)
+ uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
warbler (1.3.5)
@@ -295,7 +291,6 @@ GEM
PLATFORMS
java
- ruby
DEPENDENCIES
RedCloth
@@ -313,7 +308,7 @@ DEPENDENCIES
database_cleaner
devise
factory_girl_rails (= 1.7)
- formtastic
+ formtastic (= 2.0.2)
guard
guard-rspec
inherited_resources
diff --git a/app/assets/images/map/arrival.png b/app/assets/images/map/arrival.png
new file mode 100644
index 000000000..844b8c6c6
--- /dev/null
+++ b/app/assets/images/map/arrival.png
Binary files differ
diff --git a/app/assets/images/map/departure.png b/app/assets/images/map/departure.png
new file mode 100644
index 000000000..22a3244ee
--- /dev/null
+++ b/app/assets/images/map/departure.png
Binary files differ
diff --git a/app/assets/images/map/interstop.png b/app/assets/images/map/interstop.png
new file mode 100644
index 000000000..2fcd04b99
--- /dev/null
+++ b/app/assets/images/map/interstop.png
Binary files differ
diff --git a/app/assets/stylesheets/routes.css.scss b/app/assets/stylesheets/routes.css.scss
index c55a4646d..3e2e5b5ed 100644
--- a/app/assets/stylesheets/routes.css.scss
+++ b/app/assets/stylesheets/routes.css.scss
@@ -70,6 +70,10 @@
@include content_to_clear;
}
+ .route_stop_areas {
+ clear: both;
+ }
+
.stop_area {
@include div_for_object;
/* to create multi-column index */
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 55a700315..2ed39b0ac 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -2,6 +2,7 @@ class RoutesController < ChouetteController
defaults :resource_class => Chouette::Route
respond_to :html, :xml, :json
+ respond_to :kml, :only => :show
belongs_to :referential do
belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true
@@ -14,6 +15,7 @@ class RoutesController < ChouetteController
end
def show
+ @map = RouteMap.new referential, resource
@stop_areas = resource.stop_areas.paginate(:page => params[:page], :per_page => 10)
show!
end
diff --git a/app/maps/route_map.rb b/app/maps/route_map.rb
new file mode 100644
index 000000000..417b6037a
--- /dev/null
+++ b/app/maps/route_map.rb
@@ -0,0 +1,35 @@
+class RouteMap < ApplicationMap
+
+ attr_reader :referential, :route, :style
+
+ def initialize(referential, route, style = nil)
+ @referential = referential
+ @route = route
+ @style = style
+ end
+
+ def map
+ @map ||= MapLayers::Map.new(id, :projection => projection("EPSG:900913"), :controls => controls) do |map, page|
+ page << map.add_layer(MapLayers::OSM_MAPNIK)
+ page << map.add_layer(google_physical)
+ page << map.add_layer(google_streets)
+ page << map.add_layer(google_hybrid)
+ 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, route.line, route], :format => :kml), :styleMap => StyleMap::RouteStyleMap.new.style_map))
+ page << map.zoom_to_extent(bounds) if bounds
+ end
+ end
+
+ def bounds
+ wgs84_bounds = ( route.geometry.empty?) ? Chouette::StopArea.bounds : route.geometry.envelope
+
+ @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
+
+end
+
diff --git a/app/maps/style_map/route_style_map.rb b/app/maps/style_map/route_style_map.rb
new file mode 100644
index 000000000..136cecba5
--- /dev/null
+++ b/app/maps/style_map/route_style_map.rb
@@ -0,0 +1,44 @@
+class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap
+ attr_accessor :style
+
+ def initialize(options = {})
+ @style = options[:style].present? ? default_style.merge(options[:style]) : default_style
+ end
+
+ def default_style
+ {
+ :label => "${label}",
+ :fontColor => "black",
+ :fontSize => "11px",
+ :fontWeight => "bold",
+ :labelAlign => "ct",
+ :labelXOffset => 0,
+ :labelYOffset => -15,
+ :strokeColor => "#000000",
+ :strokeOpacity => 1,
+ :strokeWidth => 3,
+ :strokeLineCap => "round",
+ :strokeDashstyle => "solid",
+ :externalGraphic => "/assets/map/${positionType}.png",
+ :graphicWidth => 12,
+ :graphicHeight => 12,
+ :graphicOpacity => 1,
+ :graphicXOffset => -6,
+ :graphicYOffset => -6,
+ :display => true
+ }
+ end
+
+ def context
+ context = {
+ :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ",
+ :positionType => :" function(feature) { if (feature.attributes.departure != undefined) { return 'departure'; } else if (feature.attributes.arrival != undefined) { return 'arrival'; } else { return 'interstop'; }} "
+ }
+ end
+
+ def style_map
+ OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}))
+ end
+
+end
+
diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb
index 2b48f8829..15eb8780e 100644
--- a/app/views/routes/show.html.erb
+++ b/app/views/routes/show.html.erb
@@ -1,6 +1,7 @@
-<%= title_tag t('routes.show.title', :route => @route.name, :line => @line.name ) %>
+<%= title_tag t('routes.show.title', :route => @route.name, :line => @route.line.name ) %>
<div class="route_show">
+ <%= @map.to_html.html_safe %>
<div class="summary">
<p>
@@ -63,7 +64,7 @@
</div>
-<h3><%= t('.stop_areas') %></h3>
+<h3 class="route_stop_areas"><%= t('.stop_areas') %></h3>
<%= will_paginate @stop_areas %>
<div class="stop_areas paginated_content">
<%= render :partial => "stop_areas/stop_area", :collection => @stop_areas %>
diff --git a/app/views/routes/show.kml.erb b/app/views/routes/show.kml.erb
new file mode 100644
index 000000000..4e90fa963
--- /dev/null
+++ b/app/views/routes/show.kml.erb
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://www.opengis.net/kml/2.2">
+ <Document>
+ <Placemark id="route_<%= @route.id %>" >
+ <name><%= @route.name %></name>
+ <%= @route.geometry.kml_representation.html_safe %>
+ </Placemark>
+ <% @route.stop_areas.where("latitude is not null and longitude is not null").each_with_index do |stop_area, index| %>
+ <Placemark id="<%= stop_area.id %>" >
+ <name><%= "#{stop_area.name} (#{index+1})" %></name>
+ <% if stop_area.id==@route.stop_areas.first.id %>
+ <departure>true</departure>
+ <% elsif stop_area.id==@route.stop_areas.last.id %>
+ <arrival>true</arrival>
+ <% end %>
+ <%= stop_area.geometry.kml_representation.html_safe %>
+ </Placemark>
+ <% end %>
+ </Document>
+</kml>
+
diff --git a/config/environments/development.rb b/config/environments/development.rb
index c5b965a99..079265bdb 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -31,8 +31,9 @@ ChouetteIhm::Application.configure do
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.to_prepare do
- Chouette::Loader.chouette_command = "true"
+ # Chouette::Loader.chouette_command = "true"
# Chouette::Loader.chouette_command = "tmp/chouette-command/chouette"
+ Chouette::Loader.chouette_command = "/Users/marc/dev/chouette-command/chouette-kyriel_1.7.4/chouette"
end
end