pavement_condition_index 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bce66be6a47892909611a2a8d901e768c6053fb3
4
+ data.tar.gz: d34615aaa0769b0a4d9c59e25a358d3e7d263ea0
5
+ SHA512:
6
+ metadata.gz: e7a05a5fc057b84965f60bedd0012053a0233f0c255152f1286fbf8266ea5beabe6cf129f9779593036815e39a1bb4ef3a1464909dc812b1acd5c9c35cd60c75
7
+ data.tar.gz: fe54407b12136ee20d4d0ab7ceec99284505bdb4f221815d75ff59eb81f55eca271384149ae1e8c3ea3b8ff5da289a1fac6465bb85835350614cc6fab85e3da6
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ *.gem
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pavement_condition_index.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Andy Monroe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # PavementConditionIndex
2
+
3
+ The pavement_condition_index gem is a tool for generating Pavement Condition Inventory (PCI) scores for assessed sections of pavement. This gem follows the [ASTM Standard Practice for Forads and Parking Lots Pavement Condition Index Surveys](https://www.astm.org/Standards/D6433.htm).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pavement_condition_index'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pavement_condition_index
20
+
21
+ ## Usage
22
+
23
+ To start using the pavement_condition_index gem, first you will need pavement distress data from a series of sample surveys from within a section of pavement. Once these samples have been assessed, one simply needs to create a SectionConditionSurvey object that contains SampleUnitConditionSurveys representing the pavement section and its samply surveys respectively. Once this is complete, you can now call various methods on your SectionConditionSurvey to the final PCI score, or even the intermediate values used to calculate the PCI if you would like to double check the process.
24
+
25
+ Example Code:
26
+ ```
27
+ @asphalt_sample_survey = PavementConditionIndex::SampleUnitConditionSurvey::AsphaltSurvey.new({
28
+ area: 2500,
29
+ distresses: [
30
+ {severity: :low, type: :alligator_cracking, quantity: 5},
31
+ {severity: :low, type: :alligator_cracking, quantity: 4},
32
+ {severity: :low, type: :alligator_cracking, quantity: 4},
33
+ {severity: :high, type: :alligator_cracking, quantity: 8},
34
+ {severity: :high, type: :alligator_cracking, quantity: 6},
35
+ {severity: :low, type: :edge_cracking, quantity: 32},
36
+ {severity: :low, type: :edge_cracking, quantity: 15},
37
+ {severity: :low, type: :edge_cracking, quantity: 18},
38
+ {severity: :low, type: :edge_cracking, quantity: 24},
39
+ {severity: :low, type: :edge_cracking, quantity: 41},
40
+ {severity: :medium, type: :joint_reflection_cracking, quantity: 20},
41
+ {severity: :medium, type: :joint_reflection_cracking, quantity: 15},
42
+ {severity: :medium, type: :joint_reflection_cracking, quantity: 35},
43
+ {severity: :medium, type: :joint_reflection_cracking, quantity: 27},
44
+ {severity: :medium, type: :joint_reflection_cracking, quantity: 23},
45
+ {severity: :medium, type: :joint_reflection_cracking, quantity: 10},
46
+ {severity: :medium, type: :joint_reflection_cracking, quantity: 13},
47
+ {severity: :high, type: :patching_and_utility_cut_patching, quantity: 12},
48
+ {severity: :high, type: :patching_and_utility_cut_patching, quantity: 10},
49
+ {severity: :low, type: :potholes, quantity: 1},
50
+ {severity: :low, type: :rutting, quantity: 4},
51
+ {severity: :low, type: :rutting, quantity: 9},
52
+ {severity: :low, type: :rutting, quantity: 8},
53
+ {severity: :low, type: :weathering, quantity: 250}
54
+ ]
55
+ })
56
+
57
+ @concrete_sample_survey = PavementConditionIndex::SampleUnitConditionSurvey::ConcreteSurvey.new({
58
+ area: 2500,
59
+ number_of_slabs: 20,
60
+ distresses: [
61
+ {severity: :high, type: :joint_seal_damage, quantity: 123}, # joint_seal_damage has no 'quantity'
62
+ {severity: :low, type: :corner_break, quantity: 3},
63
+ {severity: :medium, type: :corner_break, quantity: 1},
64
+ {severity: :medium, type: :divided_slab, quantity: 3},
65
+ {severity: :medium, type: :patching_small, quantity: 4},
66
+ {severity: :medium, type: :punchouts, quantity: 2},
67
+ {severity: :low, type: :spalling_corner, quantity: 6},
68
+ {severity: :high, type: :spalling_joint, quantity: 1},
69
+ ]
70
+ })
71
+
72
+ @section_survey = PavementConditionIndex::SectionConditionSurvey.new({
73
+ sample_unit_condition_surveys: [
74
+ @asphalt_sample_survey,
75
+ @concrete_sample_survey],
76
+ total_number_of_sample_units: 30
77
+ })
78
+
79
+ @section_survey.pci.score
80
+ # => 49
81
+
82
+ @section_survey.pci.rating
83
+ # =>'Poor'
84
+
85
+ @section_survey.pci.color
86
+ # => 'fc2e1f'
87
+ ```
88
+ ## Development
89
+
90
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
91
+
92
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
93
+
94
+ ## Contributing
95
+
96
+ Bug reports and pull requests are welcome on GitHub at https://github.com/andrew-monroe/pavement_condition_index.
97
+
98
+ ## License
99
+
100
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ import "./lib/tasks/regression.rake"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pavement_condition_index"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ module PavementConditionIndex
2
+ class CdvIteration
3
+
4
+ attr_reader :deduct_values, :q
5
+
6
+ def initialize(deduct_values: ,pavement_type: ,q: )
7
+ @deduct_values = deduct_values
8
+ @q = q
9
+ @pavement_type = pavement_type
10
+ end
11
+
12
+ def adjusted_deduct_values
13
+ @adjusted_deduct_values ||= begin
14
+ c = @deduct_values.clone
15
+ a = c.shift(@q)
16
+ a += c.map {|dv| [dv,2.0].min }
17
+ a
18
+ end
19
+ end
20
+
21
+ def total_deduct_value
22
+ @total_deduct_value ||= adjusted_deduct_values.reduce(:+)
23
+ end
24
+
25
+ def corrected_deduct_value
26
+ @corrected_deduct_value ||= PavementConditionIndex::Lookups::CorrectedDeductValues.new(pavement_type: @pavement_type, q: @q).call(total_deduct_value)
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ class Numeric
2
+ def clamp min, max
3
+ [[self, max].min, min].max
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ module PavementConditionIndex
2
+ class DistressGroup
3
+
4
+ attr_reader :type, :severity, :distresses
5
+ attr_reader :size_of_sample_unit, :pavement_type
6
+
7
+ def initialize(type:nil,severity:nil,distresses:nil,size_of_sample_unit:nil,pavement_type:nil)
8
+ @type = type
9
+ @severity = severity
10
+ @distresses = distresses
11
+ @size_of_sample_unit = size_of_sample_unit
12
+ @pavement_type = pavement_type
13
+ end
14
+
15
+ def total_quantity
16
+ @total_quantity ||= @distresses.map{|distress| distress[:quantity]}.reduce(:+)
17
+ end
18
+
19
+ def density
20
+ @density ||= begin
21
+ if @type == :joint_seal_damage
22
+ 1.0
23
+ else
24
+ total_quantity/@size_of_sample_unit.to_f
25
+ end
26
+ end
27
+ end
28
+
29
+ def density_percentage
30
+ @density_percentage ||= density * 100
31
+ end
32
+
33
+ def deduct_value
34
+ @deduct_value ||= PavementConditionIndex::Lookups::DeductValues.new(pavement_type: @pavement_type, distress_type: @type, severity: @severity).call(density_percentage)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,50 @@
1
+ # generate this whole file by running the following command:
2
+ # rake regression:generate_calculated_corrected_deduct_coefficients_file > lib/pavement_condition_index/lookups/calculated_corrected_deduct_coefficients.rb
3
+
4
+ module PavementConditionIndex
5
+ module Lookups
6
+ class CalculatedCorrectedDeductCoefficients
7
+
8
+ # Output of `rake regression:generate_corrected_deduct_coefficients`
9
+ COEFFICIENTS =
10
+ {:asphalt=>
11
+ {:coefficients=>
12
+ {:q1=>[0.0, 0.9999999999999999],
13
+ :q2=>[-4.767827657379179, 0.9204018317853505, -0.001751870485036131],
14
+ :q3=>[-7.225000000000371, 0.8352547729618199, -0.0013491357069143565],
15
+ :q4=>[-12.07301341589303, 0.8359713622291058, -0.0013966718266254004],
16
+ :q5=>[-12.825902992776388, 0.7672961816305504, -0.0011578947368421164],
17
+ :q6=>[-15.061893704850672, 0.7418633900928823, -0.0010566950464396384],
18
+ :q7=>[-18.186068111455448, 0.8352115583075376, -0.0016336429308565648],
19
+ :q8=>
20
+ [-11.661042311659124,
21
+ 0.5804493464050489,
22
+ 0.0012355521155837934,
23
+ -9.988820089439906e-06],
24
+ :q9=>
25
+ [-10.821138630889415,
26
+ 0.5307870370368919,
27
+ 0.0020743464052291917,
28
+ -1.4092420593968467e-05],
29
+ :q10=>
30
+ [-33.76740887897169,
31
+ 2.045383029591749,
32
+ -0.033305999495864574,
33
+ 0.00035829181520672087,
34
+ -1.7915566098874656e-06,
35
+ 3.173417753551723e-09]}},
36
+ :concrete=>
37
+ {:coefficients=>
38
+ {:q1=>[0.0, 0.9999999999999999],
39
+ :q2=>[2.7629772961812407, 0.7731404798761636, -0.0010528250773993893],
40
+ :q3=>[-2.3389834881324347, 0.7286151960784343, -0.0008510706914344763],
41
+ :q4=>[-2.8658410732717314, 0.6712409700722424, -0.0007479360165118755],
42
+ :q5=>[-5.263725490196382, 0.6719569143446881, -0.000787796697626424],
43
+ :q6=>[-7.638157894737134, 0.6712648348813237, -0.0008214009287925783],
44
+ :q7=>[-7.904979360165406, 0.6438796439628511, -0.0007446465428276629],
45
+ :q8=>[-8.123555211558568, 0.6151412538699716, -0.0006607972136222964],
46
+ :q9=>[-8.39037667698684, 0.5877560629514988, -0.0005840428276573835],
47
+ :q10=>[-8.657198142415098, 0.5603708720330258, -0.0005072884416924711]}}}
48
+ end
49
+ end
50
+ end