Class: SimpleMapnik::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_mapnik/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_colorObject



12
13
14
# File 'lib/simple_mapnik/config.rb', line 12

def background_color
  @background_color ||= 'white'
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/simple_mapnik/config.rb', line 5

def path
  @path
end

#polygon_fillObject



20
21
22
# File 'lib/simple_mapnik/config.rb', line 20

def polygon_fill
  @polygon_fill ||= 'ivory'
end

#srsObject



16
17
18
# File 'lib/simple_mapnik/config.rb', line 16

def srs
  @srs ||= '+init=epsg:4326'
end

#strokeObject



24
25
26
# File 'lib/simple_mapnik/config.rb', line 24

def stroke
  @stroke ||= 'darkslateblue'
end

#stroke_widthObject



28
29
30
# File 'lib/simple_mapnik/config.rb', line 28

def stroke_width
  @stroke_width ||= '.3'
end

Instance Method Details

#typeObject



32
33
34
# File 'lib/simple_mapnik/config.rb', line 32

def type
  @type ||= 'shape'
end

#xmlObject

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