earth-ruby19 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +5 -0
- data/Gemfile.lock +138 -0
- data/LICENSE +20 -0
- data/README.markdown +38 -0
- data/lib/earth.rb +146 -0
- data/lib/earth/active_record_ext.rb +9 -0
- data/lib/earth/air.rb +13 -0
- data/lib/earth/air/aircraft.rb +21 -0
- data/lib/earth/air/aircraft/data_miner.rb +184 -0
- data/lib/earth/air/aircraft_class.rb +10 -0
- data/lib/earth/air/aircraft_class/data_miner.rb +42 -0
- data/lib/earth/air/aircraft_manufacturer.rb +9 -0
- data/lib/earth/air/aircraft_manufacturer/data_miner.rb +20 -0
- data/lib/earth/air/airline.rb +16 -0
- data/lib/earth/air/airline/data_miner.rb +57 -0
- data/lib/earth/air/airport.rb +44 -0
- data/lib/earth/air/airport/data_miner.rb +80 -0
- data/lib/earth/air/data_miner.rb +15 -0
- data/lib/earth/air/flight_configuration.rb +7 -0
- data/lib/earth/air/flight_configuration/data_miner.rb +16 -0
- data/lib/earth/air/flight_distance_class.rb +7 -0
- data/lib/earth/air/flight_distance_class/data_miner.rb +16 -0
- data/lib/earth/air/flight_domesticity.rb +6 -0
- data/lib/earth/air/flight_domesticity/data_miner.rb +57 -0
- data/lib/earth/air/flight_fuel_type.rb +12 -0
- data/lib/earth/air/flight_fuel_type/data_miner.rb +12 -0
- data/lib/earth/air/flight_propulsion.rb +7 -0
- data/lib/earth/air/flight_propulsion/data_miner.rb +16 -0
- data/lib/earth/air/flight_seat_class.rb +12 -0
- data/lib/earth/air/flight_seat_class/data_miner.rb +36 -0
- data/lib/earth/air/flight_segment.rb +29 -0
- data/lib/earth/air/flight_segment/data_miner.rb +330 -0
- data/lib/earth/air/flight_service.rb +7 -0
- data/lib/earth/air/flight_service/data_miner.rb +16 -0
- data/lib/earth/all.rb +11 -0
- data/lib/earth/automobile.rb +8 -0
- data/lib/earth/automobile/automobile_fuel_type.rb +18 -0
- data/lib/earth/automobile/automobile_fuel_type/data_miner.rb +45 -0
- data/lib/earth/automobile/automobile_make.rb +14 -0
- data/lib/earth/automobile/automobile_make/data_miner.rb +68 -0
- data/lib/earth/automobile/automobile_make_fleet_year.rb +15 -0
- data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +29 -0
- data/lib/earth/automobile/automobile_make_year.rb +14 -0
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +45 -0
- data/lib/earth/automobile/automobile_model.rb +14 -0
- data/lib/earth/automobile/automobile_model/data_miner.rb +38 -0
- data/lib/earth/automobile/automobile_model_year.rb +15 -0
- data/lib/earth/automobile/automobile_model_year/data_miner.rb +51 -0
- data/lib/earth/automobile/automobile_size_class.rb +14 -0
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +43 -0
- data/lib/earth/automobile/automobile_variant.rb +17 -0
- data/lib/earth/automobile/automobile_variant/data_miner.rb +460 -0
- data/lib/earth/automobile/data_miner.rb +8 -0
- data/lib/earth/base.rb +7 -0
- data/lib/earth/bus.rb +1 -0
- data/lib/earth/bus/bus_class.rb +19 -0
- data/lib/earth/bus/bus_class/data_miner.rb +41 -0
- data/lib/earth/bus/data_miner.rb +1 -0
- data/lib/earth/conversions_ext.rb +45 -0
- data/lib/earth/data_miner.rb +10 -0
- data/lib/earth/diet.rb +2 -0
- data/lib/earth/diet/data_miner.rb +2 -0
- data/lib/earth/diet/diet_class.rb +15 -0
- data/lib/earth/diet/diet_class/data_miner.rb +36 -0
- data/lib/earth/diet/food_group.rb +17 -0
- data/lib/earth/diet/food_group/data_miner.rb +26 -0
- data/lib/earth/fuel.rb +2 -0
- data/lib/earth/fuel/data_miner.rb +2 -0
- data/lib/earth/fuel/fuel_price.rb +13 -0
- data/lib/earth/fuel/fuel_price/data_miner.rb +20 -0
- data/lib/earth/fuel/fuel_type.rb +18 -0
- data/lib/earth/fuel/fuel_type/data_miner.rb +37 -0
- data/lib/earth/hospitality.rb +1 -0
- data/lib/earth/hospitality/data_miner.rb +1 -0
- data/lib/earth/hospitality/lodging_class.rb +9 -0
- data/lib/earth/hospitality/lodging_class/data_miner.rb +30 -0
- data/lib/earth/industry.rb +10 -0
- data/lib/earth/industry/industry.rb +23 -0
- data/lib/earth/industry/industry_product.rb +22 -0
- data/lib/earth/industry/industry_product_line.rb +20 -0
- data/lib/earth/industry/industry_sector.rb +20 -0
- data/lib/earth/industry/merchant.rb +18 -0
- data/lib/earth/industry/merchant_category.rb +22 -0
- data/lib/earth/industry/merchant_category_industry.rb +20 -0
- data/lib/earth/industry/product_line.rb +22 -0
- data/lib/earth/industry/product_line_industry_product.rb +20 -0
- data/lib/earth/industry/sector.rb +19 -0
- data/lib/earth/inflectors.rb +9 -0
- data/lib/earth/locality.rb +10 -0
- data/lib/earth/locality/census_division.rb +22 -0
- data/lib/earth/locality/census_division/data_miner.rb +64 -0
- data/lib/earth/locality/census_region.rb +13 -0
- data/lib/earth/locality/census_region/data_miner.rb +17 -0
- data/lib/earth/locality/climate_division.rb +17 -0
- data/lib/earth/locality/climate_division/data_miner.rb +20 -0
- data/lib/earth/locality/country.rb +13 -0
- data/lib/earth/locality/country/data_miner.rb +19 -0
- data/lib/earth/locality/data_miner.rb +10 -0
- data/lib/earth/locality/egrid_region.rb +15 -0
- data/lib/earth/locality/egrid_region/data_miner.rb +35 -0
- data/lib/earth/locality/egrid_subregion.rb +16 -0
- data/lib/earth/locality/egrid_subregion/data_miner.rb +65 -0
- data/lib/earth/locality/petroleum_administration_for_defense_district.rb +13 -0
- data/lib/earth/locality/petroleum_administration_for_defense_district/data_miner.rb +21 -0
- data/lib/earth/locality/state.rb +22 -0
- data/lib/earth/locality/state/data_miner.rb +37 -0
- data/lib/earth/locality/urbanity.rb +10 -0
- data/lib/earth/locality/urbanity/data_miner.rb +15 -0
- data/lib/earth/locality/zip_code.rb +23 -0
- data/lib/earth/locality/zip_code/data_miner.rb +43 -0
- data/lib/earth/pet.rb +4 -0
- data/lib/earth/pet/breed.rb +15 -0
- data/lib/earth/pet/breed/data_miner.rb +25 -0
- data/lib/earth/pet/breed_gender.rb +14 -0
- data/lib/earth/pet/breed_gender/data_miner.rb +21 -0
- data/lib/earth/pet/data_miner.rb +4 -0
- data/lib/earth/pet/gender.rb +10 -0
- data/lib/earth/pet/gender/data_miner.rb +13 -0
- data/lib/earth/pet/species.rb +40 -0
- data/lib/earth/pet/species/data_miner.rb +42 -0
- data/lib/earth/rail.rb +1 -0
- data/lib/earth/rail/data_miner.rb +1 -0
- data/lib/earth/rail/rail_class.rb +16 -0
- data/lib/earth/rail/rail_class/data_miner.rb +36 -0
- data/lib/earth/residence.rb +8 -0
- data/lib/earth/residence/air_conditioner_use.rb +13 -0
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +22 -0
- data/lib/earth/residence/clothes_machine_use.rb +10 -0
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +28 -0
- data/lib/earth/residence/data_miner.rb +8 -0
- data/lib/earth/residence/dishwasher_use.rb +10 -0
- data/lib/earth/residence/dishwasher_use/data_miner.rb +28 -0
- data/lib/earth/residence/residence_appliance.rb +16 -0
- data/lib/earth/residence/residence_appliance/data_miner.rb +20 -0
- data/lib/earth/residence/residence_class.rb +16 -0
- data/lib/earth/residence/residence_class/data_miner.rb +15 -0
- data/lib/earth/residence/residence_fuel_price.rb +18 -0
- data/lib/earth/residence/residence_fuel_price/data_miner.rb +200 -0
- data/lib/earth/residence/residence_fuel_type.rb +32 -0
- data/lib/earth/residence/residence_fuel_type/data_miner.rb +18 -0
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +39 -0
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +283 -0
- data/spec/lib/earth_spec.rb +25 -0
- data/spec/spec_helper.rb +11 -0
- data/vendor/geokit-rails/CHANGELOG.rdoc +46 -0
- data/vendor/geokit-rails/MIT-LICENSE +20 -0
- data/vendor/geokit-rails/README.markdown +561 -0
- data/vendor/geokit-rails/Rakefile +18 -0
- data/vendor/geokit-rails/about.yml +9 -0
- data/vendor/geokit-rails/assets/api_keys_template +61 -0
- data/vendor/geokit-rails/init.rb +1 -0
- data/vendor/geokit-rails/install.rb +14 -0
- data/vendor/geokit-rails/lib/geokit-rails.rb +24 -0
- data/vendor/geokit-rails/lib/geokit-rails/acts_as_mappable.rb +456 -0
- data/vendor/geokit-rails/lib/geokit-rails/adapters/abstract.rb +31 -0
- data/vendor/geokit-rails/lib/geokit-rails/adapters/mysql.rb +22 -0
- data/vendor/geokit-rails/lib/geokit-rails/adapters/postgresql.rb +22 -0
- data/vendor/geokit-rails/lib/geokit-rails/adapters/sqlserver.rb +43 -0
- data/vendor/geokit-rails/lib/geokit-rails/defaults.rb +22 -0
- data/vendor/geokit-rails/lib/geokit-rails/geocoder_control.rb +16 -0
- data/vendor/geokit-rails/lib/geokit-rails/ip_geocode_lookup.rb +46 -0
- data/vendor/geokit-rails/test/acts_as_mappable_test.rb +474 -0
- data/vendor/geokit-rails/test/boot.rb +25 -0
- data/vendor/geokit-rails/test/database.yml +20 -0
- data/vendor/geokit-rails/test/fixtures/companies.yml +7 -0
- data/vendor/geokit-rails/test/fixtures/custom_locations.yml +54 -0
- data/vendor/geokit-rails/test/fixtures/locations.yml +54 -0
- data/vendor/geokit-rails/test/fixtures/mock_addresses.yml +17 -0
- data/vendor/geokit-rails/test/fixtures/mock_families.yml +2 -0
- data/vendor/geokit-rails/test/fixtures/mock_houses.yml +9 -0
- data/vendor/geokit-rails/test/fixtures/mock_organizations.yml +5 -0
- data/vendor/geokit-rails/test/fixtures/mock_people.yml +5 -0
- data/vendor/geokit-rails/test/fixtures/stores.yml +0 -0
- data/vendor/geokit-rails/test/ip_geocode_lookup_test.rb +77 -0
- data/vendor/geokit-rails/test/models/company.rb +3 -0
- data/vendor/geokit-rails/test/models/custom_location.rb +12 -0
- data/vendor/geokit-rails/test/models/location.rb +4 -0
- data/vendor/geokit-rails/test/models/mock_address.rb +4 -0
- data/vendor/geokit-rails/test/models/mock_family.rb +3 -0
- data/vendor/geokit-rails/test/models/mock_house.rb +3 -0
- data/vendor/geokit-rails/test/models/mock_organization.rb +4 -0
- data/vendor/geokit-rails/test/models/mock_person.rb +4 -0
- data/vendor/geokit-rails/test/models/store.rb +3 -0
- data/vendor/geokit-rails/test/schema.rb +60 -0
- data/vendor/geokit-rails/test/tasks.rake +31 -0
- data/vendor/geokit-rails/test/test_helper.rb +23 -0
- metadata +476 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
class IndustryProduct < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :naics_product_code
|
4
|
+
|
5
|
+
has_many :product_line_industry_products, :foreign_key => 'naics_product_code'
|
6
|
+
|
7
|
+
belongs_to :industry, :foreign_key => 'naics_code'
|
8
|
+
|
9
|
+
def self.schema_definition
|
10
|
+
lambda do
|
11
|
+
string 'naics_product_code'
|
12
|
+
string 'description'
|
13
|
+
float 'value'
|
14
|
+
string 'value_units'
|
15
|
+
string 'naics_code'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
data_miner do
|
20
|
+
IndustryProduct.define_schema(self)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class IndustryProductLine < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :row_hash
|
4
|
+
|
5
|
+
belongs_to :industry, :foreign_key => 'naics_code'
|
6
|
+
belongs_to :product_line, :foreign_key => 'ps_code'
|
7
|
+
|
8
|
+
def self.schema_definition
|
9
|
+
lambda do
|
10
|
+
string 'row_hash'
|
11
|
+
string 'naics_code'
|
12
|
+
float 'ratio'
|
13
|
+
string 'ps_code'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
data_miner do
|
18
|
+
IndustryProductLine.define_schema(self)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class IndustrySector < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :row_hash
|
4
|
+
|
5
|
+
belongs_to :industry, :foreign_key => 'naics_code'
|
6
|
+
belongs_to :sector, :foreign_key => 'io_code'
|
7
|
+
|
8
|
+
def self.schema_definition
|
9
|
+
lambda do
|
10
|
+
string 'row_hash'
|
11
|
+
string 'naics_code'
|
12
|
+
float 'ratio'
|
13
|
+
string 'io_code'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
data_miner do
|
18
|
+
IndustrySector.define_schema(self)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Merchant < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :id
|
4
|
+
|
5
|
+
belongs_to :merchant_category, :foreign_key => 'mcc'
|
6
|
+
|
7
|
+
def self.schema_definition
|
8
|
+
lambda do
|
9
|
+
string 'id'
|
10
|
+
string 'name'
|
11
|
+
string 'mcc'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
data_miner do
|
16
|
+
Merchant.define_schema(self)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class MerchantCategory < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :mcc
|
4
|
+
|
5
|
+
has_many :merchant_category_industries, :foreign_key => 'mcc'
|
6
|
+
has_many :industries, :through => :merchant_category_industries
|
7
|
+
|
8
|
+
def name
|
9
|
+
description
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.schema_definition
|
13
|
+
lambda do
|
14
|
+
string 'mcc'
|
15
|
+
string 'description'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
data_miner do
|
20
|
+
MerchantCategory.define_schema(self)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class MerchantCategoryIndustry < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :row_hash
|
4
|
+
|
5
|
+
belongs_to :merchant_category, :foreign_key => 'mcc'
|
6
|
+
belongs_to :industry, :foreign_key => 'naics_code'
|
7
|
+
|
8
|
+
def self.schema_definition
|
9
|
+
lambda do
|
10
|
+
string 'row_hash'
|
11
|
+
string 'mcc'
|
12
|
+
float 'ratio'
|
13
|
+
string 'naics_code'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
data_miner do
|
18
|
+
MerchantCategoryIndustry.define_schema(self)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class ProductLine < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :ps_code
|
4
|
+
|
5
|
+
has_many :industry_product_lines, :foreign_key => 'ps_code'
|
6
|
+
|
7
|
+
has_many :product_line_industry_products, :foreign_key => 'ps_code'
|
8
|
+
has_many :industry_products, :through => :product_line_industry_products
|
9
|
+
|
10
|
+
def self.schema_definition
|
11
|
+
lambda do
|
12
|
+
string 'ps_code'
|
13
|
+
string 'description'
|
14
|
+
string 'broadline' # FIXME TODO do we need this?
|
15
|
+
string 'parent' # FIXME TODO do we need this?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
data_miner do
|
20
|
+
ProductLine.define_schema(self)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ProductLineIndustryProduct < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :row_hash
|
4
|
+
|
5
|
+
belongs_to :product_line, :foreign_key => 'ps_code'
|
6
|
+
belongs_to :industry_product, :foreign_key => 'naics_product_code'
|
7
|
+
|
8
|
+
def self.schema_definition
|
9
|
+
lambda do
|
10
|
+
string 'row_hash'
|
11
|
+
string 'ps_code'
|
12
|
+
float 'ratio'
|
13
|
+
string 'naics_product_code'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
data_miner do
|
18
|
+
ProductLineIndustryProduct.define_schema(self)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Sector < ActiveRecord::Base
|
2
|
+
extend Earth::Base
|
3
|
+
set_primary_key :io_code
|
4
|
+
|
5
|
+
has_many :industry_sectors, :foreign_key => 'io_code'
|
6
|
+
|
7
|
+
def self.schema_definition
|
8
|
+
lambda do
|
9
|
+
string 'io_code'
|
10
|
+
string 'description'
|
11
|
+
float 'value'
|
12
|
+
string 'value_units'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
data_miner do
|
17
|
+
Sector.define_schema(self)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
ActiveSupport::Inflector.inflections do |inflect|
|
2
|
+
inflect.uncountable %w(aircraft aircraft Aircraft airline_aircraft AirlineAircraft)
|
3
|
+
inflect.uncountable 'commons'
|
4
|
+
inflect.uncountable 'food'
|
5
|
+
inflect.uncountable 'shelter'
|
6
|
+
inflect.uncountable 'transportation'
|
7
|
+
inflect.uncountable 'press_coverage'
|
8
|
+
inflect.irregular 'foot', 'feet'
|
9
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'earth/locality/census_division'
|
2
|
+
require 'earth/locality/census_region'
|
3
|
+
require 'earth/locality/climate_division'
|
4
|
+
require 'earth/locality/country'
|
5
|
+
require 'earth/locality/egrid_region'
|
6
|
+
require 'earth/locality/egrid_subregion'
|
7
|
+
require 'earth/locality/petroleum_administration_for_defense_district'
|
8
|
+
require 'earth/locality/state'
|
9
|
+
require 'earth/locality/urbanity'
|
10
|
+
require 'earth/locality/zip_code'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CensusDivision < ActiveRecord::Base
|
2
|
+
set_primary_key :number
|
3
|
+
|
4
|
+
belongs_to :census_region, :foreign_key => 'census_region_number'
|
5
|
+
has_many :states, :foreign_key => 'census_division_number'
|
6
|
+
has_many :zip_codes, :through => :states
|
7
|
+
has_many :climate_divisions, :through => :states
|
8
|
+
has_many :residential_energy_consumption_survey_responses, :foreign_key => 'census_division_number'
|
9
|
+
|
10
|
+
falls_back_on :meeting_building_natural_gas_intensity => 0.011973,
|
11
|
+
:meeting_building_fuel_oil_intensity => 0.0037381,
|
12
|
+
:meeting_building_electricity_intensity => 0.072444,
|
13
|
+
:meeting_building_district_heat_intensity => 3458.7
|
14
|
+
|
15
|
+
data_miner do
|
16
|
+
tap "Brighter Planet's sanitized census divisions", Earth.taps_server
|
17
|
+
|
18
|
+
process "pull dependencies" do
|
19
|
+
run_data_miner_on_belongs_to_associations
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
CensusDivision.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
integer 'number'
|
5
|
+
string 'name'
|
6
|
+
string 'census_region_name'
|
7
|
+
integer 'census_region_number'
|
8
|
+
float 'meeting_building_natural_gas_intensity'
|
9
|
+
string 'meeting_building_natural_gas_intensity_units'
|
10
|
+
float 'meeting_building_fuel_oil_intensity'
|
11
|
+
string 'meeting_building_fuel_oil_intensity_units'
|
12
|
+
float 'meeting_building_electricity_intensity'
|
13
|
+
string 'meeting_building_electricity_intensity_units'
|
14
|
+
float 'meeting_building_district_heat_intensity'
|
15
|
+
string 'meeting_building_district_heat_intensity_units'
|
16
|
+
float 'lodging_building_natural_gas_intensity'
|
17
|
+
string 'lodging_building_natural_gas_intensity_units'
|
18
|
+
float 'lodging_building_fuel_oil_intensity'
|
19
|
+
string 'lodging_building_fuel_oil_intensity_units'
|
20
|
+
float 'lodging_building_electricity_intensity'
|
21
|
+
string 'lodging_building_electricity_intensity_units'
|
22
|
+
float 'lodging_building_district_heat_intensity'
|
23
|
+
string 'lodging_building_district_heat_intensity_units'
|
24
|
+
end
|
25
|
+
|
26
|
+
process 'Define some unit conversions' do
|
27
|
+
Conversions.register :hundred_cubic_feet_per_square_foot_hour, :cubic_metres_per_square_metre_hour, 30.48
|
28
|
+
Conversions.register :gallons_per_square_foot_hour, :litres_per_square_metre_hour, 40.745833
|
29
|
+
Conversions.register :kilowatt_hours_per_square_foot_hour, :kilowatt_hours_per_square_metre_hour, 10.76391
|
30
|
+
Conversions.register :thousand_btu_per_square_foot_hour, :joules_per_square_metre_hour, 11_356_527
|
31
|
+
Conversions.register :hundred_cubic_feet_per_room_night, :cubic_metres_per_room_night, 2.8317
|
32
|
+
Conversions.register :gallons_per_room_night, :litres_per_room_night, 3.7854
|
33
|
+
Conversions.register :thousand_btu_per_room_night, :joules_per_room_night, 1_055_056
|
34
|
+
end
|
35
|
+
|
36
|
+
import 'the U.S. Census Geographic Terms and Definitions',
|
37
|
+
:url => 'http://www.census.gov/popest/geographic/codes02.csv',
|
38
|
+
:skip => 9,
|
39
|
+
:select => lambda { |row| row['Division'].to_s.strip != 'X' and row['FIPS CODE STATE'].to_s.strip == 'X'} do
|
40
|
+
key 'number', :field_name => 'Division'
|
41
|
+
store 'name', :field_name => 'Name'
|
42
|
+
store 'census_region_number', :field_name => 'Region'
|
43
|
+
store 'census_region_name', :field_name => 'Region', :dictionary => { :input => 'number', :output => 'name', :url => 'http://data.brighterplanet.com/census_regions.csv' }
|
44
|
+
end
|
45
|
+
|
46
|
+
import 'meeting building fuel intensities calculated from CBECS 2003',
|
47
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGotdjgtUEk0eUU0R3lxM1hHdlF1V0E&hl=en&output=csv' do
|
48
|
+
key 'number', :field_name => 'census_division'
|
49
|
+
store 'meeting_building_natural_gas_intensity', :from_units => :hundred_cubic_feet_per_square_foot_hour, :to_units => :cubic_metres_per_square_metre_hour
|
50
|
+
store 'meeting_building_fuel_oil_intensity', :from_units => :gallons_per_square_foot_hour, :to_units => :litres_per_square_metre_hour
|
51
|
+
store 'meeting_building_electricity_intensity', :from_units => :kilowatt_hours_per_square_foot_hour, :to_units => :kilowatt_hours_per_square_metre_hour
|
52
|
+
store 'meeting_building_district_heat_intensity', :from_units => :thousand_btu_per_square_foot_hour, :to_units => :joules_per_square_metre_hour
|
53
|
+
end
|
54
|
+
|
55
|
+
import 'lodging building fuel intensities calculated from CBECS 2003',
|
56
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHZ1QjdNTGVpbWxmZDVLbjlpTHlFVHc&hl=en&output=csv' do
|
57
|
+
key 'number', :field_name => 'census_division'
|
58
|
+
store 'lodging_building_natural_gas_intensity', :from_units => :hundred_cubic_feet_per_room_night, :to_units => :cubic_metres_per_room_night
|
59
|
+
store 'lodging_building_fuel_oil_intensity', :from_units => :gallons_per_room_night, :to_units => :litres_per_room_night
|
60
|
+
store 'lodging_building_electricity_intensity', :units_field_name => 'lodging_building_electricity_intensity_units'
|
61
|
+
store 'lodging_building_district_heat_intensity', :from_units => :thousand_btu_per_room_night, :to_units => :joules_per_room_night
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CensusRegion < ActiveRecord::Base
|
2
|
+
set_primary_key :number
|
3
|
+
|
4
|
+
has_many :census_divisions, :foreign_key => 'census_region_number'
|
5
|
+
has_many :states, :through => :census_divisions
|
6
|
+
# has_many :climate_divisions, :through => :census_divisions
|
7
|
+
# has_many :zip_codes, :through => :census_divisions
|
8
|
+
has_many :residential_energy_consumption_survey_responses, :foreign_key => 'census_region_number'
|
9
|
+
|
10
|
+
data_miner do
|
11
|
+
tap "Brighter Planet's sanitized census regions", Earth.taps_server
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
CensusRegion.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
integer 'number'
|
5
|
+
string 'name'
|
6
|
+
end
|
7
|
+
|
8
|
+
import 'the U.S. Census Geographic Terms and Definitions',
|
9
|
+
:url => 'http://www.census.gov/popest/geographic/codes02.csv',
|
10
|
+
:skip => 9,
|
11
|
+
:select => lambda { |row| row['Region'].to_i > 0 and row['Division'].to_s.strip == 'X'} do
|
12
|
+
key 'number', :field_name => 'Region'
|
13
|
+
store 'name', :field_name => 'Name'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ClimateDivision < ActiveRecord::Base
|
2
|
+
set_primary_key :name
|
3
|
+
|
4
|
+
has_many :zip_codes, :foreign_key => 'climate_division_name'
|
5
|
+
belongs_to :state, :foreign_key => 'state_postal_abbreviation'
|
6
|
+
|
7
|
+
RADIUS = 750
|
8
|
+
|
9
|
+
data_miner do
|
10
|
+
tap "Brighter Planet's sanitized climate divisions", Earth.taps_server
|
11
|
+
|
12
|
+
process "pull dependencies" do
|
13
|
+
run_data_miner_on_belongs_to_associations
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
ClimateDivision.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
float 'heating_degree_days'
|
6
|
+
float 'cooling_degree_days'
|
7
|
+
string 'state_postal_abbreviation'
|
8
|
+
end
|
9
|
+
|
10
|
+
import "a list of climate divisions and their average heating and cooling degree days",
|
11
|
+
:url => 'http://static.brighterplanet.com/science/data/climate/climate_divisions/climate_divisions.csv' do
|
12
|
+
key 'name'
|
13
|
+
store 'heating_degree_days'
|
14
|
+
store 'cooling_degree_days'
|
15
|
+
store 'state_postal_abbreviation'
|
16
|
+
end
|
17
|
+
#associate :state, :key => :state_postal_abbreviation, :foreign_key => :postal_abbreviation
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Country.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'iso_3166_code'
|
5
|
+
string 'name'
|
6
|
+
end
|
7
|
+
|
8
|
+
import 'the official ISO country list',
|
9
|
+
:url => 'http://www.iso.org/iso/list-en1-semic-3.txt',
|
10
|
+
:skip => 2,
|
11
|
+
:headers => false,
|
12
|
+
:delimiter => ';',
|
13
|
+
:encoding => 'ISO-8859-1' do
|
14
|
+
key 'iso_3166_code', :field_number => 1
|
15
|
+
store 'name', :field_number => 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'earth/locality/census_division/data_miner'
|
2
|
+
require 'earth/locality/census_region/data_miner'
|
3
|
+
require 'earth/locality/climate_division/data_miner'
|
4
|
+
require 'earth/locality/country/data_miner'
|
5
|
+
require 'earth/locality/egrid_region/data_miner'
|
6
|
+
require 'earth/locality/egrid_subregion/data_miner'
|
7
|
+
require 'earth/locality/petroleum_administration_for_defense_district/data_miner'
|
8
|
+
require 'earth/locality/state/data_miner'
|
9
|
+
require 'earth/locality/urbanity/data_miner'
|
10
|
+
require 'earth/locality/zip_code/data_miner'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class EgridRegion < ActiveRecord::Base
|
2
|
+
set_primary_key :name
|
3
|
+
|
4
|
+
has_many :egrid_subregions, :foreign_key => 'egrid_region_name'
|
5
|
+
|
6
|
+
data_miner do
|
7
|
+
tap "Brighter Planet's egrid region data", Earth.taps_server
|
8
|
+
|
9
|
+
process "pull dependencies" do
|
10
|
+
run_data_miner_on_belongs_to_associations
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
falls_back_on :loss_factor => 0.061311 # Ian
|
15
|
+
end
|