From 5f4435e813a68654553ca90046bfae70c48d6830 Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Thu, 20 Sep 2012 09:43:15 +0200 Subject: remove useless method --- app/maps/application_map.rb | 6 ------ 1 file changed, 6 deletions(-) (limited to 'app/maps') diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index 9c4eaf643..5efd6da84 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -110,12 +110,6 @@ class ApplicationMap } } ) end - def open_layer_path - relative_url_root = Rails.application.config.relative_url_root - return "/assets/openlayers/" unless relative_url_root - "#{relative_url_root}/assets/openlayers/" - end - def kml_layer(url_or_object, options_or_url_options = {}, options = nil) unless options url_options = {} -- cgit v1.2.3 From 159e9c1ee586cf48cd2150f64d825a1580d79225 Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Wed, 3 Oct 2012 09:36:22 +0200 Subject: fix connection_link#show. Refs #127 --- app/maps/connection_link_map.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/maps') diff --git a/app/maps/connection_link_map.rb b/app/maps/connection_link_map.rb index 5e75f371b..fe83efe40 100644 --- a/app/maps/connection_link_map.rb +++ b/app/maps/connection_link_map.rb @@ -16,7 +16,7 @@ class ConnectionLinkMap < ApplicationMap page << map.add_layer(google_hybrid) page << map.add_layer(google_satellite) - 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(helpers).style_map)) page << map.add_control( hover_control_display_name(:stop_areas_layer) ) -- cgit v1.2.3 From 72de1c47254ca70d7be04a96b5b11dfed8f79df6 Mon Sep 17 00:00:00 2001 From: Michel Etienne Date: Tue, 9 Oct 2012 16:03:11 +0200 Subject: add group_of_line managment --- app/maps/group_of_line_map.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/maps/group_of_line_map.rb (limited to 'app/maps') diff --git a/app/maps/group_of_line_map.rb b/app/maps/group_of_line_map.rb new file mode 100644 index 000000000..fdd8cac1d --- /dev/null +++ b/app/maps/group_of_line_map.rb @@ -0,0 +1,34 @@ +class GroupOfLineMap < ApplicationMap + + attr_reader :group_of_line, :group_of_line_style + + def initialize(group_of_line, group_of_line_style = nil) + @group_of_line = group_of_line + @group_of_line_style = group_of_line_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.assign "stop_areas_layer", kml_layer([group_of_line.referential, group_of_line], :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) ) + page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds + end + end + + def bounds + @bounds ||= GeoRuby::SimpleFeatures::Point.bounds(group_of_line.stop_areas.collect(&:geometry).compact) + end + + def ready? + Chouette::StopArea.bounds.present? + end + +end -- cgit v1.2.3 From 48842ac1197560b1b7f597e3e1be7c4d93f8d098 Mon Sep 17 00:00:00 2001 From: Michel Etienne Date: Tue, 6 Nov 2012 18:53:29 +0100 Subject: add access_points and access_links managment --- app/maps/access_point_map.rb | 62 +++++++++++++++++++++++ app/maps/style_map/access_points_style_map.rb | 39 ++++++++++++++ app/maps/style_map/edit_access_point_style_map.rb | 46 +++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 app/maps/access_point_map.rb create mode 100644 app/maps/style_map/access_points_style_map.rb create mode 100644 app/maps/style_map/edit_access_point_style_map.rb (limited to 'app/maps') diff --git a/app/maps/access_point_map.rb b/app/maps/access_point_map.rb new file mode 100644 index 000000000..ebb513ab0 --- /dev/null +++ b/app/maps/access_point_map.rb @@ -0,0 +1,62 @@ +class AccessPointMap < ApplicationMap + + attr_reader :access_point + + attr_accessor :editable + alias_method :editable?, :editable + + def initialize(access_point) + @access_point = access_point + 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.assign "edit_access_point_layer", kml_layer(access_point, { :default => editable? }, :style_map => StyleMap::EditAccessPointStyleMap.new(helpers).style_map) + page << map.add_layer(:edit_access_point_layer) + + + if editable? + page.assign "referential_projection", projection_type.present? ? projection("EPSG:" + projection_type) : JsVar.new("undefined") + # TODO virer ce code inline + page << < 8, :autoActivate => true)) + + end + + page << map.set_center(center.to_google.to_openlayers, 16, false, true) + end + end + + def projection_type + access_point.referential.projection_type + end + + def ready? + center.present? + end + + def center + access_point.geometry or access_point.default_position + end + +end diff --git a/app/maps/style_map/access_points_style_map.rb b/app/maps/style_map/access_points_style_map.rb new file mode 100644 index 000000000..c3bf2586f --- /dev/null +++ b/app/maps/style_map/access_points_style_map.rb @@ -0,0 +1,39 @@ +class StyleMap::AccessPointsStyleMap < StyleMap::GenericStyleMap + attr_accessor :style, :context + + 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/access_${accessType}.png"), + :graphicWidth => 25, + :graphicHeight => 25, + :graphicOpacity => 1, + :graphicXOffset => -12.5, + :graphicYOffset => -12.5 } + end + + def initialize(helpers,options = {}) + @helpers= helpers + @style = options[:style].present? ? default_style.merge(options[:style]) : default_style + end + + + def context + { + :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ", + :accessType => :" function(feature) { return feature.attributes.access_type.toLowerCase();} " + } + end + + def style_map + OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}) ) + end + +end diff --git a/app/maps/style_map/edit_access_point_style_map.rb b/app/maps/style_map/edit_access_point_style_map.rb new file mode 100644 index 000000000..83f9298e8 --- /dev/null +++ b/app/maps/style_map/edit_access_point_style_map.rb @@ -0,0 +1,46 @@ +class StyleMap::EditAccessPointStyleMap < StyleMap::GenericStyleMap + attr_accessor :style + + 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 + + def select_style + { :fontColor => "black", + :fontSize => "11px", + :fontWeight => "bold", + :pointRadius => 4, + :fillColor => "#86b41d", + :fillOpacity => 1, + :strokeColor => "black", + :strokeOpacity => 1, + :strokeWidth => 2 } + end + + def initialize(helpers, options = {}) + @helpers= helpers + @style = options[:style].present? ? default_style.merge(options[:style]) : default_style + end + + def context + { + :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(style, { :context => context}), :select => OpenLayers::Style.new(style.merge( select_style), { :context => context})) + end + +end -- cgit v1.2.3 From eeaf81e645de6f073b84b22b19e04ac63024399e Mon Sep 17 00:00:00 2001 From: Michel Etienne Date: Tue, 13 Nov 2012 16:18:13 +0100 Subject: add some features on maps --- app/maps/access_link_map.rb | 37 +++++++++++++++++++++++ app/maps/access_point_map.rb | 4 +++ app/maps/stop_area_map.rb | 39 +++++++++++++++++------- app/maps/style_map/access_link_style_map.rb | 43 +++++++++++++++++++++++++++ app/maps/style_map/access_points_style_map.rb | 27 ++++++++++++++--- app/maps/style_map/stop_areas_style_map.rb | 26 ++++++++++++++-- 6 files changed, 159 insertions(+), 17 deletions(-) create mode 100644 app/maps/access_link_map.rb create mode 100644 app/maps/style_map/access_link_style_map.rb (limited to 'app/maps') diff --git a/app/maps/access_link_map.rb b/app/maps/access_link_map.rb new file mode 100644 index 000000000..daf49738a --- /dev/null +++ b/app/maps/access_link_map.rb @@ -0,0 +1,37 @@ + +class AccessLinkMap < ApplicationMap + + attr_reader :access_link, :access_link_style + + def initialize(access_link, access_link_style = nil) + @access_link = access_link + @access_link_style = access_link_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.assign "access_points_layer", kml_layer([access_link.referential, access_link.access_point], :styleMap => StyleMap::AccessPointsStyleMap.new(helpers).style_map) + page << map.add_layer(:access_points_layer) + page.assign "stop_areas_layer", kml_layer([access_link.referential, access_link.stop_area], :styleMap => StyleMap::StopAreasStyleMap.new(helpers).style_map) + page << map.add_layer(:stop_areas_layer) + page << map.add_layer( kml_layer([access_link.referential, access_link.access_point, access_link], :styleMap => StyleMap::AccessLinkStyleMap.new(helpers).style_map)) + page << map.add_control( hover_control_display_name([:access_points_layer,:stop_areas_layer]) ) + page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds + end + end + + def ready? + Chouette::StopArea.bounds.present? + end + + def bounds + @bounds ||= GeoRuby::SimpleFeatures::Point.bounds([access_link.stop_area.geometry,access_link.access_point.geometry]) + end + +end diff --git a/app/maps/access_point_map.rb b/app/maps/access_point_map.rb index ebb513ab0..bf763e6c6 100644 --- a/app/maps/access_point_map.rb +++ b/app/maps/access_point_map.rb @@ -17,6 +17,8 @@ class AccessPointMap < ApplicationMap page << map.add_layer(google_hybrid) page << map.add_layer(google_satellite) + page.assign "parent_layer", kml_layer(access_point.stop_area, :style_map => StyleMap::StopAreasStyleMap.new(helpers).style_map) + page << map.add_layer(:parent_layer) page.assign "edit_access_point_layer", kml_layer(access_point, { :default => editable? }, :style_map => StyleMap::EditAccessPointStyleMap.new(helpers).style_map) page << map.add_layer(:edit_access_point_layer) @@ -41,6 +43,8 @@ class AccessPointMap < ApplicationMap EOF page << map.add_control(OpenLayers::Control::ModifyFeature.new(:edit_access_point_layer, :mode => 8, :autoActivate => true)) + else + page << map.add_control( hover_control_display_name(:parent_layer) ) end page << map.set_center(center.to_google.to_openlayers, 16, false, true) diff --git a/app/maps/stop_area_map.rb b/app/maps/stop_area_map.rb index 3e172c523..2fc329dce 100644 --- a/app/maps/stop_area_map.rb +++ b/app/maps/stop_area_map.rb @@ -17,15 +17,26 @@ class StopAreaMap < ApplicationMap 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(helpers).style_map) - page << map.add_layer(:edit_stop_area_layer) + if stop_area.children.present? + page.assign "children_layer", kml_layer(stop_area, { :children => true }, :style_map => StyleMap::StopAreasStyleMap.new(helpers).style_map) + page << map.add_layer(:children_layer) + end + if stop_area.routing_stops.present? + page.assign "routing_layer", kml_layer(stop_area, { :routing => true }, :style_map => StyleMap::StopAreasStyleMap.new(helpers).style_map) + page << map.add_layer(:routing_layer) + page << map.add_control( hover_control_display_name(:routing_layer) ) + page << map.zoom_to_extent(bounds.to_google.to_openlayers) if bounds + else + + 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) - if editable? - page.assign "referential_projection", projection_type.present? ? projection("EPSG:" + projection_type) : JsVar.new("undefined") - # TODO virer ce code inline - page << < 8, :autoActivate => true)) + page << map.add_control(OpenLayers::Control::ModifyFeature.new(:edit_stop_area_layer, :mode => 8, :autoActivate => true)) + elsif stop_area.children.present? + page << map.add_control( hover_control_display_name(:children_layer) ) - end + end - 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 end @@ -59,4 +73,9 @@ EOF stop_area.geometry or stop_area.default_position end + def bounds + # for ITL only + @bounds ||= GeoRuby::SimpleFeatures::Point.bounds(stop_area.routing_stops.collect(&:geometry).compact) + end + end diff --git a/app/maps/style_map/access_link_style_map.rb b/app/maps/style_map/access_link_style_map.rb new file mode 100644 index 000000000..07ef5952b --- /dev/null +++ b/app/maps/style_map/access_link_style_map.rb @@ -0,0 +1,43 @@ +class StyleMap::AccessLinkStyleMap < StyleMap::GenericStyleMap + attr_accessor :style + + def initialize(helpers,options = {}) + @helpers= helpers + @style = options[:style].present? ? default_style.merge(options[:style]) : default_style + end + + def default_style + { + :fontColor => "black", + :fontSize => "11px", + :fontWeight => "bold", + :labelAlign => "ct", + :labelXOffset => 0, + :labelYOffset => -10, + :strokeColor => "#000000", + :strokeOpacity => 1, + :strokeWidth => 3, + :strokeLineCap => "round", + :strokeDashstyle => "solid", + :externalGraphic => @helpers.assets_path_patch( "map/${positionType}.png"), + :graphicWidth => 36, + :graphicHeight => 36, + :graphicOpacity => 1, + :graphicXOffset => -18, + :graphicYOffset => -18, + :display => true + } + end + + def context + context = { + :positionType => :" function(feature) { if (feature.attributes.departure != undefined) { return 'departure'; } else { return 'arrival'; }} " + } + end + + def style_map + OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context})) + end + +end + diff --git a/app/maps/style_map/access_points_style_map.rb b/app/maps/style_map/access_points_style_map.rb index c3bf2586f..57cf8dfb3 100644 --- a/app/maps/style_map/access_points_style_map.rb +++ b/app/maps/style_map/access_points_style_map.rb @@ -1,5 +1,5 @@ class StyleMap::AccessPointsStyleMap < StyleMap::GenericStyleMap - attr_accessor :style, :context + attr_accessor :style, :context, :temporary def default_style raise "Helpers nil" if @helpers.nil? @@ -9,7 +9,24 @@ class StyleMap::AccessPointsStyleMap < StyleMap::GenericStyleMap :fontWeight => "bold", :labelAlign => "ct", :labelXOffset => 0, - :labelYOffset => -40, + :labelYOffset => -20, + :pointRadius => 1, + :externalGraphic => @helpers.assets_path_patch( "map/access_${accessType}.png"), + :graphicWidth => 25, + :graphicHeight => 25, + :graphicOpacity => 1, + :graphicXOffset => -12.5, + :graphicYOffset => -12.5 } + end + def temporary_style + raise "Helpers nil" if @helpers.nil? + {:label => "${label}", + :fontColor => "darkblue", + :fontSize => "12px", + :fontWeight => "bold", + :labelAlign => "ct", + :labelXOffset => 0, + :labelYOffset => -20, :pointRadius => 1, :externalGraphic => @helpers.assets_path_patch( "map/access_${accessType}.png"), :graphicWidth => 25, @@ -22,18 +39,20 @@ class StyleMap::AccessPointsStyleMap < StyleMap::GenericStyleMap def initialize(helpers,options = {}) @helpers= helpers @style = options[:style].present? ? default_style.merge(options[:style]) : default_style + @temporary = options[:style].present? ? temporary_style.merge(options[:style]) : temporary_style end def context { :label => :" function(feature) {if(feature.layer.map.getZoom() > 13) { return feature.attributes.name;} else {return '';}} ", - :accessType => :" function(feature) { return feature.attributes.access_type.toLowerCase();} " + :accessType => :" function(feature) { return feature.attributes.access_point_type.toLowerCase();} " } end def style_map - OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}) ) + OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}), + :temporary => OpenLayers::Style.new(temporary, { :context => context}) ) end end diff --git a/app/maps/style_map/stop_areas_style_map.rb b/app/maps/style_map/stop_areas_style_map.rb index 398748a22..f23b58136 100644 --- a/app/maps/style_map/stop_areas_style_map.rb +++ b/app/maps/style_map/stop_areas_style_map.rb @@ -1,5 +1,5 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap - attr_accessor :style, :context + attr_accessor :style, :context, :temporary def default_style raise "Helpers nil" if @helpers.nil? @@ -9,7 +9,7 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap :fontWeight => "bold", :labelAlign => "ct", :labelXOffset => 0, - :labelYOffset => -40, + :labelYOffset => -20, :pointRadius => 1, :externalGraphic => @helpers.assets_path_patch( "map/${areaType}.png"), :graphicWidth => 25, @@ -18,10 +18,29 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap :graphicXOffset => -12.5, :graphicYOffset => -12.5 } end + def temporary_style + raise "Helpers nil" if @helpers.nil? + {:label => "${label}", + :fontColor => "darkblue", + :fontSize => "12px", + :fontWeight => "bold", + :labelAlign => "ct", + :labelXOffset => 0, + :labelYOffset => -20, + :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(helpers,options = {}) @helpers= helpers @style = options[:style].present? ? default_style.merge(options[:style]) : default_style + @temporary = options[:style].present? ? temporary_style.merge(options[:style]) : temporary_style end @@ -33,7 +52,8 @@ class StyleMap::StopAreasStyleMap < StyleMap::GenericStyleMap end def style_map - OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}) ) + OpenLayers::StyleMap.new(:default => OpenLayers::Style.new(style, { :context => context}), + :temporary => OpenLayers::Style.new(temporary, { :context => context}) ) end end -- cgit v1.2.3