Class: CartoCSSHelper::Scene
- Inherits:
-
Object
- Object
- CartoCSSHelper::Scene
- Defined in:
- lib/cartocss_helper/image_generator.rb
Overview
Defines and generates images for synthethic comparison it is mostly glue between renderer and generator of synthethic data files
Instance Attribute Summary collapse
-
#on_water ⇒ Object
readonly
Returns the value of attribute on_water.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#zlevel ⇒ Object
readonly
Returns the value of attribute zlevel.
Instance Method Summary collapse
- #flush_cache ⇒ Object
-
#get_image_filename(debug = false) ⇒ Object
TODO: misleading name - should be location.
-
#initialize(tags, zlevel, on_water, type, show_what_is_generated = false) ⇒ Scene
constructor
A new instance of Scene.
- #is_output_different(another_scene) ⇒ Object
- #is_output_identical(another_scene) ⇒ Object
- #on_water_string ⇒ Object
Constructor Details
#initialize(tags, zlevel, on_water, type, show_what_is_generated = false) ⇒ Scene
Returns a new instance of Scene.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cartocss_helper/image_generator.rb', line 16 def initialize(, zlevel, on_water, type, show_what_is_generated = false) @show_what_is_generated = show_what_is_generated raise 'tags not in hash' unless .respond_to?(:has_key?) @tags = @zlevel = zlevel @on_water = on_water @type = type if type == 'area' @tags['area'] = 'yes' @type = 'closed_way' end @generated_image_location = nil end |
Instance Attribute Details
#on_water ⇒ Object (readonly)
Returns the value of attribute on_water.
15 16 17 |
# File 'lib/cartocss_helper/image_generator.rb', line 15 def on_water @on_water end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
15 16 17 |
# File 'lib/cartocss_helper/image_generator.rb', line 15 def @tags end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/cartocss_helper/image_generator.rb', line 15 def type @type end |
#zlevel ⇒ Object (readonly)
Returns the value of attribute zlevel.
15 16 17 |
# File 'lib/cartocss_helper/image_generator.rb', line 15 def zlevel @zlevel end |
Instance Method Details
#flush_cache ⇒ Object
41 42 43 |
# File 'lib/cartocss_helper/image_generator.rb', line 41 def flush_cache File.delete(get_filename) end |
#get_image_filename(debug = false) ⇒ Object
TODO: misleading name - should be location
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cartocss_helper/image_generator.rb', line 51 def get_image_filename(debug = false) # TODO: misleading name - should be location lat = 0 lon = 20 lon = 0 if @on_water if @generated_image_location != nil return @generated_image_location if File.exist?(@generated_image_location) end description = "tags: #{@tags}, zlevel: #{@zlevel}, type: #{@type} #{on_water_string}" puts "generating: #{description}" if @show_what_is_generated generate_map(lat, lon, debug) unless File.exist?(@generated_image_location) && @generated_image_location != nil raise "get_image failed - #{description}. File <\n#{@generated_image_location}\n> was expected." end return @generated_image_location end |
#is_output_different(another_scene) ⇒ Object
30 31 32 33 |
# File 'lib/cartocss_helper/image_generator.rb', line 30 def is_output_different(another_scene) raise 'on_water mismatch' if @on_water != another_scene.on_water return !is_output_identical(another_scene) end |
#is_output_identical(another_scene) ⇒ Object
35 36 37 38 39 |
# File 'lib/cartocss_helper/image_generator.rb', line 35 def is_output_identical(another_scene) raise 'on_water mismatch' if @on_water != another_scene.on_water # Returns true if the contents of a file A and a file B are identical. return FileUtils.compare_file(get_image_filename, another_scene.get_image_filename) end |
#on_water_string ⇒ Object
45 46 47 48 49 |
# File 'lib/cartocss_helper/image_generator.rb', line 45 def on_water_string on_water_string = '' on_water_string = 'on_water' if @on_water return on_water_string end |