earth 0.2.14 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/earth/automobile/automobile_fuel_type.rb +1 -1
- data/lib/earth/automobile/automobile_make/data_miner.rb +3 -3
- data/lib/earth/automobile/automobile_make.rb +4 -4
- data/lib/earth/automobile/automobile_make_fleet_year.rb +1 -2
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +38 -0
- data/lib/earth/automobile/automobile_make_model.rb +14 -0
- data/lib/earth/automobile/{automobile_model_year → automobile_make_model_year}/data_miner.rb +12 -12
- data/lib/earth/automobile/automobile_make_model_year.rb +15 -0
- data/lib/earth/automobile/{automobile_variant → automobile_make_model_year_variant}/data_miner.rb +13 -13
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +17 -0
- data/lib/earth/automobile/automobile_make_year.rb +1 -1
- data/lib/earth/automobile/automobile_size_class.rb +1 -1
- data/lib/earth/automobile/data_miner.rb +3 -3
- data/lib/earth/automobile.rb +3 -3
- data/lib/earth/bus/bus_class/data_miner.rb +8 -20
- data/lib/earth/bus/bus_class.rb +1 -3
- data/lib/earth/rail/rail_class/data_miner.rb +6 -10
- data/lib/earth/rail/rail_class.rb +1 -8
- data/spec/earth/air/aircraft_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- data/vendor/geokit-rails/lib/geokit-rails.rb +0 -0
- metadata +275 -74
- data/lib/earth/automobile/automobile_model/data_miner.rb +0 -38
- data/lib/earth/automobile/automobile_model.rb +0 -14
- data/lib/earth/automobile/automobile_model_year.rb +0 -15
- data/lib/earth/automobile/automobile_variant.rb +0 -17
@@ -11,11 +11,11 @@ AutomobileMake.class_eval do
|
|
11
11
|
string 'fuel_efficiency_units'
|
12
12
|
end
|
13
13
|
|
14
|
-
process "Derive automobile makes from automobile variants" do
|
15
|
-
|
14
|
+
process "Derive automobile makes from automobile make model year variants" do
|
15
|
+
AutomobileMakeModelYearVariant.run_data_miner!
|
16
16
|
connection.execute %{
|
17
17
|
INSERT IGNORE INTO automobile_makes(name)
|
18
|
-
SELECT
|
18
|
+
SELECT automobile_make_model_year_variants.make_name FROM automobile_make_model_year_variants WHERE LENGTH(automobile_make_model_year_variants.make_name) > 0
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class AutomobileMake < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
has_many :make_years,
|
5
|
-
has_many :models,
|
6
|
-
has_many :fleet_years,
|
7
|
-
has_many :
|
4
|
+
has_many :make_years, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_name'
|
5
|
+
has_many :models, :class_name => 'AutomobileMakeModel', :foreign_key => 'make_name'
|
6
|
+
has_many :fleet_years, :class_name => 'AutomobileMakeFleetYear', :foreign_key => 'make_name'
|
7
|
+
has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_name'
|
8
8
|
|
9
9
|
scope :major, :conditions => { :major => true }, :order => :name
|
10
10
|
|
@@ -1,8 +1,7 @@
|
|
1
1
|
class AutomobileMakeFleetYear < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
belongs_to :make,
|
5
|
-
# WRONG belongs_to :model_year, :class_name => 'AutomobileModelYear', :foreign_key => 'automobile_model_year_name'
|
4
|
+
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
6
5
|
belongs_to :make_year, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_year_name'
|
7
6
|
|
8
7
|
data_miner do
|
@@ -0,0 +1,38 @@
|
|
1
|
+
AutomobileMakeModel.class_eval do
|
2
|
+
data_miner do
|
3
|
+
process "Start from scratch" do
|
4
|
+
connection.drop_table table_name
|
5
|
+
end
|
6
|
+
|
7
|
+
schema Earth.database_options do
|
8
|
+
string 'name' # make + model
|
9
|
+
string 'make_name'
|
10
|
+
float 'fuel_efficiency_city'
|
11
|
+
string 'fuel_efficiency_city_units'
|
12
|
+
float 'fuel_efficiency_highway'
|
13
|
+
string 'fuel_efficiency_highway_units'
|
14
|
+
end
|
15
|
+
|
16
|
+
process "Derive model names from automobile make model year variants" do
|
17
|
+
AutomobileMakeModelYearVariant.run_data_miner!
|
18
|
+
connection.execute %{
|
19
|
+
INSERT IGNORE INTO automobile_make_models(name, make_name)
|
20
|
+
SELECT automobile_make_model_year_variants.model_name, automobile_make_model_year_variants.make_name FROM automobile_make_model_year_variants WHERE LENGTH(automobile_make_model_year_variants.model_name) > 0 AND LENGTH(automobile_make_model_year_variants.make_name) > 0
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# TODO not weighted until we get weightings on auto variants
|
25
|
+
process "Derive average fuel economy from automobile make model year variants" do
|
26
|
+
AutomobileMakeModelYearVariant.run_data_miner!
|
27
|
+
automobile_make_models = AutomobileMakeModel.arel_table
|
28
|
+
automobile_make_model_year_variants = AutomobileMakeModelYearVariant.arel_table
|
29
|
+
conditional_relation = automobile_make_models[:name].eq(automobile_make_model_year_variants[:model_name])
|
30
|
+
%w{ city highway }.each do |i|
|
31
|
+
relation = AutomobileMakeModelYearVariant.where(conditional_relation).where("`automobile_make_model_year_variants`.`fuel_efficiency_#{i}` IS NOT NULL").project("AVG(`automobile_make_model_year_variants`.`fuel_efficiency_#{i}`)")
|
32
|
+
update_all "fuel_efficiency_#{i} = (#{relation.to_sql})"
|
33
|
+
update_all "fuel_efficiency_#{i}_units = 'kilometres_per_litre'"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AutomobileMakeModel < ActiveRecord::Base
|
2
|
+
set_primary_key :name
|
3
|
+
|
4
|
+
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
5
|
+
has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_model_name'
|
6
|
+
|
7
|
+
data_miner do
|
8
|
+
tap "Brighter Planet's auto model data", Earth.taps_server
|
9
|
+
|
10
|
+
process "bring in dependencies" do
|
11
|
+
run_data_miner_on_belongs_to_associations
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/earth/automobile/{automobile_model_year → automobile_make_model_year}/data_miner.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
AutomobileMakeModelYear.class_eval do
|
2
2
|
data_miner do
|
3
3
|
process "Start from scratch" do
|
4
4
|
connection.drop_table table_name
|
@@ -7,7 +7,7 @@ AutomobileModelYear.class_eval do
|
|
7
7
|
schema Earth.database_options do
|
8
8
|
string 'name'
|
9
9
|
string 'make_name'
|
10
|
-
string '
|
10
|
+
string 'make_model_name'
|
11
11
|
integer 'year'
|
12
12
|
string 'make_year_name'
|
13
13
|
float 'fuel_efficiency'
|
@@ -18,11 +18,11 @@ AutomobileModelYear.class_eval do
|
|
18
18
|
string 'fuel_efficiency_highway_units'
|
19
19
|
end
|
20
20
|
|
21
|
-
process "Derive model year names from automobile variants" do
|
22
|
-
|
21
|
+
process "Derive model year names from automobile make model year variants" do
|
22
|
+
AutomobileMakeModelYearVariant.run_data_miner!
|
23
23
|
connection.execute %{
|
24
|
-
INSERT IGNORE INTO
|
25
|
-
SELECT
|
24
|
+
INSERT IGNORE INTO automobile_make_model_years(name, make_name, model_name, year, make_year_name)
|
25
|
+
SELECT automobile_make_model_year_variants.model_year_name, automobile_make_model_year_variants.make_name, automobile_make_model_year_variants.model_name, automobile_make_model_year_variants.year, automobile_make_model_year_variants.make_year_name FROM automobile_make_model_year_variants WHERE LENGTH(automobile_make_model_year_variants.make_name) > 0 AND LENGTH(automobile_make_model_year_variants.model_name) > 0
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
@@ -30,13 +30,13 @@ AutomobileModelYear.class_eval do
|
|
30
30
|
# note that we used to derive averages from make years, but here we get it from variants
|
31
31
|
# even without volume-weighting, the values are much better.
|
32
32
|
# for example, 20km/l for a toyota prius 2006 vs. 13km/l if you use make years
|
33
|
-
process "Calculate city and highway fuel efficiency from automobile variants" do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
conditional_relation =
|
33
|
+
process "Calculate city and highway fuel efficiency from automobile make model year variants" do
|
34
|
+
AutomobileMakeModelYearVariant.run_data_miner!
|
35
|
+
automobile_make_model_years = AutomobileMakeModelYear.arel_table
|
36
|
+
automobile_make_model_year_variants = AutomobileMakeModelYearVariant.arel_table
|
37
|
+
conditional_relation = automobile_make_model_years[:name].eq(automobile_make_model_year_variants[:model_year_name])
|
38
38
|
%w{ city highway }.each do |i|
|
39
|
-
relation =
|
39
|
+
relation = AutomobileMakeModelYearVariant.where(conditional_relation).where("`automobile_make_model_year_variants`.`fuel_efficiency_#{i}` IS NOT NULL").project("AVG(`automobile_make_model_year_variants`.`fuel_efficiency_#{i}`)")
|
40
40
|
update_all "fuel_efficiency_#{i} = (#{relation.to_sql})"
|
41
41
|
update_all "fuel_efficiency_#{i}_units = 'kilometres_per_litre'"
|
42
42
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AutomobileMakeModelYear < ActiveRecord::Base
|
2
|
+
set_primary_key :name
|
3
|
+
|
4
|
+
belongs_to :make_year, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_year_name'
|
5
|
+
has_many :make_model_year_variants, :class_name => 'AutomobileMakeModelYearVariant', :foreign_key => 'make_model_year_name'
|
6
|
+
has_many :automobiles, :foreign_key => 'make_model_year_name'
|
7
|
+
|
8
|
+
data_miner do
|
9
|
+
tap "Brighter Planet's model year data", Earth.taps_server
|
10
|
+
|
11
|
+
process "pull dependencies" do
|
12
|
+
run_data_miner_on_belongs_to_associations
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/earth/automobile/{automobile_variant → automobile_make_model_year_variant}/data_miner.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
AutomobileMakeModelYearVariant.class_eval do
|
2
2
|
class << self
|
3
3
|
def transmission_is_blank?(row)
|
4
4
|
row['transmission'].blank?
|
@@ -105,7 +105,7 @@ AutomobileVariant.class_eval do
|
|
105
105
|
'(GM-PONT)' => nil,
|
106
106
|
}
|
107
107
|
|
108
|
-
class
|
108
|
+
class AutomobileMakeModelYearVariant::ParserB
|
109
109
|
attr_accessor :year
|
110
110
|
def initialize(options = {})
|
111
111
|
@year = options[:year]
|
@@ -189,7 +189,7 @@ AutomobileVariant.class_eval do
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
end
|
192
|
-
class
|
192
|
+
class AutomobileMakeModelYearVariant::ParserC
|
193
193
|
attr_accessor :year
|
194
194
|
def initialize(options = {})
|
195
195
|
@year = options[:year]
|
@@ -214,7 +214,7 @@ AutomobileVariant.class_eval do
|
|
214
214
|
row
|
215
215
|
end
|
216
216
|
end
|
217
|
-
class
|
217
|
+
class AutomobileMakeModelYearVariant::ParserD
|
218
218
|
attr_accessor :year
|
219
219
|
def initialize(options = {})
|
220
220
|
@year = options[:year]
|
@@ -238,7 +238,7 @@ AutomobileVariant.class_eval do
|
|
238
238
|
row
|
239
239
|
end
|
240
240
|
end
|
241
|
-
class
|
241
|
+
class AutomobileMakeModelYearVariant::ParserE
|
242
242
|
OLD_FUEL_CODES = {
|
243
243
|
'CNG' => 'C',
|
244
244
|
'DU' => 'D',
|
@@ -277,9 +277,9 @@ AutomobileVariant.class_eval do
|
|
277
277
|
string 'row_hash'
|
278
278
|
string 'name' # short name!
|
279
279
|
string 'make_name'
|
280
|
-
string '
|
280
|
+
string 'make_model_name' # make + model
|
281
281
|
string 'make_year_name' # make + year
|
282
|
-
string '
|
282
|
+
string 'make_model_year_name' # make + model + year
|
283
283
|
integer 'year'
|
284
284
|
float 'fuel_efficiency_city'
|
285
285
|
string 'fuel_efficiency_city_units'
|
@@ -304,9 +304,9 @@ AutomobileVariant.class_eval do
|
|
304
304
|
string 'carline_class_name'
|
305
305
|
string 'speeds'
|
306
306
|
index 'make_name'
|
307
|
-
index '
|
307
|
+
index 'make_model_name'
|
308
308
|
index 'make_year_name'
|
309
|
-
index '
|
309
|
+
index 'make_model_year_name'
|
310
310
|
end
|
311
311
|
|
312
312
|
# # 1985---1997
|
@@ -315,7 +315,7 @@ AutomobileVariant.class_eval do
|
|
315
315
|
import("19#{ yy } Fuel Economy Guide",
|
316
316
|
:url => "http://www.fueleconomy.gov/FEG/epadata/#{yy}mfgui.zip",
|
317
317
|
:filename => filename,
|
318
|
-
:transform => { :class =>
|
318
|
+
:transform => { :class => AutomobileMakeModelYearVariant::ParserB, :year => "19#{yy}".to_i },
|
319
319
|
:errata => 'http://static.brighterplanet.com/science/data/transport/automobiles/fuel_economy_guide/errata.csv') do
|
320
320
|
key 'row_hash'
|
321
321
|
store 'name', :field_name => 'model'
|
@@ -353,7 +353,7 @@ AutomobileVariant.class_eval do
|
|
353
353
|
2005 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/05data.zip', :filename => 'guide2005-2004oct15.csv' }
|
354
354
|
}.sort { |a, b| a.first <=> b.first }.each do |year, options|
|
355
355
|
import "#{ year } Fuel Economy Guide",
|
356
|
-
options.merge(:transform => { :class =>
|
356
|
+
options.merge(:transform => { :class => AutomobileMakeModelYearVariant::ParserC, :year => year },
|
357
357
|
:errata => 'http://static.brighterplanet.com/science/data/transport/automobiles/fuel_economy_guide/errata.csv') do
|
358
358
|
key 'row_hash'
|
359
359
|
store 'name', :field_name => 'model'
|
@@ -385,7 +385,7 @@ AutomobileVariant.class_eval do
|
|
385
385
|
2009 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/09data.zip', :filename => '2009_FE_guide for DOE_ALL-rel dates-no-sales-8-28-08download.csv' },
|
386
386
|
}.sort { |a, b| a.first <=> b.first }.each do |year, options|
|
387
387
|
import "#{ year } Fuel Economy Guide",
|
388
|
-
options.merge(:transform => { :class =>
|
388
|
+
options.merge(:transform => { :class => AutomobileMakeModelYearVariant::ParserD, :year => year },
|
389
389
|
:errata => 'http://static.brighterplanet.com/science/data/transport/automobiles/fuel_economy_guide/errata.csv') do
|
390
390
|
key 'row_hash'
|
391
391
|
store 'name', :field_name => 'model'
|
@@ -450,7 +450,7 @@ AutomobileVariant.class_eval do
|
|
450
450
|
update_all 'fuel_efficiency_highway = 1 / ((0.001376 / 0.425143707) + (1.3466 / raw_fuel_efficiency_highway))'
|
451
451
|
end
|
452
452
|
|
453
|
-
%w{ AutomobileMake
|
453
|
+
%w{ AutomobileMake AutomobileMakeModelYear AutomobileMakeModel }.each do |synthetic_resource|
|
454
454
|
process "Synthesize #{synthetic_resource}" do
|
455
455
|
synthetic_resource.constantize.run_data_miner!
|
456
456
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AutomobileMakeModelYearVariant < ActiveRecord::Base
|
2
|
+
set_primary_key :row_hash
|
3
|
+
|
4
|
+
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
5
|
+
belongs_to :make_model, :class_name => 'AutomobileMakeModel', :foreign_key => 'make_model_name'
|
6
|
+
belongs_to :make_model_year, :class_name => 'AutomobileMakeModelYear', :foreign_key => 'make_model_year_name'
|
7
|
+
belongs_to :fuel_type, :class_name => 'AutomobileFuelType', :foreign_key => 'fuel_type_code'
|
8
|
+
has_many :automobiles, :foreign_key => 'make_model_year_variant_row_hash'
|
9
|
+
|
10
|
+
data_miner do
|
11
|
+
tap "Brighter Planet's sanitized automobile make model year variant data", Earth.taps_server
|
12
|
+
|
13
|
+
process "pull dependencies" do
|
14
|
+
run_data_miner_on_belongs_to_associations
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AutomobileMakeYear < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
belongs_to :make,
|
4
|
+
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
5
5
|
has_many :fleet_years, :class_name => 'AutomobileMakeFleetYear', :foreign_key => 'make_year_name'
|
6
6
|
|
7
7
|
data_miner do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AutomobileSizeClass < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
|
-
has_many :automobiles, :foreign_key => '
|
4
|
+
has_many :automobiles, :foreign_key => 'size_class_name'
|
5
5
|
|
6
6
|
falls_back_on :hybrid_fuel_efficiency_city_multiplier => 1.651, # https://brighterplanet.sifterapp.com/issue/667
|
7
7
|
:hybrid_fuel_efficiency_highway_multiplier => 1.213,
|
@@ -2,7 +2,7 @@ require 'earth/automobile/automobile_fuel_type/data_miner'
|
|
2
2
|
require 'earth/automobile/automobile_make/data_miner'
|
3
3
|
require 'earth/automobile/automobile_make_fleet_year/data_miner'
|
4
4
|
require 'earth/automobile/automobile_make_year/data_miner'
|
5
|
-
require 'earth/automobile/
|
6
|
-
require 'earth/automobile/
|
5
|
+
require 'earth/automobile/automobile_make_model/data_miner'
|
6
|
+
require 'earth/automobile/automobile_make_model_year/data_miner'
|
7
7
|
require 'earth/automobile/automobile_size_class/data_miner'
|
8
|
-
require 'earth/automobile/
|
8
|
+
require 'earth/automobile/automobile_make_model_year_variant/data_miner'
|
data/lib/earth/automobile.rb
CHANGED
@@ -2,7 +2,7 @@ require 'earth/automobile/automobile_fuel_type'
|
|
2
2
|
require 'earth/automobile/automobile_make'
|
3
3
|
require 'earth/automobile/automobile_make_fleet_year'
|
4
4
|
require 'earth/automobile/automobile_make_year'
|
5
|
-
require 'earth/automobile/
|
6
|
-
require 'earth/automobile/
|
5
|
+
require 'earth/automobile/automobile_make_model'
|
6
|
+
require 'earth/automobile/automobile_make_model_year'
|
7
7
|
require 'earth/automobile/automobile_size_class'
|
8
|
-
require 'earth/automobile/
|
8
|
+
require 'earth/automobile/automobile_make_model_year_variant'
|
@@ -7,35 +7,23 @@ BusClass.class_eval do
|
|
7
7
|
float 'passengers'
|
8
8
|
float 'speed'
|
9
9
|
string 'speed_units'
|
10
|
-
float 'duration'
|
11
|
-
string 'duration_units'
|
12
10
|
float 'diesel_intensity'
|
13
11
|
string 'diesel_intensity_units'
|
14
|
-
float 'gasoline_intensity'
|
15
|
-
string 'gasoline_intensity_units'
|
16
12
|
float 'alternative_fuels_intensity'
|
17
13
|
string 'alternative_fuels_intensity_units'
|
18
|
-
float '
|
19
|
-
string '
|
20
|
-
end
|
21
|
-
|
22
|
-
process "Define some necessary conversions" do
|
23
|
-
Conversions.register :gallons_per_mile, :litres_per_kilometre, 2.35214583
|
24
|
-
Conversions.register :pounds_per_mile, :kilograms_per_kilometre, 0.281849232
|
14
|
+
float 'air_conditioning_emission_factor'
|
15
|
+
string 'air_conditioning_emission_factor_units'
|
25
16
|
end
|
26
17
|
|
27
18
|
import "a list of bus classes and pre-calculated trip and fuel use characteristics",
|
28
|
-
:url => '
|
19
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGRsSnJoS1hraGJvR012cDROWXFPbVE&hl=en&single=true&gid=0&output=csv' do
|
29
20
|
key 'name'
|
30
|
-
store 'distance', :
|
21
|
+
store 'distance', :units_field_name => 'distance_units'
|
31
22
|
store 'passengers'
|
32
|
-
store 'speed', :
|
33
|
-
store '
|
34
|
-
store '
|
35
|
-
store '
|
36
|
-
store 'alternative_fuels_intensity', :field_name => 'alternative_fuels_per_vehicle_mile', :from_units => :gallons_per_mile, :to_units => :litres_per_kilometre
|
37
|
-
store 'fugitive_air_conditioning_emission', :field_name => 'fugitive_air_conditioning_emission_per_vehicle_mile', :from_units => :pounds_per_mile, :to_units => :kilograms_per_kilometre
|
23
|
+
store 'speed', :units_field_name => 'speed_units'
|
24
|
+
store 'diesel_intensity', :units_field_name => 'diesel_intensity_units'
|
25
|
+
store 'alternative_fuels_intensity', :units_field_name => 'alternative_fuels_intensity_units'
|
26
|
+
store 'air_conditioning_emission_factor', :units_field_name => 'air_conditioning_emission_factor_units'
|
38
27
|
end
|
39
28
|
end
|
40
29
|
end
|
41
|
-
|
data/lib/earth/bus/bus_class.rb
CHANGED
@@ -7,11 +7,9 @@ class BusClass < ActiveRecord::Base
|
|
7
7
|
falls_back_on :distance => 5.45.miles.to(:kilometres),
|
8
8
|
:passengers => 8.25,
|
9
9
|
:speed => 19.67.miles.to(:kilometres),
|
10
|
-
:duration => 0.277,
|
11
10
|
:diesel_intensity => 0.143.gallons_per_mile.to(:litres_per_kilometre),
|
12
|
-
:gasoline_intensity => 0.000123.gallons_per_mile.to(:litres_per_kilometre),
|
13
11
|
:alternative_fuels_intensity => 0.0517.gallons_per_mile.to(:litres_per_kilometre),
|
14
|
-
:
|
12
|
+
:air_conditioning_emission_factor => 0.0203.pounds_per_mile.to(:kilograms_per_kilometre)
|
15
13
|
|
16
14
|
data_miner do
|
17
15
|
tap "Brighter Planet's sanitized bus class data", Earth.taps_server
|
@@ -2,18 +2,16 @@ RailClass.class_eval do
|
|
2
2
|
data_miner do
|
3
3
|
schema Earth.database_options do
|
4
4
|
string 'name'
|
5
|
+
string 'description'
|
6
|
+
float 'passengers'
|
5
7
|
float 'distance'
|
6
8
|
string 'distance_units'
|
7
|
-
float 'passengers'
|
8
9
|
float 'speed'
|
9
10
|
string 'speed_units'
|
10
|
-
float 'duration'
|
11
|
-
string 'duration_units'
|
12
11
|
float 'electricity_intensity'
|
13
12
|
string 'electricity_intensity_units'
|
14
13
|
float 'diesel_intensity'
|
15
14
|
string 'diesel_intensity_units'
|
16
|
-
string 'description'
|
17
15
|
end
|
18
16
|
|
19
17
|
process "Define some unit conversions" do
|
@@ -24,13 +22,11 @@ RailClass.class_eval do
|
|
24
22
|
:url => 'http://static.brighterplanet.com/science/data/transport/rail/rail_classes.csv' do
|
25
23
|
key 'name'
|
26
24
|
store 'description'
|
27
|
-
store 'distance', :from_units => :miles, :to_units => :kilometres
|
28
|
-
store 'speed', :from_units => :miles, :to_units => :kilometres
|
29
|
-
store 'duration'
|
30
25
|
store 'passengers'
|
31
|
-
store '
|
32
|
-
store '
|
26
|
+
store 'distance', :units_field_name => 'distance_units'
|
27
|
+
store 'speed', :units_field_name => 'speed_units'
|
28
|
+
store 'electricity_intensity', :units_field_name => 'electricity_intensity_units'
|
29
|
+
store 'diesel_intensity', :units_field_name => 'diesel_intensity_units'
|
33
30
|
end
|
34
31
|
end
|
35
32
|
end
|
36
|
-
|
@@ -2,15 +2,8 @@ class RailClass < ActiveRecord::Base
|
|
2
2
|
set_primary_key :name
|
3
3
|
|
4
4
|
has_many :rail_trips
|
5
|
-
|
5
|
+
|
6
6
|
data_miner do
|
7
7
|
tap "Brighter Planet's rail class data", Earth.taps_server
|
8
8
|
end
|
9
|
-
|
10
|
-
# speed is missing
|
11
|
-
# https://brighterplanet.sifterapp.com/projects/30/issues/455
|
12
|
-
falls_back_on :passengers => 25.06,
|
13
|
-
:distance => 8.57.miles.to(:kilometres),
|
14
|
-
:diesel_intensity => 0.05.gallons_per_mile.to(:litres_per_kilometre),
|
15
|
-
:electricity_intensity => 8.89.miles.to(:kilometres)
|
16
9
|
end
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: earth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 11
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Seamus Abshere
|
@@ -17,18 +16,29 @@ autorequire:
|
|
17
16
|
bindir: bin
|
18
17
|
cert_chain: []
|
19
18
|
|
20
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-19 00:00:00 -05:00
|
21
20
|
default_executable:
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
|
-
name:
|
25
|
-
prerelease: false
|
23
|
+
name: earth
|
26
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
25
|
none: false
|
28
26
|
requirements:
|
29
27
|
- - ">="
|
30
28
|
- !ruby/object:Gem::Version
|
31
|
-
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: activerecord
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
32
42
|
segments:
|
33
43
|
- 3
|
34
44
|
- 0
|
@@ -36,128 +46,120 @@ dependencies:
|
|
36
46
|
- beta4
|
37
47
|
version: 3.0.0.beta4
|
38
48
|
type: :runtime
|
39
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: *id002
|
40
51
|
- !ruby/object:Gem::Dependency
|
41
52
|
name: data_miner
|
42
|
-
|
43
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
44
54
|
none: false
|
45
55
|
requirements:
|
46
56
|
- - ~>
|
47
57
|
- !ruby/object:Gem::Version
|
48
|
-
hash: 7
|
49
58
|
segments:
|
50
59
|
- 0
|
51
60
|
- 5
|
52
61
|
- 6
|
53
62
|
version: 0.5.6
|
54
63
|
type: :runtime
|
55
|
-
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: *id003
|
56
66
|
- !ruby/object:Gem::Dependency
|
57
67
|
name: falls_back_on
|
58
|
-
|
59
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
60
69
|
none: false
|
61
70
|
requirements:
|
62
71
|
- - ">="
|
63
72
|
- !ruby/object:Gem::Version
|
64
|
-
hash: 25
|
65
73
|
segments:
|
66
74
|
- 0
|
67
75
|
- 0
|
68
76
|
- 3
|
69
77
|
version: 0.0.3
|
70
78
|
type: :runtime
|
71
|
-
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *id004
|
72
81
|
- !ruby/object:Gem::Dependency
|
73
82
|
name: geokit
|
74
|
-
|
75
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
76
84
|
none: false
|
77
85
|
requirements:
|
78
86
|
- - ">="
|
79
87
|
- !ruby/object:Gem::Version
|
80
|
-
hash: 3
|
81
88
|
segments:
|
82
89
|
- 1
|
83
90
|
- 5
|
84
91
|
- 0
|
85
92
|
version: 1.5.0
|
86
93
|
type: :runtime
|
87
|
-
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: *id005
|
88
96
|
- !ruby/object:Gem::Dependency
|
89
97
|
name: cohort_scope
|
90
|
-
|
91
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
92
99
|
none: false
|
93
100
|
requirements:
|
94
101
|
- - ">="
|
95
102
|
- !ruby/object:Gem::Version
|
96
|
-
hash: 17
|
97
103
|
segments:
|
98
104
|
- 0
|
99
105
|
- 0
|
100
106
|
- 7
|
101
107
|
version: 0.0.7
|
102
108
|
type: :runtime
|
103
|
-
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: *id006
|
104
111
|
- !ruby/object:Gem::Dependency
|
105
112
|
name: conversions
|
106
|
-
|
107
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
113
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
108
114
|
none: false
|
109
115
|
requirements:
|
110
116
|
- - ">="
|
111
117
|
- !ruby/object:Gem::Version
|
112
|
-
hash: 13
|
113
118
|
segments:
|
114
119
|
- 1
|
115
120
|
- 4
|
116
121
|
- 5
|
117
122
|
version: 1.4.5
|
118
123
|
type: :runtime
|
119
|
-
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *id007
|
120
126
|
- !ruby/object:Gem::Dependency
|
121
127
|
name: weighted_average
|
122
|
-
|
123
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
128
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
124
129
|
none: false
|
125
130
|
requirements:
|
126
131
|
- - ">="
|
127
132
|
- !ruby/object:Gem::Version
|
128
|
-
hash: 23
|
129
133
|
segments:
|
130
134
|
- 0
|
131
135
|
- 0
|
132
136
|
- 4
|
133
137
|
version: 0.0.4
|
134
138
|
type: :runtime
|
135
|
-
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: *id008
|
136
141
|
- !ruby/object:Gem::Dependency
|
137
142
|
name: loose_tight_dictionary
|
138
|
-
|
139
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
143
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
140
144
|
none: false
|
141
145
|
requirements:
|
142
146
|
- - ">="
|
143
147
|
- !ruby/object:Gem::Version
|
144
|
-
hash: 15
|
145
148
|
segments:
|
146
149
|
- 0
|
147
150
|
- 0
|
148
151
|
- 8
|
149
152
|
version: 0.0.8
|
150
153
|
type: :runtime
|
151
|
-
|
154
|
+
prerelease: false
|
155
|
+
version_requirements: *id009
|
152
156
|
- !ruby/object:Gem::Dependency
|
153
157
|
name: rspec
|
154
|
-
|
155
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
158
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
156
159
|
none: false
|
157
160
|
requirements:
|
158
161
|
- - ">="
|
159
162
|
- !ruby/object:Gem::Version
|
160
|
-
hash: 62196417
|
161
163
|
segments:
|
162
164
|
- 2
|
163
165
|
- 0
|
@@ -166,79 +168,280 @@ dependencies:
|
|
166
168
|
- 17
|
167
169
|
version: 2.0.0.beta.17
|
168
170
|
type: :development
|
169
|
-
|
171
|
+
prerelease: false
|
172
|
+
version_requirements: *id010
|
170
173
|
- !ruby/object:Gem::Dependency
|
171
174
|
name: rake
|
172
|
-
|
173
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
175
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
174
176
|
none: false
|
175
177
|
requirements:
|
176
178
|
- - ">="
|
177
179
|
- !ruby/object:Gem::Version
|
178
|
-
hash: 3
|
179
180
|
segments:
|
180
181
|
- 0
|
181
182
|
version: "0"
|
182
183
|
type: :development
|
183
|
-
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: *id011
|
184
186
|
- !ruby/object:Gem::Dependency
|
185
187
|
name: jeweler
|
186
|
-
|
187
|
-
requirement: &id011 !ruby/object:Gem::Requirement
|
188
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
188
189
|
none: false
|
189
190
|
requirements:
|
190
191
|
- - ">="
|
191
192
|
- !ruby/object:Gem::Version
|
192
|
-
hash: 3
|
193
193
|
segments:
|
194
194
|
- 0
|
195
195
|
version: "0"
|
196
196
|
type: :development
|
197
|
-
|
197
|
+
prerelease: false
|
198
|
+
version_requirements: *id012
|
198
199
|
- !ruby/object:Gem::Dependency
|
199
200
|
name: rcov
|
200
|
-
|
201
|
-
requirement: &id012 !ruby/object:Gem::Requirement
|
201
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
202
202
|
none: false
|
203
203
|
requirements:
|
204
204
|
- - ">="
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
hash: 3
|
207
206
|
segments:
|
208
207
|
- 0
|
209
208
|
version: "0"
|
210
209
|
type: :development
|
211
|
-
|
210
|
+
prerelease: false
|
211
|
+
version_requirements: *id013
|
212
212
|
- !ruby/object:Gem::Dependency
|
213
213
|
name: rdoc
|
214
|
-
|
215
|
-
requirement: &id013 !ruby/object:Gem::Requirement
|
214
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
216
215
|
none: false
|
217
216
|
requirements:
|
218
217
|
- - ">="
|
219
218
|
- !ruby/object:Gem::Version
|
220
|
-
hash: 3
|
221
219
|
segments:
|
222
220
|
- 0
|
223
221
|
version: "0"
|
224
222
|
type: :development
|
225
|
-
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: *id014
|
226
225
|
- !ruby/object:Gem::Dependency
|
227
226
|
name: sqlite3-ruby
|
227
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
228
|
+
none: false
|
229
|
+
requirements:
|
230
|
+
- - ">="
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
segments:
|
233
|
+
- 1
|
234
|
+
- 3
|
235
|
+
- 0
|
236
|
+
version: 1.3.0
|
237
|
+
type: :development
|
228
238
|
prerelease: false
|
229
|
-
|
239
|
+
version_requirements: *id015
|
240
|
+
- !ruby/object:Gem::Dependency
|
241
|
+
name: activerecord
|
242
|
+
requirement: &id016 !ruby/object:Gem::Requirement
|
243
|
+
none: false
|
244
|
+
requirements:
|
245
|
+
- - ">="
|
246
|
+
- !ruby/object:Gem::Version
|
247
|
+
segments:
|
248
|
+
- 3
|
249
|
+
- 0
|
250
|
+
- 0
|
251
|
+
- beta4
|
252
|
+
version: 3.0.0.beta4
|
253
|
+
type: :runtime
|
254
|
+
prerelease: false
|
255
|
+
version_requirements: *id016
|
256
|
+
- !ruby/object:Gem::Dependency
|
257
|
+
name: data_miner
|
258
|
+
requirement: &id017 !ruby/object:Gem::Requirement
|
259
|
+
none: false
|
260
|
+
requirements:
|
261
|
+
- - ~>
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
segments:
|
264
|
+
- 0
|
265
|
+
- 5
|
266
|
+
- 6
|
267
|
+
version: 0.5.6
|
268
|
+
type: :runtime
|
269
|
+
prerelease: false
|
270
|
+
version_requirements: *id017
|
271
|
+
- !ruby/object:Gem::Dependency
|
272
|
+
name: falls_back_on
|
273
|
+
requirement: &id018 !ruby/object:Gem::Requirement
|
274
|
+
none: false
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
segments:
|
279
|
+
- 0
|
280
|
+
- 0
|
281
|
+
- 3
|
282
|
+
version: 0.0.3
|
283
|
+
type: :runtime
|
284
|
+
prerelease: false
|
285
|
+
version_requirements: *id018
|
286
|
+
- !ruby/object:Gem::Dependency
|
287
|
+
name: geokit
|
288
|
+
requirement: &id019 !ruby/object:Gem::Requirement
|
289
|
+
none: false
|
290
|
+
requirements:
|
291
|
+
- - ">="
|
292
|
+
- !ruby/object:Gem::Version
|
293
|
+
segments:
|
294
|
+
- 1
|
295
|
+
- 5
|
296
|
+
- 0
|
297
|
+
version: 1.5.0
|
298
|
+
type: :runtime
|
299
|
+
prerelease: false
|
300
|
+
version_requirements: *id019
|
301
|
+
- !ruby/object:Gem::Dependency
|
302
|
+
name: cohort_scope
|
303
|
+
requirement: &id020 !ruby/object:Gem::Requirement
|
304
|
+
none: false
|
305
|
+
requirements:
|
306
|
+
- - ">="
|
307
|
+
- !ruby/object:Gem::Version
|
308
|
+
segments:
|
309
|
+
- 0
|
310
|
+
- 0
|
311
|
+
- 7
|
312
|
+
version: 0.0.7
|
313
|
+
type: :runtime
|
314
|
+
prerelease: false
|
315
|
+
version_requirements: *id020
|
316
|
+
- !ruby/object:Gem::Dependency
|
317
|
+
name: conversions
|
318
|
+
requirement: &id021 !ruby/object:Gem::Requirement
|
319
|
+
none: false
|
320
|
+
requirements:
|
321
|
+
- - ">="
|
322
|
+
- !ruby/object:Gem::Version
|
323
|
+
segments:
|
324
|
+
- 1
|
325
|
+
- 4
|
326
|
+
- 5
|
327
|
+
version: 1.4.5
|
328
|
+
type: :runtime
|
329
|
+
prerelease: false
|
330
|
+
version_requirements: *id021
|
331
|
+
- !ruby/object:Gem::Dependency
|
332
|
+
name: weighted_average
|
333
|
+
requirement: &id022 !ruby/object:Gem::Requirement
|
334
|
+
none: false
|
335
|
+
requirements:
|
336
|
+
- - ">="
|
337
|
+
- !ruby/object:Gem::Version
|
338
|
+
segments:
|
339
|
+
- 0
|
340
|
+
- 0
|
341
|
+
- 4
|
342
|
+
version: 0.0.4
|
343
|
+
type: :runtime
|
344
|
+
prerelease: false
|
345
|
+
version_requirements: *id022
|
346
|
+
- !ruby/object:Gem::Dependency
|
347
|
+
name: loose_tight_dictionary
|
348
|
+
requirement: &id023 !ruby/object:Gem::Requirement
|
349
|
+
none: false
|
350
|
+
requirements:
|
351
|
+
- - ">="
|
352
|
+
- !ruby/object:Gem::Version
|
353
|
+
segments:
|
354
|
+
- 0
|
355
|
+
- 0
|
356
|
+
- 8
|
357
|
+
version: 0.0.8
|
358
|
+
type: :runtime
|
359
|
+
prerelease: false
|
360
|
+
version_requirements: *id023
|
361
|
+
- !ruby/object:Gem::Dependency
|
362
|
+
name: rspec
|
363
|
+
requirement: &id024 !ruby/object:Gem::Requirement
|
364
|
+
none: false
|
365
|
+
requirements:
|
366
|
+
- - ">="
|
367
|
+
- !ruby/object:Gem::Version
|
368
|
+
segments:
|
369
|
+
- 2
|
370
|
+
- 0
|
371
|
+
- 0
|
372
|
+
- beta
|
373
|
+
- 17
|
374
|
+
version: 2.0.0.beta.17
|
375
|
+
type: :development
|
376
|
+
prerelease: false
|
377
|
+
version_requirements: *id024
|
378
|
+
- !ruby/object:Gem::Dependency
|
379
|
+
name: rake
|
380
|
+
requirement: &id025 !ruby/object:Gem::Requirement
|
381
|
+
none: false
|
382
|
+
requirements:
|
383
|
+
- - ">="
|
384
|
+
- !ruby/object:Gem::Version
|
385
|
+
segments:
|
386
|
+
- 0
|
387
|
+
version: "0"
|
388
|
+
type: :development
|
389
|
+
prerelease: false
|
390
|
+
version_requirements: *id025
|
391
|
+
- !ruby/object:Gem::Dependency
|
392
|
+
name: jeweler
|
393
|
+
requirement: &id026 !ruby/object:Gem::Requirement
|
394
|
+
none: false
|
395
|
+
requirements:
|
396
|
+
- - ">="
|
397
|
+
- !ruby/object:Gem::Version
|
398
|
+
segments:
|
399
|
+
- 0
|
400
|
+
version: "0"
|
401
|
+
type: :development
|
402
|
+
prerelease: false
|
403
|
+
version_requirements: *id026
|
404
|
+
- !ruby/object:Gem::Dependency
|
405
|
+
name: rcov
|
406
|
+
requirement: &id027 !ruby/object:Gem::Requirement
|
407
|
+
none: false
|
408
|
+
requirements:
|
409
|
+
- - ">="
|
410
|
+
- !ruby/object:Gem::Version
|
411
|
+
segments:
|
412
|
+
- 0
|
413
|
+
version: "0"
|
414
|
+
type: :development
|
415
|
+
prerelease: false
|
416
|
+
version_requirements: *id027
|
417
|
+
- !ruby/object:Gem::Dependency
|
418
|
+
name: rdoc
|
419
|
+
requirement: &id028 !ruby/object:Gem::Requirement
|
420
|
+
none: false
|
421
|
+
requirements:
|
422
|
+
- - ">="
|
423
|
+
- !ruby/object:Gem::Version
|
424
|
+
segments:
|
425
|
+
- 0
|
426
|
+
version: "0"
|
427
|
+
type: :development
|
428
|
+
prerelease: false
|
429
|
+
version_requirements: *id028
|
430
|
+
- !ruby/object:Gem::Dependency
|
431
|
+
name: sqlite3-ruby
|
432
|
+
requirement: &id029 !ruby/object:Gem::Requirement
|
230
433
|
none: false
|
231
434
|
requirements:
|
232
435
|
- - ">="
|
233
436
|
- !ruby/object:Gem::Version
|
234
|
-
hash: 27
|
235
437
|
segments:
|
236
438
|
- 1
|
237
439
|
- 3
|
238
440
|
- 0
|
239
441
|
version: 1.3.0
|
240
442
|
type: :development
|
241
|
-
|
443
|
+
prerelease: false
|
444
|
+
version_requirements: *id029
|
242
445
|
description: An earth-simulation environment with ActiveRecord models and data
|
243
446
|
email: andy@rossmeissl.net
|
244
447
|
executables: []
|
@@ -281,16 +484,16 @@ files:
|
|
281
484
|
- lib/earth/automobile/automobile_make/data_miner.rb
|
282
485
|
- lib/earth/automobile/automobile_make_fleet_year.rb
|
283
486
|
- lib/earth/automobile/automobile_make_fleet_year/data_miner.rb
|
487
|
+
- lib/earth/automobile/automobile_make_model.rb
|
488
|
+
- lib/earth/automobile/automobile_make_model/data_miner.rb
|
489
|
+
- lib/earth/automobile/automobile_make_model_year.rb
|
490
|
+
- lib/earth/automobile/automobile_make_model_year/data_miner.rb
|
491
|
+
- lib/earth/automobile/automobile_make_model_year_variant.rb
|
492
|
+
- lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb
|
284
493
|
- lib/earth/automobile/automobile_make_year.rb
|
285
494
|
- lib/earth/automobile/automobile_make_year/data_miner.rb
|
286
|
-
- lib/earth/automobile/automobile_model.rb
|
287
|
-
- lib/earth/automobile/automobile_model/data_miner.rb
|
288
|
-
- lib/earth/automobile/automobile_model_year.rb
|
289
|
-
- lib/earth/automobile/automobile_model_year/data_miner.rb
|
290
495
|
- lib/earth/automobile/automobile_size_class.rb
|
291
496
|
- lib/earth/automobile/automobile_size_class/data_miner.rb
|
292
|
-
- lib/earth/automobile/automobile_variant.rb
|
293
|
-
- lib/earth/automobile/automobile_variant/data_miner.rb
|
294
497
|
- lib/earth/automobile/data_miner.rb
|
295
498
|
- lib/earth/base.rb
|
296
499
|
- lib/earth/bus.rb
|
@@ -423,18 +626,18 @@ files:
|
|
423
626
|
- vendor/geokit-rails/test/schema.rb
|
424
627
|
- vendor/geokit-rails/test/tasks.rake
|
425
628
|
- vendor/geokit-rails/test/test_helper.rb
|
629
|
+
- Gemfile
|
630
|
+
- Gemfile.lock
|
426
631
|
- spec/earth/air/aircraft_spec.rb
|
427
632
|
- spec/earth_spec.rb
|
428
633
|
- spec/spec_helper.rb
|
429
|
-
- Gemfile
|
430
|
-
- Gemfile.lock
|
431
634
|
has_rdoc: true
|
432
635
|
homepage: http://github.com/brighterplanet/earth
|
433
636
|
licenses: []
|
434
637
|
|
435
638
|
post_install_message:
|
436
|
-
rdoc_options:
|
437
|
-
|
639
|
+
rdoc_options: []
|
640
|
+
|
438
641
|
require_paths:
|
439
642
|
- lib
|
440
643
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -442,7 +645,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
442
645
|
requirements:
|
443
646
|
- - ">="
|
444
647
|
- !ruby/object:Gem::Version
|
445
|
-
hash: 3
|
446
648
|
segments:
|
447
649
|
- 0
|
448
650
|
version: "0"
|
@@ -451,7 +653,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
451
653
|
requirements:
|
452
654
|
- - ">="
|
453
655
|
- !ruby/object:Gem::Version
|
454
|
-
hash: 3
|
455
656
|
segments:
|
456
657
|
- 0
|
457
658
|
version: "0"
|
@@ -463,8 +664,8 @@ signing_key:
|
|
463
664
|
specification_version: 3
|
464
665
|
summary: Land, sky, and sea
|
465
666
|
test_files:
|
667
|
+
- Gemfile
|
668
|
+
- Gemfile.lock
|
466
669
|
- spec/earth/air/aircraft_spec.rb
|
467
670
|
- spec/earth_spec.rb
|
468
671
|
- spec/spec_helper.rb
|
469
|
-
- Gemfile
|
470
|
-
- Gemfile.lock
|
@@ -1,38 +0,0 @@
|
|
1
|
-
AutomobileModel.class_eval do
|
2
|
-
data_miner do
|
3
|
-
process "Start from scratch" do
|
4
|
-
connection.drop_table table_name
|
5
|
-
end
|
6
|
-
|
7
|
-
schema Earth.database_options do
|
8
|
-
string 'name' # make + model
|
9
|
-
string 'make_name'
|
10
|
-
float 'fuel_efficiency_city'
|
11
|
-
string 'fuel_efficiency_city_units'
|
12
|
-
float 'fuel_efficiency_highway'
|
13
|
-
string 'fuel_efficiency_highway_units'
|
14
|
-
end
|
15
|
-
|
16
|
-
process "Derive model names from automobile variants" do
|
17
|
-
AutomobileVariant.run_data_miner!
|
18
|
-
connection.execute %{
|
19
|
-
INSERT IGNORE INTO automobile_models(name, make_name)
|
20
|
-
SELECT automobile_variants.model_name, automobile_variants.make_name FROM automobile_variants WHERE LENGTH(automobile_variants.model_name) > 0 AND LENGTH(automobile_variants.make_name) > 0
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
# TODO not weighted until we get weightings on auto variants
|
25
|
-
process "Derive average fuel economy from automobile variants" do
|
26
|
-
AutomobileVariant.run_data_miner!
|
27
|
-
automobile_models = AutomobileModel.arel_table
|
28
|
-
automobile_variants = AutomobileVariant.arel_table
|
29
|
-
conditional_relation = automobile_models[:name].eq(automobile_variants[:model_name])
|
30
|
-
%w{ city highway }.each do |i|
|
31
|
-
relation = AutomobileVariant.where(conditional_relation).where("`automobile_variants`.`fuel_efficiency_#{i}` IS NOT NULL").project("AVG(`automobile_variants`.`fuel_efficiency_#{i}`)")
|
32
|
-
update_all "fuel_efficiency_#{i} = (#{relation.to_sql})"
|
33
|
-
update_all "fuel_efficiency_#{i}_units = 'kilometres_per_litre'"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class AutomobileModel < ActiveRecord::Base
|
2
|
-
set_primary_key :name
|
3
|
-
|
4
|
-
has_many :variants, :class_name => 'AutomobileVariant', :foreign_key => 'model_name'
|
5
|
-
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
6
|
-
|
7
|
-
data_miner do
|
8
|
-
tap "Brighter Planet's auto model data", Earth.taps_server
|
9
|
-
|
10
|
-
process "bring in dependencies" do
|
11
|
-
run_data_miner_on_belongs_to_associations
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class AutomobileModelYear < ActiveRecord::Base
|
2
|
-
set_primary_key :name
|
3
|
-
|
4
|
-
belongs_to :make_year, :class_name => 'AutomobileMakeYear', :foreign_key => 'make_year_name'
|
5
|
-
has_many :variants, :class_name => 'AutomobileVariant', :foreign_key => 'model_year_name'
|
6
|
-
has_many :automobiles, :foreign_key => 'model_year_id'
|
7
|
-
|
8
|
-
data_miner do
|
9
|
-
tap "Brighter Planet's model year data", Earth.taps_server
|
10
|
-
|
11
|
-
process "pull dependencies" do
|
12
|
-
run_data_miner_on_belongs_to_associations
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class AutomobileVariant < ActiveRecord::Base
|
2
|
-
set_primary_key :row_hash
|
3
|
-
|
4
|
-
has_many :automobiles, :foreign_key => 'variant_id'
|
5
|
-
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
6
|
-
belongs_to :model, :class_name => 'AutomobileModel', :foreign_key => 'model_name'
|
7
|
-
belongs_to :model_year, :class_name => 'AutomobileModelYear', :foreign_key => 'model_year_name'
|
8
|
-
belongs_to :fuel_type, :class_name => 'AutomobileFuelType', :foreign_key => 'fuel_type_code'
|
9
|
-
|
10
|
-
data_miner do
|
11
|
-
tap "Brighter Planet's sanitized automobile variant data", Earth.taps_server
|
12
|
-
|
13
|
-
process "pull dependencies" do
|
14
|
-
run_data_miner_on_belongs_to_associations
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|