Class: URBANopt::GeoJSON::ScaleArea
- Inherits:
-
Object
- Object
- URBANopt::GeoJSON::ScaleArea
- Defined in:
- lib/urbanopt/geojson/scale_area.rb
Instance Attribute Summary collapse
-
#eps ⇒ Object
readonly
Returns the value of attribute eps.
-
#new_vertices ⇒ Object
readonly
Returns the value of attribute new_vertices.
-
#one ⇒ Object
readonly
Returns the value of attribute one.
-
#ten ⇒ Object
readonly
Returns the value of attribute ten.
-
#two ⇒ Object
readonly
Returns the value of attribute two.
-
#zero ⇒ Object
readonly
Returns the value of attribute zero.
Instance Method Summary collapse
-
#initialize(vertices, desired_area, runner, eps) ⇒ ScaleArea
constructor
A new instance of ScaleArea.
-
#values(x) ⇒ Object
Used to determine new scaled vertices, by iteratively passing in the perimeter distance to minimise the difference of the new and scaled area.
Constructor Details
#initialize(vertices, desired_area, runner, eps) ⇒ ScaleArea
Returns a new instance of ScaleArea.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 29 def initialize(vertices, desired_area, runner, eps) @vertices = vertices @centroid = OpenStudio.getCentroid(vertices) raise "Cannot compute centroid for '#{vertices}'" if @centroid.empty? @centroid = @centroid.get @desired_area = desired_area @new_vertices = vertices @runner = runner @zero = BigDecimal('0.0') @one = BigDecimal('1.0') @two = BigDecimal('2.0') @ten = BigDecimal('10.0') @eps = eps end |
Instance Attribute Details
#eps ⇒ Object (readonly)
Returns the value of attribute eps.
45 46 47 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 45 def eps @eps end |
#new_vertices ⇒ Object (readonly)
Returns the value of attribute new_vertices.
45 46 47 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 45 def new_vertices @new_vertices end |
#one ⇒ Object (readonly)
Returns the value of attribute one.
45 46 47 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 45 def one @one end |
#ten ⇒ Object (readonly)
Returns the value of attribute ten.
45 46 47 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 45 def ten @ten end |
#two ⇒ Object (readonly)
Returns the value of attribute two.
45 46 47 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 45 def two @two end |
#zero ⇒ Object (readonly)
Returns the value of attribute zero.
45 46 47 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 45 def zero @zero end |
Instance Method Details
#values(x) ⇒ Object
Used to determine new scaled vertices, by iteratively passing in the perimeter distance to minimise the difference of the new and scaled area. Returns the difference of the new area and desired area.
51 52 53 54 55 56 57 58 59 |
# File 'lib/urbanopt/geojson/scale_area.rb', line 51 def values(x) @new_vertices = URBANopt::GeoJSON::Zoning.divide_floor_print(@vertices, x[0].to_f, @runner, scale = true) new_area = OpenStudio.getArea(@new_vertices) raise "Cannot compute area for '#{@new_vertices}'" if new_area.empty? new_area = new_area.get return [new_area - @desired_area] end |