mapstatic 0.0.1

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.
@@ -0,0 +1,91 @@
1
+ require 'spec_helper'
2
+ describe Mapstatic::Map do
3
+
4
+ describe "the resulting image" do
5
+
6
+ it "is the correct image when got via lat lng" do
7
+ output_path = 'london.png'
8
+ map = Mapstatic::Map.new(
9
+ :lat => 51.515579783755925,
10
+ :lng => -0.1373291015625,
11
+ :zoom => 11,
12
+ :width => 256,
13
+ :height => 256,
14
+ :provider => 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
15
+ )
16
+ VCR.use_cassette('osm-london') do
17
+ map.render_map output_path
18
+ end
19
+ images_are_identical(output_path, 'spec/fixtures/maps/london.png')
20
+ File.delete output_path
21
+ end
22
+
23
+ it "is the correct image when got via bounding box" do
24
+ output_path = 'london.png'
25
+ map = Mapstatic::Map.new(
26
+ :bbox => "-0.2252197265625,51.4608524464555,-0.0494384765625,51.570241445811234",
27
+ :zoom => 11,
28
+ :provider => 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
29
+ )
30
+ VCR.use_cassette('osm-london') do
31
+ map.render_map output_path
32
+ end
33
+ images_are_identical(output_path, 'spec/fixtures/maps/london.png')
34
+ File.delete output_path
35
+ end
36
+
37
+
38
+ it "renders the correct image" do
39
+ output_path = 'thames.png'
40
+ map = Mapstatic::Map.new(
41
+ :provider => 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
42
+ :zoom => 12,
43
+ :bbox => '-0.169851,51.480829,0.027421,51.513658'
44
+ )
45
+ VCR.use_cassette('osm-thames') do
46
+ map.render_map output_path
47
+ end
48
+ images_are_identical(output_path, 'spec/fixtures/maps/thames.png')
49
+ File.delete output_path
50
+ end
51
+
52
+ def images_are_identical(image1, image2)
53
+ `compare -metric MAE #{image1} #{image2} null: 2>&1`.chomp.should == "0 (0)"
54
+ end
55
+ end
56
+
57
+ describe "image width" do
58
+
59
+ context "when calculated from the bounding box" do
60
+
61
+ it "doubles with each zoom level" do
62
+ bbox = '-11.29,49.78,2.45,59.71'
63
+
64
+ image = Mapstatic::Map.new( :zoom => 6, :bbox => bbox)
65
+ expect( image.width.to_i ).to eql( 625 )
66
+
67
+ image = Mapstatic::Map.new( :zoom => 7, :bbox => bbox)
68
+ expect( image.width.to_i ).to eql( 1250 )
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ describe "image height" do
75
+
76
+ context "when calculated from the bounding box" do
77
+
78
+ it "doubles with each zoom level" do
79
+ bbox = '-11.29,49.78,2.45,59.71'
80
+
81
+ image = Mapstatic::Map.new( :zoom => 2, :bbox => bbox)
82
+ expect( image.height.to_i ).to eql( 49 )
83
+
84
+ image = Mapstatic::Map.new( :zoom => 3, :bbox => bbox)
85
+ expect( image.height.to_i ).to eql( 98 )
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ end
@@ -0,0 +1,7 @@
1
+ require 'mapstatic'
2
+ require 'vcr'
3
+
4
+ VCR.configure do |c|
5
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
6
+ c.hook_into :webmock
7
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mapstatic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - James Croft
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mini_magick
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.6.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.6.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: faraday
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.8.8
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.8
46
+ - !ruby/object:Gem::Dependency
47
+ name: thor
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.18.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.18.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: awesome_print
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.0
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: typhoeus
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.6.6
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.6.6
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 2.13.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 2.13.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: vcr
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.7.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 2.7.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 1.15.2
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 1.15.2
142
+ description:
143
+ email: james@matchingnotes.com
144
+ executables:
145
+ - mapstatic
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - Gemfile
150
+ - Gemfile.lock
151
+ - spec/fixtures/maps/london.png
152
+ - spec/fixtures/maps/thames.png
153
+ - spec/fixtures/vcr_cassettes/osm-london.yml
154
+ - spec/fixtures/vcr_cassettes/osm-thames.yml
155
+ - spec/models/map_spec.rb
156
+ - spec/spec_helper.rb
157
+ - lib/mapstatic/cli.rb
158
+ - lib/mapstatic/conversion.rb
159
+ - lib/mapstatic/map.rb
160
+ - lib/mapstatic/tile.rb
161
+ - lib/mapstatic/tile_source.rb
162
+ - lib/mapstatic/version.rb
163
+ - lib/mapstatic.rb
164
+ - bin/mapstatic
165
+ homepage: http://matchingnotes.com
166
+ licenses: []
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ! '>='
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ! '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 1.8.24
186
+ signing_key:
187
+ specification_version: 3
188
+ summary: Static Map Generator
189
+ test_files: []