map_print 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/map_print/core.rb +1 -0
- data/lib/map_print/geo_json_handler.rb +24 -10
- data/lib/map_print/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 423a53002a18daf1de1ba8cd5aabdcc9c17fb112
|
4
|
+
data.tar.gz: 49824e15480ccfffd1c89e48573c8e8fb7957ea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ee96b45449be505392177a1a893295e0c844728d48b762f28945c2cda30cb368ea48ce12d81dc30720adc740fa973125c70759fe3061592043b3e8c320ff069
|
7
|
+
data.tar.gz: a3f083c06a7c3781c23362bde338748cadaf53cc9b0e057b212110ad56e2442f0452f88d10b293bb99a8cf972d2d36242b070f93dc1f59a68014b084b560c7f6
|
data/Gemfile.lock
CHANGED
data/lib/map_print/core.rb
CHANGED
@@ -34,6 +34,7 @@ module MapPrint
|
|
34
34
|
raise ParameterError.new("Please indicate the northeast point for the map ({map: {ne: {lat: -29.980172, lng: -52.959305}}})") unless @map[:ne] && @map[:ne][:lat] && @map[:ne][:lng]
|
35
35
|
raise ParameterError.new("Please indicate the zoom level for the map ({map: {zoom: 9})") unless @map[:zoom]
|
36
36
|
raise ParameterError.new("Please indicate layers to be printed for the map ({map: {layers: [{type: 'osm'}]})") unless @map[:layers].is_a?(Array)
|
37
|
+
Logger.warn 'Found geojson property defined outside map, it must be inside the map property' if @map[:geojson].nil? && args[:geojson]
|
37
38
|
end
|
38
39
|
|
39
40
|
def print(output_path)
|
@@ -77,14 +77,18 @@ module MapPrint
|
|
77
77
|
x = get_x(point['coordinates'][0])
|
78
78
|
y = get_y(point['coordinates'][1])
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
80
|
+
if 0 <= x && x <= @width && 0 <= y && y <= @height
|
81
|
+
point_image = MiniMagick::Image.open(image_path)
|
82
|
+
x -= point_image.width / 2
|
83
|
+
y -= point_image.height / 2
|
84
|
+
|
85
|
+
@image.composite(point_image) do |c|
|
86
|
+
c.density 300
|
87
|
+
c.geometry("+#{x}+#{y}")
|
88
|
+
end.write @image.path
|
89
|
+
else
|
90
|
+
Logger.warn "Point #{image_path} is outside the map's boundaries!\n#{point.inspect}"
|
91
|
+
end
|
88
92
|
end
|
89
93
|
|
90
94
|
def line_string(geometry, properties)
|
@@ -92,7 +96,12 @@ module MapPrint
|
|
92
96
|
coords = geometry['coordinates']
|
93
97
|
coords = coords.first if coords.first.first.is_a?(Array)
|
94
98
|
points = coords.map do |coord|
|
95
|
-
|
99
|
+
x = get_x(coord[0])
|
100
|
+
y = get_y(coord[1])
|
101
|
+
if 0 <= x && x <= @width && 0 <= y && y <= @height
|
102
|
+
Logger.warn "Line coordinate outside map's boundaries!\ngeometry: #{geometry.inspect}\nproperties: #{properties.inspect}"
|
103
|
+
end
|
104
|
+
"#{x},#{y}"
|
96
105
|
end
|
97
106
|
|
98
107
|
draw_command = (0..(points.length - 2)).map do |i|
|
@@ -110,7 +119,12 @@ module MapPrint
|
|
110
119
|
coords = geometry['coordinates']
|
111
120
|
coords = coords.first if coords.first.first.is_a?(Array)
|
112
121
|
points = coords.map do |coord|
|
113
|
-
|
122
|
+
x = get_x(coord[0])
|
123
|
+
y = get_y(coord[1])
|
124
|
+
if 0 <= x && x <= @width && 0 <= y && y <= @height
|
125
|
+
Logger.warn "Polygon coordinate outside map's boundaries!\ngeometry: #{geometry.inspect}\nproperties: #{properties.inspect}"
|
126
|
+
end
|
127
|
+
"#{x},#{y}"
|
114
128
|
end
|
115
129
|
|
116
130
|
@image.combine_options do |c|
|
data/lib/map_print/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: map_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Fast
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|