simple_mapnik 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/mapnik.yml +14 -0
- data/lib/simple_mapnik/config.rb +66 -16
- data/lib/simple_mapnik/version.rb +1 -1
- data/spec/lib/simple_mapnik/config_spec.rb +4 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 606d7bb053ce8d471f71f8d37763e932dbd3b292
|
4
|
+
data.tar.gz: 86b8767e26a6d7fa0f59873776a20ef951afa9e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f51f5b63d46d1f1d6626d2657aa5eb74b1bced00e7e9fd6281336bea38fa88e158a41aef72f61b4502fe9e375c36b5a6379e8e4ab356562bd3a6135478e3143
|
7
|
+
data.tar.gz: 1847a6420707c81f291553c8812cc36e588c98ce4f3d76d9b8a55a621d6c288b90e22675d86bbb0ce14d73d0ec323c61399b985ac6f16d71000ced5f2e653a91
|
data/config/mapnik.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
background_color: '#ffffff' # use '#ffffff00' for a transparent background
|
2
|
+
|
3
|
+
polygon_fill_color: '#fffff0'
|
4
|
+
|
5
|
+
line_stroke_color: '#483d8b'
|
6
|
+
line_stroke_width: '0.3'
|
7
|
+
|
8
|
+
marker_fill: '#0000ff'
|
9
|
+
marker_width: '5'
|
10
|
+
marker_height: '5'
|
11
|
+
marker_stroke_color: '#483d8b'
|
12
|
+
marker_stroke_width: '0.2'
|
13
|
+
marker_placement: 'point'
|
14
|
+
marker_allow_overlap-overlap: 'true'
|
data/lib/simple_mapnik/config.rb
CHANGED
@@ -1,52 +1,102 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module SimpleMapnik
|
4
5
|
class Config
|
5
|
-
|
6
|
-
attr_writer
|
6
|
+
attr_reader :settings
|
7
|
+
attr_writer :srs,
|
8
|
+
:type,
|
9
|
+
:background_color,
|
10
|
+
:polygon_fill_color,
|
11
|
+
:line_stroke_color,
|
12
|
+
:line_stroke_width,
|
13
|
+
:marker_fill,
|
14
|
+
:marker_width,
|
15
|
+
:marker_height,
|
16
|
+
:marker_stroke_color,
|
17
|
+
:marker_stroke_width
|
7
18
|
|
8
19
|
def initialize(path)
|
9
20
|
@path = path
|
21
|
+
@settings ||= File.exist?(config_file) ? YAML.load_file(config_file) : {}
|
10
22
|
end
|
11
23
|
|
12
|
-
def
|
13
|
-
|
24
|
+
def config_file
|
25
|
+
File.expand_path('../../config/mapnik.yml', File.dirname(__FILE__))
|
14
26
|
end
|
15
27
|
|
16
28
|
def srs
|
17
29
|
@srs ||= '+init=epsg:4326'
|
18
30
|
end
|
19
31
|
|
20
|
-
def
|
21
|
-
@
|
32
|
+
def type
|
33
|
+
@type ||= 'shape'
|
22
34
|
end
|
23
35
|
|
24
|
-
def
|
25
|
-
@
|
36
|
+
def background_color
|
37
|
+
@background_color ||= settings.fetch('background_color', '#483d8b')
|
26
38
|
end
|
27
39
|
|
28
|
-
def
|
29
|
-
@
|
40
|
+
def polygon_fill_color
|
41
|
+
@polygon_fill_color ||= settings.fetch('polygon_fill_color', '#fffff0')
|
30
42
|
end
|
31
43
|
|
32
|
-
def
|
33
|
-
@
|
44
|
+
def line_stroke_color
|
45
|
+
@line_stroke_color ||= settings.fetch('line_stroke_color', '#483d8b')
|
46
|
+
end
|
47
|
+
|
48
|
+
def line_stroke_width
|
49
|
+
@line_stroke_width ||= settings.fetch('line_stroke_width', '0.2')
|
50
|
+
end
|
51
|
+
|
52
|
+
def marker_fill
|
53
|
+
@marker_fill ||= settings.fetch('marker_fill', '#0000ff')
|
54
|
+
end
|
55
|
+
|
56
|
+
def marker_width
|
57
|
+
@marker_width ||= settings.fetch('marker_width', '5')
|
58
|
+
end
|
59
|
+
|
60
|
+
def marker_height
|
61
|
+
@marker_height ||= settings.fetch('marker_height', '5')
|
62
|
+
end
|
63
|
+
|
64
|
+
def marker_stroke_color
|
65
|
+
@marker_stroke_color ||= settings.fetch('marker_stroke_color', '#483d8b')
|
66
|
+
end
|
67
|
+
|
68
|
+
def marker_stroke_width
|
69
|
+
@marker_stroke_width ||= settings.fetch('marker_stroke_width', '0.2')
|
34
70
|
end
|
35
71
|
|
36
72
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
37
73
|
def xml
|
38
74
|
Nokogiri::XML::Builder.new do |xml|
|
39
|
-
xml.Map(srs: srs, 'background-color'
|
75
|
+
xml.Map(srs: srs, :'background-color' => background_color) do
|
40
76
|
xml.Style(name: 'style') do
|
41
77
|
xml.Rule() do
|
42
|
-
xml.
|
43
|
-
xml.
|
78
|
+
xml.Filter('[mapnik::geometry_type]=point')
|
79
|
+
xml.MarkersSymbolizer(
|
80
|
+
fill: marker_fill,
|
81
|
+
width: marker_width,
|
82
|
+
height: marker_height,
|
83
|
+
:'stroke-color' => marker_stroke_color,
|
84
|
+
:'stroke-width' => marker_stroke_width,
|
85
|
+
:'allow_overlap-overlap' => 'true'
|
86
|
+
)
|
87
|
+
end
|
88
|
+
xml.Rule() do
|
89
|
+
xml.PolygonSymbolizer(fill: polygon_fill_color)
|
90
|
+
xml.LineSymbolizer(
|
91
|
+
stroke: line_stroke_color,
|
92
|
+
smooth: '1.0',
|
93
|
+
:'stroke-width' => line_stroke_width)
|
44
94
|
end
|
45
95
|
end
|
46
96
|
xml.Layer(name: 'layer', srs: srs) do
|
47
97
|
xml.StyleName 'style'
|
48
98
|
xml.Datasource do
|
49
|
-
xml.Parameter(path, name: 'file')
|
99
|
+
xml.Parameter(@path, name: 'file')
|
50
100
|
xml.Parameter(type, name: 'type')
|
51
101
|
end
|
52
102
|
end
|
@@ -4,13 +4,12 @@ describe SimpleMapnik::Config do
|
|
4
4
|
subject { described_class.new('shapefile') }
|
5
5
|
|
6
6
|
describe '#xml' do
|
7
|
-
it 'has
|
7
|
+
it 'has layer rules' do
|
8
8
|
config = subject.xml
|
9
|
-
expect(config).to include('
|
9
|
+
expect(config).to include('MarkersSymbolizer')
|
10
|
+
expect(config).to include('PolygonSymbolizer')
|
11
|
+
expect(config).to include('LineSymbolizer')
|
10
12
|
expect(config).to include('+init=epsg:4326')
|
11
|
-
expect(config).to include('ivory')
|
12
|
-
expect(config).to include('darkslateblue')
|
13
|
-
expect(config).to include('stroke-width')
|
14
13
|
expect(config).to include('shape')
|
15
14
|
end
|
16
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_mapnik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eliot Jordan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- README.md
|
170
170
|
- Rakefile
|
171
171
|
- bin/mapnik_console
|
172
|
+
- config/mapnik.yml
|
172
173
|
- coveralls.yml
|
173
174
|
- lib/simple_mapnik.rb
|
174
175
|
- lib/simple_mapnik/api.rb
|