simple_mapnik 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_mapnik/config.rb +58 -0
- data/lib/simple_mapnik/version.rb +1 -1
- data/lib/simple_mapnik.rb +1 -0
- data/simple_mapnik.gemspec +1 -0
- data/spec/lib/simple_mapnik/config_spec.rb +17 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fde74f6c08431ecd79eadd9e53cb013c93f318e6
|
4
|
+
data.tar.gz: 67b3788a29f8a9e3fa08eff3b563292507f3affd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30332c347f933f7699f91bfb13bda27983ad9536b4e5719c6de30285f00c880fe63b7444819afc48e6f9aa1e9ebb0d0a33e8296783cfbdf3ce52e00608a6a441
|
7
|
+
data.tar.gz: 136498479b705627db8c8f7cf11d669f53c596fe595a011884b003d32b4c32523e2d249454ac3bd850474728466390513acf0b230368cd25de482f63d0776ac5
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module SimpleMapnik
|
4
|
+
class Config
|
5
|
+
attr_accessor :path
|
6
|
+
attr_writer :background_color, :srs, :polygon_fill, :stroke, :stroke_width
|
7
|
+
|
8
|
+
def initialize(path)
|
9
|
+
@path = path
|
10
|
+
end
|
11
|
+
|
12
|
+
def background_color
|
13
|
+
@background_color ||= 'white'
|
14
|
+
end
|
15
|
+
|
16
|
+
def srs
|
17
|
+
@srs ||= '+init=epsg:4326'
|
18
|
+
end
|
19
|
+
|
20
|
+
def polygon_fill
|
21
|
+
@polygon_fill ||= 'ivory'
|
22
|
+
end
|
23
|
+
|
24
|
+
def stroke
|
25
|
+
@stroke ||= 'darkslateblue'
|
26
|
+
end
|
27
|
+
|
28
|
+
def stroke_width
|
29
|
+
@stroke_width ||= '.3'
|
30
|
+
end
|
31
|
+
|
32
|
+
def type
|
33
|
+
@type ||= 'shape'
|
34
|
+
end
|
35
|
+
|
36
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
37
|
+
def xml
|
38
|
+
Nokogiri::XML::Builder.new do |xml|
|
39
|
+
xml.Map(srs: srs, 'background-color'.to_sym => background_color) do
|
40
|
+
xml.Style(name: 'style') do
|
41
|
+
xml.Rule() do
|
42
|
+
xml.PolygonSymbolizer(fill: polygon_fill)
|
43
|
+
xml.LineSymbolizer(stroke: stroke, 'stroke-width'.to_sym => stroke_width)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
xml.Layer(name: 'layer', srs: srs) do
|
47
|
+
xml.StyleName 'style'
|
48
|
+
xml.Datasource do
|
49
|
+
xml.Parameter(path, name: 'file')
|
50
|
+
xml.Parameter(type, name: 'type')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end.to_xml
|
55
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/simple_mapnik.rb
CHANGED
@@ -7,6 +7,7 @@ module SimpleMapnik
|
|
7
7
|
autoload :Coordinate, File.join(MAPNIK_BASE, 'coordinate')
|
8
8
|
autoload :Bounds, File.join(MAPNIK_BASE, 'bounds')
|
9
9
|
autoload :Api, File.join(MAPNIK_BASE, 'api')
|
10
|
+
autoload :Config, File.join(MAPNIK_BASE, 'config')
|
10
11
|
|
11
12
|
module FFI
|
12
13
|
def self.find_lib(lib)
|
data/simple_mapnik.gemspec
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SimpleMapnik::Config do
|
4
|
+
subject { described_class.new('shapefile') }
|
5
|
+
|
6
|
+
describe '#xml' do
|
7
|
+
it 'has style elements' do
|
8
|
+
config = subject.xml
|
9
|
+
expect(config).to include('background-color')
|
10
|
+
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
|
+
expect(config).to include('shape')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
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.5
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +173,7 @@ files:
|
|
159
173
|
- lib/simple_mapnik.rb
|
160
174
|
- lib/simple_mapnik/api.rb
|
161
175
|
- lib/simple_mapnik/bounds.rb
|
176
|
+
- lib/simple_mapnik/config.rb
|
162
177
|
- lib/simple_mapnik/coordinate.rb
|
163
178
|
- lib/simple_mapnik/map.rb
|
164
179
|
- lib/simple_mapnik/version.rb
|
@@ -176,6 +191,7 @@ files:
|
|
176
191
|
- spec/fixtures/sample/world_merc_license.txt
|
177
192
|
- spec/lib/simple_mapnik/api_spec.rb
|
178
193
|
- spec/lib/simple_mapnik/bounds_spec.rb
|
194
|
+
- spec/lib/simple_mapnik/config_spec.rb
|
179
195
|
- spec/lib/simple_mapnik/coordinate_spec.rb
|
180
196
|
- spec/lib/simple_mapnik/map_spec.rb
|
181
197
|
- spec/lib/simple_mapnik_spec.rb
|
@@ -217,6 +233,7 @@ test_files:
|
|
217
233
|
- spec/fixtures/sample/world_merc_license.txt
|
218
234
|
- spec/lib/simple_mapnik/api_spec.rb
|
219
235
|
- spec/lib/simple_mapnik/bounds_spec.rb
|
236
|
+
- spec/lib/simple_mapnik/config_spec.rb
|
220
237
|
- spec/lib/simple_mapnik/coordinate_spec.rb
|
221
238
|
- spec/lib/simple_mapnik/map_spec.rb
|
222
239
|
- spec/lib/simple_mapnik_spec.rb
|