urbanopt-geojson 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/CONTRIBUTING.md +1 -1
  4. data/LICENSE.md +1 -1
  5. data/RDOC_MAIN.md +1 -1
  6. data/README.md +1 -1
  7. data/Rakefile +1 -1
  8. data/doc_templates/LICENSE.md +1 -1
  9. data/doc_templates/copyright_erb.txt +1 -1
  10. data/doc_templates/copyright_js.txt +1 -1
  11. data/doc_templates/copyright_ruby.txt +1 -1
  12. data/docs/README.md +1 -1
  13. data/docs/package-lock.json +5232 -6909
  14. data/docs/package.json +9 -8
  15. data/lib/measures/urban_geometry_creation/LICENSE.md +1 -1
  16. data/lib/measures/urban_geometry_creation/README.md +1 -1
  17. data/lib/measures/urban_geometry_creation/measure.rb +19 -4
  18. data/lib/measures/urban_geometry_creation_zoning/LICENSE.md +1 -1
  19. data/lib/measures/urban_geometry_creation_zoning/README.md +1 -1
  20. data/lib/measures/urban_geometry_creation_zoning/measure.rb +1 -3
  21. data/lib/urbanopt-geojson.rb +1 -1
  22. data/lib/urbanopt/geojson.rb +2 -1
  23. data/lib/urbanopt/geojson/building.rb +53 -8
  24. data/lib/urbanopt/geojson/derived_extension.rb +1 -1
  25. data/lib/urbanopt/geojson/district_system.rb +1 -1
  26. data/lib/urbanopt/geojson/feature.rb +80 -2
  27. data/lib/urbanopt/geojson/geo_file.rb +2 -2
  28. data/lib/urbanopt/geojson/helper.rb +30 -2
  29. data/lib/urbanopt/geojson/logging.rb +1 -1
  30. data/lib/urbanopt/geojson/mapper_classes.rb +1 -1
  31. data/lib/urbanopt/geojson/model.rb +1 -1
  32. data/lib/urbanopt/geojson/region.rb +1 -1
  33. data/lib/urbanopt/geojson/scale_area.rb +91 -0
  34. data/lib/urbanopt/geojson/schema/building_properties.json +12 -7
  35. data/lib/urbanopt/geojson/schema/electrical_connector_properties.json +1 -1
  36. data/lib/urbanopt/geojson/update_areas.rb +1 -1
  37. data/lib/urbanopt/geojson/validate_geojson.rb +1 -1
  38. data/lib/urbanopt/geojson/version.rb +2 -2
  39. data/lib/urbanopt/geojson/zoning.rb +21 -16
  40. data/urbanopt-geojson-gem.gemspec +5 -8
  41. metadata +15 -14
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -0,0 +1,91 @@
1
+ # *********************************************************************************
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
+ # contributors. All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without modification,
6
+ # are permitted provided that the following conditions are met:
7
+ #
8
+ # Redistributions of source code must retain the above copyright notice, this list
9
+ # of conditions and the following disclaimer.
10
+ #
11
+ # Redistributions in binary form must reproduce the above copyright notice, this
12
+ # list of conditions and the following disclaimer in the documentation and/or other
13
+ # materials provided with the distribution.
14
+ #
15
+ # Neither the name of the copyright holder nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without specific
17
+ # prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
+ # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24
+ # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
+ # OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ # *********************************************************************************
30
+ require 'json'
31
+ require 'net/http'
32
+ require 'uri'
33
+ require 'openssl'
34
+ require 'bigdecimal/newton'
35
+
36
+ module Newton
37
+ def self.jacobian(f, fx, x)
38
+ Jacobian.jacobian(f, fx, x)
39
+ end
40
+
41
+ def self.ludecomp(a, n, zero = 0, one = 1)
42
+ LUSolve.ludecomp(a, n, zero, one)
43
+ end
44
+
45
+ def self.lusolve(a, b, ps, zero = 0.0)
46
+ LUSolve.lusolve(a, b, ps, zero)
47
+ end
48
+ end
49
+
50
+ module URBANopt
51
+ module GeoJSON
52
+ class ScaleArea
53
+ def initialize(vertices, desired_area, runner, eps)
54
+ @vertices = vertices
55
+ @centroid = OpenStudio.getCentroid(vertices)
56
+ raise "Cannot compute centroid for '#{vertices}'" if @centroid.empty?
57
+ @centroid = @centroid.get
58
+ @desired_area = desired_area
59
+ @new_vertices = vertices
60
+ @runner = runner
61
+ @zero = BigDecimal('0.0')
62
+ @one = BigDecimal('1.0')
63
+ @two = BigDecimal('2.0')
64
+ @ten = BigDecimal('10.0')
65
+ @eps = eps # BigDecimal::new(eps)
66
+ end
67
+
68
+ attr_reader :zero
69
+
70
+ attr_reader :one
71
+
72
+ attr_reader :two
73
+
74
+ attr_reader :ten
75
+
76
+ attr_reader :eps
77
+
78
+ # compute value
79
+ def values(x)
80
+ @new_vertices = URBANopt::GeoJSON::Zoning.divide_floor_print(@vertices, x[0].to_f, @runner, scale = true)
81
+ new_area = OpenStudio.getArea(@new_vertices)
82
+ raise "Cannot compute area for '#{@new_vertices}'" if new_area.empty?
83
+ new_area = new_area.get
84
+
85
+ return [new_area - @desired_area]
86
+ end
87
+
88
+ attr_reader :new_vertices
89
+ end # ScaleArea
90
+ end # GeoJSON
91
+ end # URBANopt
@@ -87,7 +87,7 @@
87
87
  "type": "string"
