Class: GMS::Stitcher

Inherits:
Object
  • Object
show all
Defined in:
lib/google-map-stitch/stitcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, output_file = "map.png") ⇒ Stitcher

Returns a new instance of Stitcher.



8
9
10
11
# File 'lib/google-map-stitch/stitcher.rb', line 8

def initialize(dir, output_file="map.png")
  @dir = dir
  @output_file = output_file
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



6
7
8
# File 'lib/google-map-stitch/stitcher.rb', line 6

def dir
  @dir
end

#output_fileObject

Returns the value of attribute output_file.



6
7
8
# File 'lib/google-map-stitch/stitcher.rb', line 6

def output_file
  @output_file
end

Instance Method Details

#processObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/google-map-stitch/stitcher.rb', line 21

def process
  output = Magick::ImageList.new

  tiles.each do |row|
    column = Magick::ImageList.new
    row.sort.each do |file|
      puts "Combining #{file}"
      column.push(Magick::Image.read(file).first)
    end
    output.push(column.append(true))
  end
  output.append(false).write(@output_file)
end

#tilesObject



13
14
15
16
17
18
19
# File 'lib/google-map-stitch/stitcher.rb', line 13

def tiles
  Dir.glob(File.join(dir,"*")).sort.map do |path|
    Dir.glob(File.join(path,"*.png")).sort.map do |image|
      image
    end
  end
end