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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b7f7ff077bdc65127a96cb126451677f4f8317f
4
- data.tar.gz: 0fb0c8560df44020151c117670206c3593acc3a8
3
+ metadata.gz: 423a53002a18daf1de1ba8cd5aabdcc9c17fb112
4
+ data.tar.gz: 49824e15480ccfffd1c89e48573c8e8fb7957ea7
5
5
  SHA512:
6
- metadata.gz: c4100a81072048511823a1ba2cd7b3e10779b24f0493cb7fe22cdf4d1455c255fc2ef767f3b079268e4a1dc0a845500d3c16752ecf37d4a8e4065f3b6ae02967
7
- data.tar.gz: 75daabd87f3a99af524f38cd73806ad4c433efb39460d0e01f76992d4d4059131a6ba7f7141f96ad74103864d1547b03b810c9d78883d92f26ceecf502b141d6
6
+ metadata.gz: 8ee96b45449be505392177a1a893295e0c844728d48b762f28945c2cda30cb368ea48ce12d81dc30720adc740fa973125c70759fe3061592043b3e8c320ff069
7
+ data.tar.gz: a3f083c06a7c3781c23362bde338748cadaf53cc9b0e057b212110ad56e2442f0452f88d10b293bb99a8cf972d2d36242b070f93dc1f59a68014b084b560c7f6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- map_print (1.0.0)
4
+ map_print (1.0.1)
5
5
  mini_magick (~> 4.3)
6
6
  parallel (~> 1.6)
7
7
  prawn (~> 2.0)
@@ -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
- point_image = MiniMagick::Image.open(image_path)
81
- x -= point_image.width / 2
82
- y -= point_image.height / 2
83
-
84
- @image.composite(point_image) do |c|
85
- c.density 300
86
- c.geometry("+#{x}+#{y}")
87
- end.write @image.path
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
- "#{get_x(coord[0])},#{get_y(coord[1])}"
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
- "#{get_x(coord[0])},#{get_y(coord[1])}"
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|
@@ -1,3 +1,3 @@
1
1
  module MapPrint
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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.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-02-21 00:00:00.000000000 Z
11
+ date: 2016-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler