aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Etienne2012-05-21 11:39:00 +0200
committerMichel Etienne2012-05-21 11:39:00 +0200
commit1cc9e0a809793cc87ce593e842f2bce9c14cc06b (patch)
tree7da88a00e73130e21f91ff056d39f7583cc3e55e
parent84056ddeab762326909b474f05670f90116b36a4 (diff)
parent63213bbbd8be7f4e20c4ed7191327bfed3575d55 (diff)
downloadchouette-core-1cc9e0a809793cc87ce593e842f2bce9c14cc06b.tar.bz2
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
-rw-r--r--Gemfile7
-rw-r--r--Gemfile.lock29
-rw-r--r--app/controllers/stop_areas_controller.rb4
-rw-r--r--app/maps/application_map.rb3
-rw-r--r--app/maps/connection_link_map.rb2
-rw-r--r--app/maps/line_map.rb2
-rw-r--r--app/maps/network_map.rb2
-rw-r--r--app/maps/stop_area_map.rb10
-rw-r--r--app/maps/style_map/edit_stop_area_style_map.rb93
-rw-r--r--app/maps/style_map/stop_areas_style_map.rb79
-rw-r--r--app/views/stop_areas/show.kml.erb2
11 files changed, 97 insertions, 136 deletions
diff --git a/Gemfile b/Gemfile
index fd5c70e9f..f3659bc37 100644
--- a/Gemfile
+++ b/Gemfile
@@ -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'
diff --git a/Gemfile.lock b/Gemfile.lock
index 90f8cd70d..01a35a77e 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: git://chouette.dryade.priv/ninoxe
- revision: 9deb81a3121fdf295512f875a91ba7b5d0d106a4
+ revision: dcf5c4e0f9d1abf7524d1ae9bf672276ab978052
specs:
ninoxe (0.0.8)
GeoRuby
@@ -34,6 +34,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:
@@ -142,10 +161,13 @@ GEM
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)
@@ -167,6 +189,7 @@ GEM
bouncy-castle-java (>= 1.5.0146.1)
jruby-rack (1.1.5)
json (1.7.3-java)
+ json_pure (1.7.3)
launchy (2.1.0)
addressable (~> 2.2.6)
launchy (2.1.0-java)
@@ -237,6 +260,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 +335,6 @@ DEPENDENCIES
capistrano
capistrano-ext
capybara
- capybara-webkit
cocoon
coffee-rails (~> 3.1.1)
coffee-script-source
@@ -320,7 +343,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>