Class: SimpleMapnik::Config
- Inherits:
-
Object
- Object
- SimpleMapnik::Config
- Defined in:
- lib/simple_mapnik/config.rb
Instance Attribute Summary collapse
- #background_color ⇒ Object
-
#path ⇒ Object
Returns the value of attribute path.
- #polygon_fill ⇒ Object
- #srs ⇒ Object
- #stroke ⇒ Object
- #stroke_width ⇒ Object
Instance Method Summary collapse
-
#initialize(path) ⇒ Config
constructor
A new instance of Config.
- #type ⇒ Object
-
#xml ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Constructor Details
#initialize(path) ⇒ Config
8 9 10 |
# File 'lib/simple_mapnik/config.rb', line 8 def initialize(path) @path = path end |
Instance Attribute Details
#background_color ⇒ Object
12 13 14 |
# File 'lib/simple_mapnik/config.rb', line 12 def background_color @background_color ||= 'white' end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/simple_mapnik/config.rb', line 5 def path @path end |
#polygon_fill ⇒ Object
20 21 22 |
# File 'lib/simple_mapnik/config.rb', line 20 def polygon_fill @polygon_fill ||= 'ivory' end |
#srs ⇒ Object
16 17 18 |
# File 'lib/simple_mapnik/config.rb', line 16 def srs @srs ||= '+init=epsg:4326' end |
#stroke ⇒ Object
24 25 26 |
# File 'lib/simple_mapnik/config.rb', line 24 def stroke @stroke ||= 'darkslateblue' end |
#stroke_width ⇒ Object
28 29 30 |
# File 'lib/simple_mapnik/config.rb', line 28 def stroke_width @stroke_width ||= '.3' end |
Instance Method Details
#type ⇒ Object
32 33 34 |
# File 'lib/simple_mapnik/config.rb', line 32 def type @type ||= 'shape' end |
#xml ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/simple_mapnik/config.rb', line 37 def xml Nokogiri::XML::Builder.new do |xml| xml.Map(srs: srs, 'background-color'.to_sym => background_color) do xml.Style(name: 'style') do xml.Rule() do xml.PolygonSymbolizer(fill: polygon_fill) xml.LineSymbolizer(stroke: stroke, 'stroke-width'.to_sym => stroke_width) end end xml.Layer(name: 'layer', srs: srs) do xml.StyleName 'style' xml.Datasource do xml.Parameter(path, name: 'file') xml.Parameter(type, name: 'type') end end end end.to_xml # rubocop:enable Metrics/AbcSize, Metrics/MethodLength end |