Top Level Namespace
Defined Under Namespace
Classes: Tiler
Instance Method Summary collapse
-
#main ⇒ Object
Runs this as a script.
Instance Method Details
#main ⇒ Object
Runs this as a script
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/imagetiler.rb', line 134 def main OptionParser.accept(Range, /(\d+)\.\.(\d+)/) do |range,start,finish| Range.new(start.to_i,finish.to_i) end OptionParser.accept(Magick::Pixel,/(\d+),(\d+),(\d+),(\d+)/) do |pixel, r,g,b,a| Magick::Pixel.new(r.to_f,g.to_f,b.to_f,a.to_f) end = {} opts = OptionParser.new do |opts| opts. = "Image Tiler for Google Maps\nUsage: tile_image.rb [options] IMAGE_FILE \nExample: tile_image.rb -o ./tiles -z 11..12 -p 602,768,11,78,112,1.91827348 ./input_files/map.jpg" opts.separator "" opts.on("-o","--output OUTPUT_DIR","Directory where the tiles will be created") do |dir| [:output_dir] = dir end opts.on("-f","--format FORMAT","Image format in which to get the file (gif, jpeg, png...). Is jpg by default") do |format| [:format] = format end opts.on("-z","--zoom_levels ZOOM_RANGE",Range,"Range of zoom values at which the tiles must be generated. Is 0..4 by default") do |range| [:zoom_levels] = range end opts.on("-b","--background COLOR",Magick::Pixel,"Background color components. Is fully transparent par default") do |bg| [:bg_color] = bg end opts.on("-p","--prefix PREFIX","Prefix to file output. Is 'tile' by default") do |prefix| [:prefix] = prefix end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end opts.parse!(ARGV) #test the presence of all the options and exit with an error message error = [] error << "No output directory defined (-o,--output)" if [:output_dir].nil? error << "No input files defined" if ARGV.empty? unless error.empty? puts error * "\n" + "\n\n" puts opts exit end t = Tiler.new t.make_tiles(ARGV[0], ) # ignore all input files but first end |