Class: WrfLibrary::JsonConverter::WrfStationJsonConverter

Inherits:
BaseStationJsonConverter show all
Defined in:
lib/wrf_library/json_converter/wrf_station_converter.rb

Overview

Abstract child class to add the relevant additional informations to the the JSON putput

Direct Known Subclasses

HourlyJsonConverter, WrfJsonConverter

Instance Attribute Summary

Attributes inherited from BaseStationJsonConverter

#data

Instance Method Summary collapse

Methods inherited from BaseStationJsonConverter

#convert, #generate_data_values, #generate_meta_hash, #generate_station_hash, #initialize

Constructor Details

This class inherits a constructor from WrfLibrary::JsonConverter::BaseStationJsonConverter

Instance Method Details

#add_additionsHash (private)

implementation of the abstract parent method. In addition to the data stored by the parent class, the wrf data also stores data of the considered grid point

Returns:

  • (Hash)

    the key-value hash for the json output



15
16
17
18
19
20
21
# File 'lib/wrf_library/json_converter/wrf_station_converter.rb', line 15

def add_additions
    additions = Hash.new()
    additions[:grid_point] = generate_grid_data(@data..grid_data)
    additions[:grid_coordinates] = 
      generate_grid_coordinates(@data..grid_data)
    return additions
end

#generate_grid_coordinates(grid_point) ⇒ Hash (private)

method to generate a json Hash for the representation of a grid coordinate

Parameters:

  • grid_point (GridPoint)

    the given grid coordinate

Returns:

  • (Hash)

    the key-value hash for the json output



36
37
38
39
40
41
# File 'lib/wrf_library/json_converter/wrf_station_converter.rb', line 36

def generate_grid_coordinates(grid_point)
  grid_coordinates = Hash.new()
  grid_coordinates[:grid_coordinates] = { :x => grid_point.grid_coordinates.x, 
                                          :y => grid_point.grid_coordinates.y }
  return grid_coordinates
end

#generate_grid_data(grid_point) ⇒ Hash (private)

method to generate a json Hash for the representation of a grid point

Parameters:

  • grid_point (GridPoint)

    the given grid point

Returns:

  • (Hash)

    the key-value hash for the json output



26
27
28
29
30
31
# File 'lib/wrf_library/json_converter/wrf_station_converter.rb', line 26

def generate_grid_data(grid_point)
  grid_data = Hash.new()
  grid_data[:grid_point] = { :x => grid_point.grid_point.x, 
                             :y => grid_point.grid_point.y }
  return grid_data
end