88
88
  },
89
89
  "floor_area": {
90
- "description": "Usable floor area (ft^2).",
90
+ "description": "Usable floor area (ft^2). Required for residential buildings, this represents conditioned floor area.",
91
91
  "type": "number"
92
92
  },
93
93
  "number_of_stories": {
@@ -95,7 +95,7 @@
95
95
  "type": "integer"
96
96
  },
97
97
  "number_of_stories_above_ground": {
98
- "description": "The number of building stories above ground. Defaults to number_of_stories.",
98
+ "description": "The number of building stories above ground. Defaults to number_of_stories. Required for residential buildings.",
99
99
  "type": "integer"
100
100
  },
101
101
  "maximum_roof_height": {
@@ -194,7 +194,7 @@
194
194
  "maximum": 100
195
195
  },
196
196
  "number_of_residential_units": {
197
- "description": "Total number of residential units in the building. Required for single-family attached or multifamily residential buildings.",
197
+ "description": "Total number of residential units in the building. Required for single-family attached and multifamily residential buildings.",
198
198
  "type": "integer"
199
199
  },
200
200
  "number_of_bedrooms": {
@@ -241,8 +241,8 @@
241
241
  "type",
242
242
  "name",
243
243
  "floor_area",
244
+ "number_of_stories_above_ground",
244
245
  "number_of_stories",
245
- "footprint_area",
246
246
  "building_type",
247
247
  "number_of_bedrooms",
248
248
  "foundation_type",
@@ -262,8 +262,8 @@
262
262
  "type",
263
263
  "name",
264
264
  "floor_area",
265
+ "number_of_stories_above_ground",
265
266
  "number_of_stories",
266
- "footprint_area",
267
267
  "building_type",
268
268
  "number_of_residential_units",
269
269
  "number_of_bedrooms",
@@ -284,8 +284,8 @@
284
284
  "type",
285
285
  "name",
286
286
  "floor_area",
287
+ "number_of_stories_above_ground",
287
288
  "number_of_stories",
288
- "footprint_area",
289
289
  "building_type",
290
290
  "number_of_residential_units",
291
291
  "number_of_bedrooms",
@@ -519,7 +519,12 @@
519
519
  "DEER 2060",
520
520
  "DEER 2065",
521
521
  "DEER 2070",
522
- "DEER 2075"
522
+ "DEER 2075",
523
+ "Residential IECC 2006 - Customizable Template Sep 2020",
524
+ "Residential IECC 2009 - Customizable Template Sep 2020",
525
+ "Residential IECC 2012 - Customizable Template Sep 2020",
526
+ "Residential IECC 2015 - Customizable Template Sep 2020",
527
+ "Residential IECC 2018 - Customizable Template Sep 2020"
523
528
  ]
524
529
  },
525
530
  "foundationType": {
@@ -88,7 +88,7 @@
88
88
  "description": "Type of electrical line",
89
89
  "type": "string",
90
90
  "enum": [
91
- "Line"
91
+ "Wire"
92
92
  ]
93
93
  },
