Class: Gpx2png::Osm

Inherits:
OsmBase show all
Defined in:
lib/gpx2png/osm.rb

Direct Known Subclasses

Landscape, OpenCycle, Outdoors, Transport, Ump

Constant Summary collapse

DEFAULT_RENDERER =
:rmagick

Constants inherited from OsmBase

Gpx2png::OsmBase::TILE_HEIGHT, Gpx2png::OsmBase::TILE_WIDTH

Constants included from Calculations::OsmClassMethods

Calculations::OsmClassMethods::TILE_HEIGHT, Calculations::OsmClassMethods::TILE_WIDTH

Constants included from Calculations::OsmInstanceMethods

Calculations::OsmInstanceMethods::TILE_HEIGHT, Calculations::OsmInstanceMethods::TILE_WIDTH

Instance Attribute Summary collapse

Attributes included from Calculations::OsmInstanceMethods

#bitmap_point_x_max, #bitmap_point_x_min, #bitmap_point_y_max, #bitmap_point_y_min, #lat_max, #lat_min, #lon_max, #lon_min, #tile_x_distance, #tile_y_distance

Attributes inherited from Base

#layers, #simulate_download

Instance Method Summary collapse

Methods inherited from OsmBase

licence_string, url, url_convert

Methods included from Calculations::OsmClassMethods

#calc_zoom, #convert, #point_on_absolute_image, #point_on_image, #reverse_convert

Methods included from Calculations::OsmInstanceMethods

#auto_zoom_for, #calculate_for_crop, #calculate_for_crop_with_auto_zoom, #download_and_join_tiles, #expand_map, #initial_calculations

Methods inherited from Base

#add, #add_layer, #color, #coords=, #destroy, #fixed_size, logger, logger=, simulate_download=, #simulate_download?, #zoom, #zoom=

Methods included from Calculations::BaseClassMethods

#deg2rad, #rad2deg

Methods included from Calculations::BaseInstanceMethods

#calculate_minmax_latlon, #enlarge_border_coords

Constructor Details

#initializeOsm

Returns a new instance of Osm.



10
11
12
13
14
15
# File 'lib/gpx2png/osm.rb', line 10

def initialize
  super
  @renderer ||= DEFAULT_RENDERER
  @r = nil
  @markers = Array.new
end

Instance Attribute Details

#rendererObject

Returns the value of attribute renderer.



8
9
10
# File 'lib/gpx2png/osm.rb', line 8

def renderer
  @renderer
end

#renderer_optionsObject

Returns the value of attribute renderer_options.



37
38
39
# File 'lib/gpx2png/osm.rb', line 37

def renderer_options
  @renderer_options
end

Instance Method Details

#add_marker(p) ⇒ Object



27
28
29
# File 'lib/gpx2png/osm.rb', line 27

def add_marker(p)
  @markers << p
end

#renderObject



31
32
33
34
35
# File 'lib/gpx2png/osm.rb', line 31

def render
  setup_renderer
  initial_calculations
  download_and_join_tiles
end

#save(filename) ⇒ Object



17
18
19
20
# File 'lib/gpx2png/osm.rb', line 17

def save(filename)
  render
  @r.save(filename)
end

#setup_rendererObject

Get proper renderer class



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gpx2png/osm.rb', line 40

def setup_renderer
  case @renderer
    when :chunky_png
      require 'gpx2png/renderers/chunky_png_renderer'
      @r = ChunkyPngRenderer.new(@renderer_options)
    when :rmagick
      require 'gpx2png/renderers/rmagick_renderer'
      @r = RmagickRenderer.new(@renderer_options)
      @r.licence_string = self.class.licence_string
    else
      raise ArgumentError
  end
end

#to_pngObject



22
23
24
25
# File 'lib/gpx2png/osm.rb', line 22

def to_png
  render
  @r.to_png
end