lib/earth/locality/country/data_miner.rb in earth-0.11.13 vs lib/earth/locality/country/data_miner.rb in earth-0.11.14
- old
+ new
@@ -7,32 +7,25 @@
# http://www.iso.org/iso/list-en1-semic-3.txt
# http://unstats.un.org/unsd/methods/m49/m49alpha.htm
import "OpenGeoCode.org's Country Codes to Country Names list",
:url => 'http://opengeocode.org/download/countrynames.txt',
:format => :delimited,
- :delimiter => ';',
+ :delimiter => '; ',
:headers => false,
:skip => 22 do
key 'iso_3166_code', :field_number => 0
store 'iso_3166_alpha_3_code', :field_number => 1
store 'iso_3166_numeric_code', :field_number => 2
- store 'name', :field_number => 5 # romanized version
+ store 'name', :field_number => 5 # romanized version with utf-8 characters
end
- import "heating degree day data from WRI CAIT",
+ import "heating and cooling degree day data from WRI CAIT",
:url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdDN4MkRTSWtWRjdfazhRdWllTkVSMkE&output=csv',
:select => Proc.new { |record| record['country'] != 'European Union (27)' },
:errata => { :url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdDNSMUtCV0h4cUF4UnBKZlNkczlNbFE&output=csv' } do
key 'name', :field_name => 'country'
store 'heating_degree_days', :units => :degrees_celsius
- end
-
- import "cooling degree day data from WRI CAIT",
- :url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdDN4MkRTSWtWRjdfazhRdWllTkVSMkE&output=csv',
- :select => Proc.new { |record| record['country'] != 'European Union (27)' },
- :errata => { :url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdDNSMUtCV0h4cUF4UnBKZlNkczlNbFE&output=csv' } do
- key 'name', :field_name => 'country'
store 'cooling_degree_days', :units => :degrees_celsius
end
process "set Montenegro's heating and cooling degree days to the same as Serbia's" do
montenegro = Country.find 'ME'
@@ -140,16 +133,16 @@
process "Derive average hotel characteristics from CountryLodgingClass" do
find_each do |country|
if country.lodging_classes.any?
country.lodging_natural_gas_intensity = country.lodging_classes.weighted_average(:natural_gas_intensity)
- country.lodging_natural_gas_intensity_units = 'cubic_metres_per_room_night' # FIXME TODO derive this
+ country.lodging_natural_gas_intensity_units = 'cubic_metres_per_occupied_room_night' # FIXME TODO derive this
country.lodging_fuel_oil_intensity = country.lodging_classes.weighted_average(:fuel_oil_intensity)
- country.lodging_fuel_oil_intensity_units = 'gallons_per_room_night' # FIXME TODO derive this
+ country.lodging_fuel_oil_intensity_units = 'gallons_per_occupied_room_night' # FIXME TODO derive this
country.lodging_electricity_intensity = country.lodging_classes.weighted_average(:electricity_intensity)
- country.lodging_electricity_intensity_units = 'kilowatt_hours_per_room_night' # FIXME TODO derive this
+ country.lodging_electricity_intensity_units = 'kilowatt_hours_per_occupied_room_night' # FIXME TODO derive this
country.lodging_district_heat_intensity = country.lodging_classes.weighted_average(:district_heat_intensity)
- country.lodging_district_heat_intensity_units = 'megajoules_per_room_night' # FIXME TODO derive this
+ country.lodging_district_heat_intensity_units = 'megajoules_per_occupied_room_night' # FIXME TODO derive this
country.save!
end
end
end