94
94
  "WireType": {
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -30,6 +30,6 @@
30
30
 
31
31
  module URBANopt
32
32
  module GeoJSON
33
- VERSION = '0.3.1'.freeze
33
+ VERSION = '0.4.0'.freeze
34
34
  end
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # *********************************************************************************
2
- # URBANopt, Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ # URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
3
3
  # contributors. All rights reserved.
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without modification,
@@ -41,7 +41,8 @@ module URBANopt
41
41
  # * +floor_print+ - _Type:Array_ - An instance of +OpenStudio::Point3dVector.new+ .
42
42
  # * +perimeter_depth+ - _Type:Float_ - Represents perimeter depth.
43
43
  # * +runner+ - _Type:String_ - Measure run's instance of +OpenStudio::Measure::OSRunner+ .
44
- def self.divide_floor_print(floor_print, perimeter_depth, runner)
44
+ # * +scale+ - _Type:Boolean_ - Checks whether floor print is to be scaled. Default is false.
45
+ def self.divide_floor_print(floor_print, perimeter_depth, runner, scale = false)
45
46
  result = []
46
47
  t_inv = OpenStudio::Transformation.alignFace(floor_print)
47
48
  t = t_inv.inverse
@@ -86,21 +87,25 @@ module URBANopt
86
87
  if self_intersects
87
88
  runner.registerWarning('Self intersecting surface result, will not divide')
88
89
  end
89
- result << t_inv * new_vertices
90
- (0...n).each do |i|
91
- perim_vertices = OpenStudio::Point3dVector.new
92
- if i == (n - 1)
93
- perim_vertices << vertices[i]
94
- perim_vertices << vertices[0]
95
- perim_vertices << new_vertices[0]
96
- perim_vertices << new_vertices[i]
97
- else
98
- perim_vertices << vertices[i]
99
- perim_vertices << vertices[i + 1]
100
- perim_vertices << new_vertices[i + 1]
101
- perim_vertices << new_vertices[i]
90
+ if scale == true
91
+ result = t_inv * new_vertices
92
+ else
93
+ result << t_inv * new_vertices
94
+ (0...n).each do |i|
95
+ perim_vertices = OpenStudio::Point3dVector.new
96
+ if i == (n - 1)
97
+ perim_vertices << vertices[i]
98
+ perim_vertices << vertices[0]
99
+ perim_vertices << new_vertices[0]
100
+ perim_vertices << new_vertices[i]
101
+ else
102
+ perim_vertices << vertices[i]
103
+ perim_vertices << vertices[i + 1]
104
+ perim_vertices << new_vertices[i + 1]
105
+ perim_vertices << new_vertices[i]
106
+ end
107
+ result << t_inv * perim_vertices
102
108
  end
103
- result << t_inv * perim_vertices
104
109
  end
105
110
  return result
106
111
  end
@@ -9,9 +9,10 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Tanushree Charan', 'Nicholas Long', 'Dan Macumber']
10
10
  spec.email = ['tanushree.charan@nrel.gov', 'nicholas.long@nrel.gov', 'daniel.macumber@nrel.gov']
11
11
 
12
- spec.summary = 'Library and measures to translate URBANopt GeoJSON format to OpenStudio'
12
+ spec.summary = 'Translate URBANopt GeoJSON format to OpenStudio'
13
13
  spec.description = 'Library and measures to translate URBANopt GeoJSON format to OpenStudio'
14
14
  spec.homepage = 'https://github.com/urbanopt/urbanopt-geojson-gem'
15
+ spec.licenses = 'Nonstandard'
15
16
 
16
17
  # Specify which files should be added to the gem when it is released.
17
18
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -28,11 +29,7 @@ Gem::Specification.new do |spec|
28
29
  spec.add_development_dependency 'rake', '~> 13.0'
29
30
  spec.add_development_dependency 'rspec', '~> 3.7'
30
31
 
31
- # lock the version of these dependencies due to using older version of Ruby.
32
- # spec.add_dependency 'public_suffix', '3.1.1'
33
-
34
- # other dependencies
35
- spec.add_dependency 'json-schema'
36
- spec.add_dependency 'openstudio-extension', '~> 0.2.3'
37
- spec.add_dependency 'urbanopt-core', '~> 0.3.0'
32
+ spec.add_runtime_dependency 'json-schema', '~> 2.8'
33
+ spec.add_runtime_dependency 'openstudio-extension', '~> 0.2.5'
34
+ spec.add_runtime_dependency 'urbanopt-core', '~> 0.4.0'
38
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: urbanopt-geojson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanushree Charan
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-08-07 00:00:00.000000000 Z
13
+ date: 2020-09-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -58,44 +58,44 @@ dependencies:
58
58
  name: json-schema
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0'
63
+ version: '2.8'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '0'
70
+ version: '2.8'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: openstudio-extension
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 0.2.3
77
+ version: 0.2.5
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 0.2.3
84
+ version: 0.2.5
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: urbanopt-core
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: 0.3.0
91
+ version: 0.4.0
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 0.3.0
98
+ version: 0.4.0
99
99
  description: Library and measures to translate URBANopt GeoJSON format to OpenStudio
100
100
  email:
101
101
  - tanushree.charan@nrel.gov
@@ -179,6 +179,7 @@ files:
179
179
  - lib/urbanopt/geojson/mapper_classes.rb
180
180
  - lib/urbanopt/geojson/model.rb
181
181
  - lib/urbanopt/geojson/region.rb
182
+ - lib/urbanopt/geojson/scale_area.rb
182
183
  - lib/urbanopt/geojson/schema/building_properties.json
183
184
  - lib/urbanopt/geojson/schema/district_system_properties.json
184
185
  - lib/urbanopt/geojson/schema/electrical_connector_properties.json
@@ -199,7 +200,8 @@ files:
199
200
  - package-lock.json
200
201
  - urbanopt-geojson-gem.gemspec
201
202
  homepage: https://github.com/urbanopt/urbanopt-geojson-gem
202
- licenses: []
203
+ licenses:
204
+ - Nonstandard
203
205
  metadata: {}
204
206
  post_install_message:
205
207
  rdoc_options: []
@@ -216,9 +218,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
218
  - !ruby/object:Gem::Version
217
219
  version: '0'
218
220
  requirements: []
219
- rubyforge_project:
220
- rubygems_version: 2.7.6
221
+ rubygems_version: 3.1.4
221
222
  signing_key:
222
223
  specification_version: 4
223
- summary: Library and measures to translate URBANopt GeoJSON format to OpenStudio
224
+ summary: Translate URBANopt GeoJSON format to OpenStudio
224
225
  test_files: []