google-maps-stitch-bin 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tiler/tile.rb +11 -3
- metadata +1 -1
data/lib/tiler/tile.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require "tempfile"
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
2
5
|
class Tile
|
3
6
|
|
4
7
|
attr_reader :x, :y, :z
|
@@ -17,12 +20,17 @@ class Tile
|
|
17
20
|
end
|
18
21
|
|
19
22
|
def download
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
|
24
|
+
uri = URI.parse(remote_url)
|
25
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
26
|
+
resp = http.get(uri.path)
|
27
|
+
file = Tempfile.new("x_#{x}_y_#{y}_z_#{z}", Dir.tmpdir, 'wb+')
|
28
|
+
file.write(resp.body)
|
29
|
+
file.flush
|
23
30
|
puts "downloaded #{remote_url} to #{file.path}"
|
24
31
|
@file = file
|
25
32
|
@local_file_name = file.path
|
33
|
+
file
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|