Class: GMS::Engine
- Inherits:
-
Object
- Object
- GMS::Engine
- Defined in:
- lib/google-map-stitch/engine.rb
Instance Attribute Summary collapse
-
#endX ⇒ Object
Returns the value of attribute endX.
-
#endY ⇒ Object
Returns the value of attribute endY.
-
#layer ⇒ Object
Returns the value of attribute layer.
-
#startX ⇒ Object
Returns the value of attribute startX.
-
#startY ⇒ Object
Returns the value of attribute startY.
-
#zoomLevel ⇒ Object
Returns the value of attribute zoomLevel.
Instance Method Summary collapse
-
#height ⇒ Object
total height in tiles.
-
#imageURL(x, y, z, layer = @layer) ⇒ Object
build a url for a google image.
-
#initialize(config) ⇒ Engine
constructor
A new instance of Engine.
-
#pixelHeight ⇒ Object
total height in pixels.
-
#pixelWidth ⇒ Object
total width in pixels.
-
#printHeight(dpi = 300) ⇒ Object
total height printed @ 300 dpi (in inches).
-
#printWidth(dpi = 300) ⇒ Object
total width printed @ 300 dpi (in inches).
- #status ⇒ Object
-
#tileCount ⇒ Object
total number of tiles to download.
-
#tiles ⇒ Object
list all tiles.
-
#width ⇒ Object
total width in tiles.
Constructor Details
#initialize(config) ⇒ Engine
Returns a new instance of Engine.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/google-map-stitch/engine.rb', line 6 def initialize(config) @zoomLevel = config[:zoomLevel]||2 # two is the minimum zoom level @zoomLevel = 2 if config[:zoomLevel] < 2 # if all starting and ending coords are not defined, then # assume we want the whole map if ![:startX,:endX,:startY,:endY].all? { |key| config.has_key?(key) } @startX = 0 @endX = 2**config[:zoomLevel]-1 @startY = 0 @endY = 2**config[:zoomLevel]-1 else @startX = config[:startX] @endX = config[:endX] @startY = config[:startY] @endY = config[:endY] end # allow the downloaded layer to be customized @layer = config[:layerID] || "m@195000000" status end |
Instance Attribute Details
#endX ⇒ Object
Returns the value of attribute endX.
4 5 6 |
# File 'lib/google-map-stitch/engine.rb', line 4 def endX @endX end |
#endY ⇒ Object
Returns the value of attribute endY.
4 5 6 |
# File 'lib/google-map-stitch/engine.rb', line 4 def endY @endY end |
#layer ⇒ Object
Returns the value of attribute layer.
4 5 6 |
# File 'lib/google-map-stitch/engine.rb', line 4 def layer @layer end |
#startX ⇒ Object
Returns the value of attribute startX.
4 5 6 |
# File 'lib/google-map-stitch/engine.rb', line 4 def startX @startX end |
#startY ⇒ Object
Returns the value of attribute startY.
4 5 6 |
# File 'lib/google-map-stitch/engine.rb', line 4 def startY @startY end |
#zoomLevel ⇒ Object
Returns the value of attribute zoomLevel.
4 5 6 |
# File 'lib/google-map-stitch/engine.rb', line 4 def zoomLevel @zoomLevel end |
Instance Method Details
#height ⇒ Object
total height in tiles
39 40 41 |
# File 'lib/google-map-stitch/engine.rb', line 39 def height @endY-@startY end |
#imageURL(x, y, z, layer = @layer) ⇒ Object
build a url for a google image
69 70 71 |
# File 'lib/google-map-stitch/engine.rb', line 69 def imageURL(x, y, z, layer=@layer) "http://mt1.google.com/vt/lyrs=#{layer}&hl=en&x=#{x}&s=&y=#{y}&z=#{z.to_s}" end |
#pixelHeight ⇒ Object
total height in pixels
49 50 51 |
# File 'lib/google-map-stitch/engine.rb', line 49 def pixelHeight height*256 end |
#pixelWidth ⇒ Object
total width in pixels
44 45 46 |
# File 'lib/google-map-stitch/engine.rb', line 44 def pixelWidth width*256 end |
#printHeight(dpi = 300) ⇒ Object
total height printed @ 300 dpi (in inches)
59 60 61 |
# File 'lib/google-map-stitch/engine.rb', line 59 def printHeight(dpi=300) (pixelHeight.to_f/dpi).round(2) end |
#printWidth(dpi = 300) ⇒ Object
total width printed @ 300 dpi (in inches)
54 55 56 |
# File 'lib/google-map-stitch/engine.rb', line 54 def printWidth(dpi=300) (pixelWidth.to_f/dpi).round(2) end |
#status ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/google-map-stitch/engine.rb', line 73 def status puts "\Google Map Stitch Configuration" puts "=======================================================" puts "Starting Coord: #{@startX},#{@endX}" puts "Ending Coord: #{@startY},#{@endY}" puts "Zoom Level: #{@zoomLevel}" puts "Total Tiles to Download: #{tileCount.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse}" puts "Final Image Size @ 72DPI #{pixelWidth}x#{pixelHeight}" puts "Final Print Size @ 300DPI (Inches): #{printWidth}\"x#{printHeight}\"" puts "Final Print Size @ 300DPI (Feet): #{(printWidth/12).round(2)}'x#{(printHeight/12).round(2)}'" puts "=======================================================\n\n" end |
#tileCount ⇒ Object
total number of tiles to download
64 65 66 |
# File 'lib/google-map-stitch/engine.rb', line 64 def tileCount width*height end |
#tiles ⇒ Object
list all tiles
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/google-map-stitch/engine.rb', line 87 def tiles @startY.upto(@endY).map.with_index do |y, c| @startX.upto(@endX).map.with_index do |x, r| { :url => imageURL(x,y,@zoomLevel,@layer), :dir => "r#{"%06d" % r}", :file => "c#{"%06d" % c}.png" } end end.flatten end |
#width ⇒ Object
total width in tiles
34 35 36 |
# File 'lib/google-map-stitch/engine.rb', line 34 def width @endX-@startX end |