class Gpx2png::Base
Attributes
layers[RW]
simulate_download[RW]
Simulate download of tiles
Public Class Methods
logger()
click to toggle source
# File lib/gpx2png/base.rb, line 120 def self.logger @@logger = Logger.new(STDOUT) unless defined? @@logger return @@logger end
logger=(_logger)
click to toggle source
# File lib/gpx2png/base.rb, line 116 def self.logger=(_logger) @@logger = _logger end
new()
click to toggle source
# File lib/gpx2png/base.rb, line 12 def initialize @layers = Array.new _layer = Layer.new _layer.parent = self @layers << _layer @single_layer = true @zoom = 9 self.class.logger.debug("Init, default zoom #{@zoom.to_s.green}") end
simulate_download=(b)
click to toggle source
# File lib/gpx2png/base.rb, line 102 def self.simulate_download=(b) logger.debug("Simulate tiles download for class #{self.to_s.blue}") if b @@simulate_download = b end
Public Instance Methods
add(lat, lon)
click to toggle source
# File lib/gpx2png/base.rb, line 44 def add(lat, lon) if @single_layer # add coord to first layer _layer = @layers.first _layer.add(lat, lon) else # I'm afraid Dave I can't do that self.class.logger.fatal("After you've added first layer you can use coords only from layers") raise StandardError end end
add_layer(_layer_options)
click to toggle source
# File lib/gpx2png/base.rb, line 24 def add_layer(_layer_options) if @single_layer self.class.logger.debug("Created #{"first".to_s.red} layer") # turn off single layer version @single_layer = false # set layer options for first layer and return it _layer = @layers.first _layer.options = _layer_options return _layer else # create new layer with options, add to list and return _layer = Layer.new _layer.parent = self _layer.options = _layer_options @layers << _layer self.class.logger.debug("Created layer, count: #{@layers.size.to_s.red}") return _layer end end
color(_color)
click to toggle source
# File lib/gpx2png/base.rb, line 68 def color(_color) if @single_layer # add coord to first layer _layer = @layers.first _layer.color = _color else # I'm afraid Dave I can't do that self.class.fatal("After you've added first layer you have to use layers") raise StandardError end end
coords=(_coords)
click to toggle source
# File lib/gpx2png/base.rb, line 56 def coords=(_coords) if @single_layer # add coord to first layer _layer = @layers.first _layer.coords = _coords else # I'm afraid Dave I can't do that self.class.fatal("After you've added first layer you can use coords only from layers") raise StandardError end end
destroy()
click to toggle source
# File lib/gpx2png/base.rb, line 111 def destroy @r.destroy self.class.logger.debug "Image destroyed" end
fixed_size(_width, _height)
click to toggle source
Create image with fixed size
# File lib/gpx2png/base.rb, line 81 def fixed_size(_width, _height) @fixed_width = _width @fixed_height = _height self.class.logger.debug("Map image fixed dimension set #{@fixed_width.to_s.red} x #{@fixed_height.to_s.red}") true end
simulate_download?()
click to toggle source
# File lib/gpx2png/base.rb, line 107 def simulate_download? return true if true == self.simulate_download or (defined? @@simulate_download and true == @@simulate_download) end
zoom()
click to toggle source
# File lib/gpx2png/base.rb, line 93 def zoom @zoom end
zoom=(_zoom)
click to toggle source
# File lib/gpx2png/base.rb, line 88 def zoom=(_zoom) self.class.logger.debug("Map zoom set #{_zoom.to_s.red}") @zoom = _zoom end