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 /app/maps | |
| parent | 41dc5c3cbcdf7cea46561b8223bd57a1bb4377cb (diff) | |
| download | chouette-core-63dbf0e73aa7e32eca6bcab41f970efdd8e441d6.tar.bz2 | |
Add ffi for georuby ext and update stop area map Refs #18 #20 #22
Diffstat (limited to 'app/maps')
| -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 |
7 files changed, 62 insertions, 129 deletions
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 |
