Last change
on this file since 16254 was
4955,
checked in by jonb, 12 years ago
|
mod_tile: Apache module and rendering daemon for serving OSM tiles
|
-
Property svn:executable set to
*
|
File size:
735 bytes
|
Line | |
---|
1 | #!/usr/bin/ruby |
---|
2 | require 'mysql' |
---|
3 | require 'date' |
---|
4 | require 'time' |
---|
5 | require 'fileutils' |
---|
6 | |
---|
7 | dbh = nil |
---|
8 | dbh = Mysql.real_connect('localhost', 'tile', 'tile', 'tile') |
---|
9 | dbh.query_with_result = false |
---|
10 | dbh.query("select x,y,z,data,created_at from tiles" ) |
---|
11 | res = dbh.use_result |
---|
12 | |
---|
13 | while row = res.fetch_hash do |
---|
14 | x = row['x'] |
---|
15 | y = row['y'] |
---|
16 | z = row['z'] |
---|
17 | created_at = Time.parse(row['created_at']) |
---|
18 | |
---|
19 | path = "/var/www/html/osm_tiles2/#{z}/#{x}" |
---|
20 | FileUtils.mkdir_p(path) |
---|
21 | |
---|
22 | print "x(#{x}) y(#{y}) z(#{z}), created_at(#{created_at.to_i})\n" |
---|
23 | |
---|
24 | f = File.new("#{path}/#{y}.png", "w") |
---|
25 | f.print row['data'] |
---|
26 | f.close |
---|
27 | File.utime(created_at,created_at,"#{path}/#{y}.png") |
---|
28 | end |
---|
29 | puts "Number of rows returned: #{res.num_rows}" |
---|
30 | |
---|
31 | res.free |
---|
Note: See
TracBrowser
for help on using the repository browser.