mapnik_legendary 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -13
- data/lib/mapnik_legendary.rb +14 -2
- data/lib/mapnik_legendary/docwriter.rb +1 -1
- data/lib/mapnik_legendary/geometry.rb +5 -4
- data/lib/mapnik_legendary/tags.rb +4 -1
- data/lib/mapnik_legendary/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -9,25 +9,16 @@
|
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
|
-
|
12
|
+
You can install the gem from rubygems:
|
13
13
|
|
14
|
-
`
|
14
|
+
`gem install mapnik_legendary`
|
15
15
|
|
16
|
-
|
16
|
+
Alternatively, you can add the gem to your project's Gemfile
|
17
17
|
|
18
|
-
|
19
|
-
gem build mapnik_legendary.gemspec
|
20
|
-
gem install mapnik_legendary-0.x.x.gem
|
21
|
-
```
|
18
|
+
`gem mapnik_legendary`
|
22
19
|
|
23
20
|
## Running
|
24
21
|
|
25
|
-
To run locally, without installing a gem, run:
|
26
|
-
|
27
|
-
`ruby -Ilib bin/mapnik_legendary`
|
28
|
-
|
29
|
-
If you've installed the gem, `mapnik_legendary` will be in your path.
|
30
|
-
|
31
22
|
For full options, run
|
32
23
|
|
33
24
|
`mapnik_legendary -h`
|
data/lib/mapnik_legendary.rb
CHANGED
@@ -33,7 +33,7 @@ module MapnikLegendary
|
|
33
33
|
map.layers.each do |l|
|
34
34
|
layer_styles.push(name: l.name,
|
35
35
|
style: l.styles.map { |s| s } # get them out of the collection
|
36
|
-
|
36
|
+
)
|
37
37
|
end
|
38
38
|
|
39
39
|
docs = Docwriter.new
|
@@ -79,7 +79,19 @@ module MapnikLegendary
|
|
79
79
|
i += 1
|
80
80
|
filename = File.join(Dir.pwd, 'output', "#{id}-#{zoom}-#{i}.png")
|
81
81
|
end
|
82
|
-
|
82
|
+
begin
|
83
|
+
map.render_to_file(filename, 'png256:t=2')
|
84
|
+
rescue RuntimeError => e
|
85
|
+
r = /^CSV Plugin: no attribute '(?<key>[^']*)'/
|
86
|
+
match_data = r.match(e.message)
|
87
|
+
if match_data
|
88
|
+
log.error "'#{match_data[:key]}' is a key needed for the '#{feature.name}' feature."
|
89
|
+
log.error "Try adding '#{match_data[:key]}' to the extra_tags list."
|
90
|
+
next
|
91
|
+
else
|
92
|
+
raise e
|
93
|
+
end
|
94
|
+
end
|
83
95
|
docs.add File.basename(filename), feature.description
|
84
96
|
end
|
85
97
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module MapnikLegendary
|
4
|
+
# A wkt-based geometry that can be used for the legend feature.
|
4
5
|
class Geometry
|
5
6
|
def initialize(type, zoom, map)
|
6
7
|
proj = Mapnik::Projection.new(map.srs)
|
@@ -19,10 +20,10 @@ module MapnikLegendary
|
|
19
20
|
when 'point75' then "POINT(#{@max_x * 0.5} #{@max_y * 0.75})"
|
20
21
|
when 'polygon' then "POLYGON((0 0, #{@max_x} 0, #{@max_x} #{@max_y}, 0 #{@max_y}, 0 0))"
|
21
22
|
when 'linestring-with-gap' then "MULTILINESTRING((0 0, #{@max_x * 0.45} #{@max_y * 0.45}),(#{@max_x * 0.55} #{@max_y * 0.55},#{@max_x} #{@max_y}))"
|
22
|
-
when 'polygon-with-hole' then "POLYGON((#{0.7 * @max_x} #{0.2 * @max_y}, #{0.9 * @max_x} #{0.9 * @max_y}"
|
23
|
-
", #{0.3 * @max_x} #{0.8 * @max_y}, #{0.2 * @max_x} #{0.4 * @max_y}"
|
24
|
-
", #{0.7 * @max_y} #{0.2 * @max_y}),( #{0.4 * @max_x} #{0.6 * @max_y}"
|
25
|
-
", #{0.7 * @max_x} #{0.7 * @max_y}, #{0.6 * @max_x} #{0.4 * @max_y}"
|
23
|
+
when 'polygon-with-hole' then "POLYGON((#{0.7 * @max_x} #{0.2 * @max_y}, #{0.9 * @max_x} #{0.9 * @max_y}" \
|
24
|
+
", #{0.3 * @max_x} #{0.8 * @max_y}, #{0.2 * @max_x} #{0.4 * @max_y}" \
|
25
|
+
", #{0.7 * @max_y} #{0.2 * @max_y}),( #{0.4 * @max_x} #{0.6 * @max_y}" \
|
26
|
+
", #{0.7 * @max_x} #{0.7 * @max_y}, #{0.6 * @max_x} #{0.4 * @max_y}" \
|
26
27
|
", #{0.4 * @max_x} #{0.6 * @max_y}))"
|
27
28
|
else "LINESTRING(0 0, #{@max_x} #{@max_y})"
|
28
29
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module MapnikLegendary
|
4
|
+
# convenience methods for handling tags
|
4
5
|
class Tags
|
6
|
+
# Merges a list of extra keys into an existing hash of tags.
|
7
|
+
# The extra keys are each given a null value.
|
5
8
|
def self.merge_nulls(tags, extras)
|
6
9
|
tags = {} if tags.nil?
|
7
10
|
extras = [] if extras.nil?
|
8
|
-
Hash[extras.map { |t| [t,
|
11
|
+
Hash[extras.map { |t| [t, nil] }].merge(tags)
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mapnik_legendary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-08-
|
12
|
+
date: 2015-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mapnik
|