diff options
| author | Marc Florisson | 2012-09-19 12:04:29 +0200 | 
|---|---|---|
| committer | Marc Florisson | 2012-09-19 12:04:29 +0200 | 
| commit | 629ebdfafc4ac8fa0bc65a1dd93b1e21b985d162 (patch) | |
| tree | 28e5eec26a063891be3d0828f24e14518abba742 /app/maps | |
| parent | 7cdfab565d89ebcf88c4e04912bd55b430dafa80 (diff) | |
| parent | 307254776caa2aa353422b8a489ab804d18e1cbc (diff) | |
| download | chouette-core-629ebdfafc4ac8fa0bc65a1dd93b1e21b985d162.tar.bz2 | |
merge branch master
Diffstat (limited to 'app/maps')
| -rw-r--r-- | app/maps/application_map.rb | 11 | ||||
| -rw-r--r-- | app/maps/connection_link_map.rb | 2 | ||||
| -rw-r--r-- | app/maps/journey_pattern_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/route_map.rb | 2 | ||||
| -rw-r--r-- | app/maps/stop_area_map.rb | 13 | ||||
| -rw-r--r-- | app/maps/style_map/connection_link_style_map.rb | 5 | ||||
| -rw-r--r-- | app/maps/style_map/edit_stop_area_style_map.rb | 64 | ||||
| -rw-r--r-- | app/maps/style_map/generic_style_map.rb | 6 | ||||
| -rw-r--r-- | app/maps/style_map/journey_pattern_style_map.rb | 7 | ||||
| -rw-r--r-- | app/maps/style_map/line_style_map.rb | 3 | ||||
| -rw-r--r-- | app/maps/style_map/route_style_map.rb | 7 | ||||
| -rw-r--r-- | app/maps/style_map/stop_areas_style_map.rb | 42 | 
14 files changed, 75 insertions, 93 deletions
diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index 1fd2326c7..618ca0db2 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -7,7 +7,7 @@ class ApplicationMap    cattr_accessor :ign_api_key    def helpers -    @helper ||= Helpers.new +    @helpers ||= Helpers.new    end    # For example, in a controller : @@ -136,11 +136,6 @@ class ApplicationMap      "#{relative_url_root}/assets/openlayers/"    end -  def polymorphic_path_patch( source) -    relative_url_root = Rails.application.config.relative_url_root -    relative_url_root && !source.starts_with?("#{relative_url_root}/") ? "#{relative_url_root}#{source}" : source -  end -    def kml_layer(url_or_object, options_or_url_options = {}, options = nil)         unless options        url_options = {} @@ -156,9 +151,9 @@ class ApplicationMap        when String          url_or_object        when Array -        polymorphic_path_patch( helpers.polymorphic_path(url_or_object, url_options)) +        helpers.polymorphic_path_patch( helpers.polymorphic_path(url_or_object, url_options))        else -        polymorphic_path_patch( helpers.polymorphic_path([url_or_object.referential, url_or_object], url_options)) +        helpers.polymorphic_path_patch( helpers.polymorphic_path([url_or_object.referential, url_or_object], url_options))        end      protocol = OpenLayers::Protocol::HTTP.new :url => url, :format => kml diff --git a/app/maps/connection_link_map.rb b/app/maps/connection_link_map.rb index 62f6a23a9..98e51e38f 100644 --- a/app/maps/connection_link_map.rb +++ b/app/maps/connection_link_map.rb @@ -9,7 +9,7 @@ class ConnectionLinkMap < ApplicationMap    end    def customize_map(map, page) -    page.assign "stop_areas_layer", kml_layer([connection_link.referential, connection_link, :stop_areas], :styleMap => StyleMap::StopAreasStyleMap.new.style_map)  +    page.assign "stop_areas_layer", kml_layer([connection_link.referential, connection_link, :stop_areas], :styleMap => StyleMap::StopAreasStyleMap.new(helpers).style_map)       page << map.add_layer(:stop_areas_layer)      page << map.add_layer( kml_layer([connection_link.referential, connection_link], :styleMap => StyleMap::ConnectionLinkStyleMap.new.style_map))      page << map.add_control( hover_control_display_name(:stop_areas_layer) ) diff --git a/app/maps/journey_pattern_map.rb b/app/maps/journey_pattern_map.rb index b4117645d..075019c79 100644 --- a/app/maps/journey_pattern_map.rb +++ b/app/maps/journey_pattern_map.rb @@ -8,7 +8,7 @@ class JourneyPatternMap < ApplicationMap    end    def customize_map(map, page) -    layer = kml_layer([journey_pattern.referential, journey_pattern.route.line, journey_pattern.route, journey_pattern], :styleMap => StyleMap::JourneyPatternStyleMap.new.style_map) +    layer = kml_layer([journey_pattern.referential, journey_pattern.route.line, journey_pattern.route, journey_pattern], :styleMap => StyleMap::JourneyPatternStyleMap.new(helpers).style_map)      page.assign "journeyPatternLayer", layer      selectFeature = OpenLayers::Control::SelectFeature.new( :journeyPatternLayer) diff --git a/app/maps/line_map.rb b/app/maps/line_map.rb index 9b398cae2..3bc229555 100644 --- a/app/maps/line_map.rb +++ b/app/maps/line_map.rb @@ -10,7 +10,7 @@ class LineMap < ApplicationMap    def customize_map(map, page)      page << map.add_layer(kml_layer(line, :styleMap => StyleMap::LineStyleMap.new( :style => line_style).style_map)) -    page.assign "stop_areas_layer", kml_layer([line.referential, line], :styleMap => StyleMap::StopAreasStyleMap.new.style_map) +    page.assign "stop_areas_layer", kml_layer([line.referential, line], :styleMap => StyleMap::StopAreasStyleMap.new(helpers).style_map)      page << map.add_layer(:stop_areas_layer) diff --git a/app/maps/network_map.rb b/app/maps/network_map.rb index f3693b985..ec23f62c9 100644 --- a/app/maps/network_map.rb +++ b/app/maps/network_map.rb @@ -8,7 +8,7 @@ class NetworkMap < ApplicationMap    end    def customize_map(map, page) -    page.assign "stop_areas_layer", kml_layer([network.referential, network], :styleMap => StyleMap::StopAreasStyleMap.new.style_map) +    page.assign "stop_areas_layer", kml_layer([network.referential, network], :styleMap => StyleMap::StopAreasStyleMap.new(helpers).style_map)      page << map.add_layer(:stop_areas_layer)      page << map.add_control( hover_control_display_name(:stop_areas_layer) ) diff --git a/app/maps/route_map.rb b/app/maps/route_map.rb index a1f6bcf1d..fc1a7d93e 100644 --- a/app/maps/route_map.rb +++ b/app/maps/route_map.rb @@ -8,7 +8,7 @@ class RouteMap < ApplicationMap    end    def customize_map(map, page) -    layer = kml_layer([route.referential, route.line, route], :styleMap => StyleMap::RouteStyleMap.new.style_map) +    layer = kml_layer([route.referential, route.line, route], :styleMap => StyleMap::RouteStyleMap.new(helpers).style_map)      page.assign "routeLayer", layer      selectFeature = OpenLayers::Control::SelectFeature.new( :routeLayer) diff --git a/app/maps/stop_area_map.rb b/app/maps/stop_area_map.rb index 2134a78c0..a1cae955c 100644 --- a/app/maps/stop_area_map.rb +++ b/app/maps/stop_area_map.rb @@ -9,16 +9,8 @@ class StopAreaMap < ApplicationMap      @stop_area = stop_area    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(geoportail_wmts) -      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.assign "edit_stop_area_layer", kml_layer(stop_area, { :default => editable? }, :style_map => StyleMap::EditStopAreaStyleMap.new.style_map) +  def customize_map(map, page) +      page.assign "edit_stop_area_layer", kml_layer(stop_area, { :default => editable? }, :style_map => StyleMap::EditStopAreaStyleMap.new(helpers).style_map)        page << map.add_layer(:edit_stop_area_layer) @@ -45,7 +37,6 @@ EOF        end        page << map.set_center(center.to_google.to_openlayers, 16, false, true) -    end    end    def projection_type diff --git a/app/maps/style_map/connection_link_style_map.rb b/app/maps/style_map/connection_link_style_map.rb index 9a0abfebc..99393fc08 100644 --- a/app/maps/style_map/connection_link_style_map.rb +++ b/app/maps/style_map/connection_link_style_map.rb @@ -1,7 +1,8 @@  class StyleMap::ConnectionLinkStyleMap < StyleMap::GenericStyleMap    attr_accessor :style -  def initialize(options = {}) +  def initialize(helpers,options = {}) +    @helpers= helpers      @style = options[:style].present? ? default_style.merge(options[:style]) : default_style    end @@ -18,7 +19,7 @@ class StyleMap::ConnectionLinkStyleMap < StyleMap::GenericStyleMap        :strokeWidth => 3,        :strokeLineCap => "round",        :strokeDashstyle => "solid", -      :externalGraphic => self.class.polymorphic_path_patch( "map/${positionType}.png"), +      :externalGraphic => @helpers.assets_path_patch( "map/${positionType}.png"),        :graphicWidth => 36,        :graphicHeight => 36,         :graphicOpacity => 1,	 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 263950d62..38f18f04a 100644 --- a/app/maps/style_map/edit_stop_area_style_map.rb +++ b/app/maps/style_map/edit_stop_area_style_map.rb @@ -1,37 +1,36 @@  class StyleMap::EditStopAreaStyleMap < StyleMap::GenericStyleMap -  attr_accessor :default_style, :select_style, :context +  attr_accessor :style -  @@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 default_style +    { :fontColor => "black", +      :fontSize => "11px", +      :fontWeight => "bold", +      :labelAlign => "ct", +      :labelXOffset => 0, +      :labelYOffset => -15, +      :pointRadius => 4, +      :fillColor => "white", +      :fillOpacity => 1, +      :strokeColor => "black", +      :strokeOpacity => 1, +      :strokeWidth => 2 }  +  end -  @@select_style_class = { -    :fontColor => "black",  -    :fontSize => "11px", -    :fontWeight => "bold", -    :pointRadius => 4, -    :fillColor => "#86b41d", -    :fillOpacity => 1, -    :strokeColor => "black", -    :strokeOpacity => 1, -    :strokeWidth => 2 -  } +  def select_style +   { :fontColor => "black",  +     :fontSize => "11px", +     :fontWeight => "bold", +     :pointRadius => 4, +     :fillColor => "#86b41d", +     :fillOpacity => 1, +     :strokeColor => "black", +     :strokeOpacity => 1, +     :strokeWidth => 2 } +  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 +  def initialize(helpers, options = {}) +    @helpers= helpers +    @style = options[:style].present? ? default_style.merge(options[:style]) : default_style    end    def context @@ -41,10 +40,7 @@ class StyleMap::EditStopAreaStyleMap < StyleMap::GenericStyleMap    end    def style_map -    OpenLayers::StyleMap.new( -                             :default => OpenLayers::Style.new(default_style,  { :context => context}), -                             :select => OpenLayers::Style.new(select_style) -                             ) +    OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}), :select =>  OpenLayers::Style.new(style.merge( select_style), { :context => context}))    end  end diff --git a/app/maps/style_map/generic_style_map.rb b/app/maps/style_map/generic_style_map.rb index 88819650a..c905cd00d 100644 --- a/app/maps/style_map/generic_style_map.rb +++ b/app/maps/style_map/generic_style_map.rb @@ -2,10 +2,4 @@ class StyleMap::GenericStyleMap    include MapLayers    include MapLayers::ViewHelpers -  def self.polymorphic_path_patch( source) -     -    relative_url_root = Rails.application.config.relative_url_root -    return "/assets/#{source}" unless relative_url_root -    "#{relative_url_root}/assets/#{source}" -  end  end diff --git a/app/maps/style_map/journey_pattern_style_map.rb b/app/maps/style_map/journey_pattern_style_map.rb index 9e2550232..5a06b5c18 100644 --- a/app/maps/style_map/journey_pattern_style_map.rb +++ b/app/maps/style_map/journey_pattern_style_map.rb @@ -1,12 +1,13 @@  class StyleMap::JourneyPatternStyleMap < StyleMap::GenericStyleMap    attr_accessor :style -  def initialize(options = {}) +  def initialize(helpers, options = {}) +    @helpers= helpers      @style = options[:style].present? ? default_style.merge(options[:style]) : default_style    end    def select_style -    default_style.merge :externalGraphic => self.class.polymorphic_path_patch( "icons/stop_area_hover.png") +    default_style.merge :externalGraphic => @helpers.assets_path_patch( "icons/stop_area_hover.png")    end    def default_style      { @@ -22,7 +23,7 @@ class StyleMap::JourneyPatternStyleMap < StyleMap::GenericStyleMap        :strokeWidth => 3,        :strokeLineCap => "round",        :strokeDashstyle => "solid", -      :externalGraphic => self.class.polymorphic_path_patch( "icons/${positionType}.png"), +      :externalGraphic => @helpers.assets_path_patch( "icons/${positionType}.png"),        :graphicWidth => 12,        :graphicHeight => 12,         :graphicOpacity => 1,	 diff --git a/app/maps/style_map/line_style_map.rb b/app/maps/style_map/line_style_map.rb index e86e8570f..acc307df4 100644 --- a/app/maps/style_map/line_style_map.rb +++ b/app/maps/style_map/line_style_map.rb @@ -1,7 +1,8 @@  class StyleMap::LineStyleMap < StyleMap::GenericStyleMap    attr_accessor :style, :line_priority, :line_color -  def initialize(options = {}) +  def initialize(helpers,options = {}) +    @helpers= helpers      @line_color = options[:line_color]      @style = options[:style].present? ? default_style.merge(options[:style]) : default_style    end diff --git a/app/maps/style_map/route_style_map.rb b/app/maps/style_map/route_style_map.rb index c791441f4..1d9ab12f0 100644 --- a/app/maps/style_map/route_style_map.rb +++ b/app/maps/style_map/route_style_map.rb @@ -1,12 +1,13 @@  class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap    attr_accessor :style -  def initialize(options = {}) +  def initialize(helpers,options = {}) +    @helpers= helpers      @style = options[:style].present? ? default_style.merge(options[:style]) : default_style    end    def select_style -    default_style.merge :externalGraphic => self.class.polymorphic_path_patch( "icons/stop_area_hover.png") +    default_style.merge :externalGraphic => @helpers.assets_path_patch( "icons/stop_area_hover.png")    end    def default_style      { @@ -22,7 +23,7 @@ class StyleMap::RouteStyleMap < StyleMap::GenericStyleMap        :strokeWidth => 3,        :strokeLineCap => "round",        :strokeDashstyle => "solid", -      :externalGraphic => self.class.polymorphic_path_patch( "icons/${positionType}.png"), +      :externalGraphic => @helpers.assets_path_patch( "icons/${positionType}.png"),        :graphicWidth => 12,        :graphicHeight => 12,         :graphicOpacity => 1,	 diff --git a/app/maps/style_map/stop_areas_style_map.rb b/app/maps/style_map/stop_areas_style_map.rb index 5bb16af35..398748a22 100644 --- a/app/maps/style_map/stop_areas_style_map.rb +++ b/app/maps/style_map/stop_areas_style_map.rb @@ -1,25 +1,27 @@  class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap -  attr_accessor :default_style, :context +  attr_accessor :style, :context -  @@default_style_class = { -    :label => "${label}", -    :fontColor => "black", -    :fontSize => "11px", -    :fontWeight => "bold", -    :labelAlign => "ct", -    :labelXOffset => 0, -    :labelYOffset => -40, -    :pointRadius => 1,  -    :externalGraphic => polymorphic_path_patch( "map/${areaType}.png"),       -    :graphicWidth => 25, -    :graphicHeight => 25,  -    :graphicOpacity => 1,     -    :graphicXOffset => -12.5, -    :graphicYOffset => -12.5 -  } +  def default_style +    raise "Helpers nil" if @helpers.nil? +    {:label => "${label}", +     :fontColor => "black", +     :fontSize => "11px", +     :fontWeight => "bold", +     :labelAlign => "ct", +     :labelXOffset => 0, +     :labelYOffset => -40, +     :pointRadius => 1,  +     :externalGraphic => @helpers.assets_path_patch( "map/${areaType}.png"),       +     :graphicWidth => 25, +     :graphicHeight => 25,  +     :graphicOpacity => 1,     +     :graphicXOffset => -12.5, +     :graphicYOffset => -12.5 } +  end -  def initialize(options = {}) -    @default_style = options[:default_style].present? ? options[:default_style].merge(@@default_style_class) : @@default_style_class +  def initialize(helpers,options = {}) +    @helpers= helpers +    @style = options[:style].present? ? default_style.merge(options[:style]) : default_style    end @@ -31,7 +33,7 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap    end    def style_map -    OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(default_style, { :context => context})                             ) +    OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context})                             )    end  end  | 
