A quick way to get tiled images 'untiled'.

A way to get tlled images 'untiled', using RMagick. An experiment on OpenStreetMap tiles for Pacifico Yokoyama.

The code

# untile.rb
require 'rubygems'
require 'RMagick'
require 'open-uri'

root_url = 'http://a.tile.openstreetmap.org/18/'
x0 = 232749
y0 = 103422
cx = 6
cy = 6
d = 256

img = Magick::Image.new(d * cx, d * cy)
cx.times {|i|
  cy.times {|j|
    path = "#{x0 + i}-#{y0 + j}.png"
    unless File.exist?(path)
      url = "#{root_url}#{x0 + i}/#{y0 + j}.png"
      File.open(path, 'w') {|w| w.print(open(url).read)}
    end
    img.composite!(Magick::Image.read(path)[0], 
                   i * d, j * d, Magick::AddCompositeOp)
  }
}
img.write('untiled.png')

You get an 'untiled' image titled untiled.png. It's such easy. Now you wont get lost approaching venue for G-spatial expo (http://www.g-expo.jp/en/index.html).