urbanopt-geojson 0.2.0.pre3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10a192e307d2e97310601a894c2eac28caba1061
4
- data.tar.gz: 09a0ec17fbc7a1a5ee6101094dc6be6749d4fcee
3
+ metadata.gz: 870b9ea6276a059c4eb18b0128ab7bea9d0b1ffb
4
+ data.tar.gz: 1fe21a2f8de24867eb607672cd848574eca1226d
5
5
  SHA512:
6
- metadata.gz: 9064d122b7786d2e3b0549f4d44015267dbbbde25935c13f5397a9b82758134df8b88659fd565ae45d9340bdf7ce473f055f7a3ed30bfc902f4677df4012b633
7
- data.tar.gz: 7c4f7ffe616d5f33f22769ac9f8981db669e7b74afeb9d58a06fbd34bda8a5d47e3250c10a660a2c49e0a1ceceb04a01f8db34e8bd5cd5972a1ba1c922699bf8
6
+ metadata.gz: 0771a25df9ba8a02f4867b314c2f88a6cc2c62c7321dc14f8b055d4e7514a0bd2b0ae9341d0410358d09bbb634ccb6ce6a2215894472ef4d0a676f3341b6c231
7
+ data.tar.gz: d7a7b009954797acaf314ce6e81a60733823d9baac89493398ea787cbe0b77ef00e904beed35ae5e527a052eb93fba298344993218c2248d85b25083021335d1
@@ -1,5 +1,38 @@
1
1
  # URBANopt GeoJSON Gem
2
2
 
3
+ ## Version 0.2.0
4
+
5
+ Date Range: 12/26/19 - 03/25/20
6
+
7
+
8
+ Accepted Pull Requests:
9
+ - Fixed [#41]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/41 ), Added urbanopt-geojson, this closes #40
10
+ - Fixed [#45]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/45 ), Add script to ease updates to changelog
11
+ - Fixed [#46]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/46 ), Use URBANopt standard contributing guidelines
12
+ - Fixed [#49]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/49 ), adding unspecified to flow_direction enum #48
13
+ - Fixed [#50]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/50 ), update package-lock file with secure dependency versions
14
+ - Fixed [#51]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/51 ), update license date to include 2020
15
+ - Fixed [#52]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/52 ), Addresses issues in GeoJSON gem
16
+ - Fixed [#53]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/53 ), Remove unused travis CI file
17
+ - Fixed [#54]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/54 ), Remove Simplecov dependency
18
+ - Fixed [#55]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/55 ), Add github templates for issues and PRs
19
+ - Fixed [#56]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/56 ), Use new version of extension gem
20
+ - Fixed [#58]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/58 ), Require ISSUES for PRs to address. Makes auto-changelog easy
21
+ - Fixed [#62]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/62 ), modifying wire types enum and fixing json validation
22
+ error
23
+ - Fixed [#63]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/63 ), Require ruby < 2.3.0
24
+ - Fixed [#65]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/65 ), Use pessimistic versioning for dependencies
25
+ - Fixed [#66]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/66 ), Update Jenkinsfile
26
+ - Fixed [#68]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/68 ), fix create_other_building functionality and merge site props to feature props
27
+ - Fixed [#71]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/71 ), Adds methods for converting building class instance to hash.
28
+ - Fixed [#73]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/73 ), Warning message for number of stories
29
+ - Fixed [#74]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/74 ), prep for prerelease
30
+ - Fixed [#75]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/75 ), Fixes bug while creating
31
+ shading surface for adjacent buildings
32
+ - Fixed [#76]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/76 ), Changed name of extension file
33
+ - Fixed [#78]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/78 ), 0.2.0.pre2
34
+ - Fixed [#80]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/80 ), look for site features in project key instead of Site Origin feature
35
+
3
36
  ## Version 0.1.0
4
37
 
5
38
  * Initial release of the URBANopt GeoJSON Gem
@@ -14,9 +14,9 @@ require 'optparse/date'
14
14
 
15
15
  options = {}
16
16
  OptionParser.new do |opts|
17
- opts.banner = "Usage: change_log.rb [options]\n" +
18
- "Prints New, Open, Closed Issues, and number of accepted PRs"
19
- opts.separator ""
17
+ opts.banner = "Usage: change_log.rb [options]\n" \
18
+ 'Prints New, Open, Closed Issues, and number of accepted PRs'
19
+ opts.separator ''
20
20
 
21
21
  # defaults, go back 90 days
22
22
  options[:start_date] = Date.today - 90
@@ -8,7 +8,7 @@
8
8
  This measure reads an URBANopt GeoJSON and creates geometry for a particular building. Surrounding buildings are included as shading structures.
9
9
 
10
10
  ## Modeler Description
11
-
11
+ This measure takes in the GeoJSON file, the feature_id of the building and the surrounding buildings as arguments and add has methods to create space types and add default construction sets.
12
12
 
13
13
  ## Measure Type
14
14
  ModelMeasure
@@ -77,7 +77,9 @@ class UrbanGeometryCreation < OpenStudio::Measure::ModelMeasure
77
77
  end
78
78
 
79
79
  # define what happens when the measure is run
80
+ # rubocop:disable Metrics/AbcSize
80
81
  def run(model, runner, user_arguments)
82
+ # rubocop:enable Metrics/AbcSize
81
83
  super(model, runner, user_arguments)
82
84
  # use the built-in error checking
83
85
  if !runner.validateUserArguments(arguments(model), user_arguments)
@@ -2,13 +2,13 @@
2
2
  <schema_version>3.0</schema_version>
3
3
  <name>urban_geometry_creation</name>
4
4
  <uid>5ab85d6b-c9af-4361-8ab9-613ee99a5666</uid>
5
- <version_id>0808dbbe-ec8a-46c7-b416-cbae39e2b06c</version_id>
6
- <version_modified>20190523T021410Z</version_modified>
5
+ <version_id>cf023329-6ef3-43b3-a316-b08fabb47cd2</version_id>
6
+ <version_modified>20200327T211951Z</version_modified>
7
7
  <xml_checksum>D254E772</xml_checksum>
8
8
  <class_name>UrbanGeometryCreation</class_name>
9
9
  <display_name>UrbanGeometryCreation</display_name>
10
10
  <description>This measure reads an URBANopt GeoJSON and creates geometry for a particular building. Surrounding buildings are included as shading structures.</description>
11
- <modeler_description></modeler_description>
11
+ <modeler_description>This measure takes in the GeoJSON file, the feature_id of the building and the surrounding buildings as arguments and add has methods to create space types and add default construction sets.</modeler_description>
12
12
  <arguments>
13
13
  <argument>
14
14
  <name>geojson_file</name>
@@ -43,10 +43,6 @@
43
43
  <value>ShadingOnly</value>
44
44
  <display_name>ShadingOnly</display_name>
45
45
  </choice>
46
- <choice>
47
- <value>All</value>
48
- <display_name>All</display_name>
49
- </choice>
50
46
  </choices>
51
47
  </argument>
52
48
  </arguments>
@@ -94,35 +90,29 @@
94
90
  <usage_type>readmeerb</usage_type>
95
91
  <checksum>703C9964</checksum>
96
92
  </file>
97
- <file>
98
- <filename>README.md</filename>
99
- <filetype>md</filetype>
100
- <usage_type>readme</usage_type>
101
- <checksum>D339FA87</checksum>
102
- </file>
103
93
  <file>
104
94
  <filename>LICENSE.md</filename>
105
95
  <filetype>md</filetype>
106
96
  <usage_type>license</usage_type>
107
- <checksum>B646B327</checksum>
97
+ <checksum>EA283B74</checksum>
108
98
  </file>
109
99
  <file>
110
100
  <filename>nrel_stm_footprints.geojson</filename>
111
101
  <filetype>geojson</filetype>
112
102
  <usage_type>test</usage_type>
113
- <checksum>21E06908</checksum>
103
+ <checksum>40290298</checksum>
114
104
  </file>
115
105
  <file>
116
106
  <filename>shadowed_tests.rb</filename>
117
107
  <filetype>rb</filetype>
118
108
  <usage_type>test</usage_type>
119
- <checksum>53A7DD48</checksum>
109
+ <checksum>861137CF</checksum>
120
110
  </file>
121
111
  <file>
122
112
  <filename>urban_geometry_creation_test.rb</filename>
123
113
  <filetype>rb</filetype>
124
114
  <usage_type>test</usage_type>
125
- <checksum>B55E2F27</checksum>
115
+ <checksum>6DED5C96</checksum>
126
116
  </file>
127
117
  <file>
128
118
  <version>
@@ -133,7 +123,19 @@
133
123
  <filename>measure.rb</filename>
134
124
  <filetype>rb</filetype>
135
125
  <usage_type>script</usage_type>
136
- <checksum>E152B533</checksum>
126
+ <checksum>1A6BAAFA</checksum>
127
+ </file>
128
+ <file>
129
+ <filename>out.txt</filename>
130
+ <filetype>txt</filetype>
131
+ <usage_type>test</usage_type>
132
+ <checksum>C5B18B73</checksum>
133
+ </file>
134
+ <file>
135
+ <filename>README.md</filename>
136
+ <filetype>md</filetype>
137
+ <usage_type>readme</usage_type>
138
+ <checksum>A09F345D</checksum>
137
139
  </file>
138
140
  </files>
139
141
  </measure>
@@ -70,7 +70,7 @@ class UrbanGeometryCreationTest < MiniTest::Unit::TestCase
70
70
  end
71
71
  argument_map[arg.name] = temp_arg_var
72
72
  end
73
-
73
+
74
74
  # run the measure
75
75
  measure.run(model, runner, argument_map)
76
76
  result = runner.result
@@ -5,7 +5,7 @@
5
5
  # UrbanGeometryCreationZoning
6
6
 
7
7
  ## Description
8
- This measure reads an URBANopt GeoJSON and creates geometry for a particular building. Surrounding buildings are included as shading structures.
8
+ This measure reads an URBANopt GeoJSON and creates geometry with zoning for a particular building. Surrounding buildings are included as shading structures.
9
9
 
10
10
  ## Modeler Description
11
11
 
@@ -81,7 +81,9 @@ class UrbanGeometryCreationZoning < OpenStudio::Measure::ModelMeasure
81
81
  end
82
82
 
83
83
  # define what happens when the measure is run
84
+ # rubocop:disable Metrics/AbcSize
84
85
  def run(model, runner, user_arguments)
86
+ # rubocop:enable Metrics/AbcSize
85
87
  super(model, runner, user_arguments)
86
88
  # use the built-in error checking
87
89
  if !runner.validateUserArguments(arguments(model), user_arguments)
@@ -111,8 +113,8 @@ class UrbanGeometryCreationZoning < OpenStudio::Measure::ModelMeasure
111
113
  @runner = runner
112
114
  @origin_lat_lon = nil
113
115
 
114
- all_features = URBANopt::GeoJSON::GeoFile.from_file(geojson_file)
115
- feature = URBANopt::GeoJSON::GeoFile.from_file(geojson_file).get_feature_by_id(feature_id)
116
+ all_features = URBANopt::GeoJSON::GeoFile.from_file(geojson_file)
117
+ feature = URBANopt::GeoJSON::GeoFile.from_file(geojson_file).get_feature_by_id(feature_id)
116
118
 
117
119
  # EXPOSE NAME
118
120
  name = feature.feature_json[:properties][:name]
@@ -153,7 +155,6 @@ class UrbanGeometryCreationZoning < OpenStudio::Measure::ModelMeasure
153
155
  convert_to_shades = feature.create_other_buildings(surrounding_buildings, all_features.json, model, @origin_lat_lon, @runner)
154
156
  end
155
157
 
156
-
157
158
  # intersect surfaces in this building with others
158
159
  @runner.registerInfo('Intersecting surfaces')
159
160
  spaces.each do |space|
@@ -2,12 +2,12 @@
2
2
  <schema_version>3.0</schema_version>
3
3
  <name>urban_geometry_creation_zoning</name>
4
4
  <uid>96ea1317-76ac-4670-b51d-71ee3f4fdd65</uid>
5
- <version_id>63e08249-fcf1-4037-9cb4-b1188702b056</version_id>
6
- <version_modified>20190523T021410Z</version_modified>
5
+ <version_id>5109b19e-6300-4068-900e-8a989b9762c8</version_id>
6
+ <version_modified>20200327T211951Z</version_modified>
7
7
  <xml_checksum>D254E772</xml_checksum>
8
8
  <class_name>UrbanGeometryCreationZoning</class_name>
9
9
  <display_name>UrbanGeometryCreationZoning</display_name>
10
- <description>This measure reads an URBANopt GeoJSON and creates geometry for a particular building. Surrounding buildings are included as shading structures.</description>
10
+ <description>This measure reads an URBANopt GeoJSON and creates geometry with zoning for a particular building. Surrounding buildings are included as shading structures.</description>
11
11
  <modeler_description></modeler_description>
12
12
  <arguments>
13
13
  <argument>
@@ -43,10 +43,6 @@
43
43
  <value>ShadingOnly</value>
44
44
  <display_name>ShadingOnly</display_name>
45
45
  </choice>
46
- <choice>
47
- <value>All</value>
48
- <display_name>All</display_name>
49
- </choice>
50
46
  </choices>
51
47
  </argument>
52
48
  </arguments>
@@ -104,19 +100,7 @@
104
100
  <filename>LICENSE.md</filename>
105
101
  <filetype>md</filetype>
106
102
  <usage_type>license</usage_type>
107
- <checksum>B646B327</checksum>
108
- </file>
109
- <file>
110
- <filename>README.md</filename>
111
- <filetype>md</filetype>
112
- <usage_type>readme</usage_type>
113
- <checksum>15702F0A</checksum>
114
- </file>
115
- <file>
116
- <filename>urban_geometry_creation_test.rb</filename>
117
- <filetype>rb</filetype>
118
- <usage_type>test</usage_type>
119
- <checksum>111178B3</checksum>
103
+ <checksum>EA283B74</checksum>
120
104
  </file>
121
105
  <file>
122
106
  <version>
@@ -127,7 +111,25 @@
127
111
  <filename>measure.rb</filename>
128
112
  <filetype>rb</filetype>
129
113
  <usage_type>script</usage_type>
130
- <checksum>F9C7D6B2</checksum>
114
+ <checksum>EF1B3E84</checksum>
115
+ </file>
116
+ <file>
117
+ <filename>out.txt</filename>
118
+ <filetype>txt</filetype>
119
+ <usage_type>test</usage_type>
120
+ <checksum>7FAF05F3</checksum>
121
+ </file>
122
+ <file>
123
+ <filename>urban_geometry_creation_zoning_test.rb</filename>
124
+ <filetype>rb</filetype>
125
+ <usage_type>test</usage_type>
126
+ <checksum>60BFE46B</checksum>
127
+ </file>
128
+ <file>
129
+ <filename>README.md</filename>
130
+ <filetype>md</filetype>
131
+ <usage_type>readme</usage_type>
132
+ <checksum>0458EE16</checksum>
131
133
  </file>
132
134
  </files>
133
135
  </measure>
@@ -47,7 +47,7 @@ class UrbanGeometryCreationZoningTest < MiniTest::Unit::TestCase
47
47
 
48
48
  geojson_file = File.absolute_path(File.join(File.dirname(__FILE__), 'nrel_stm_footprints.geojson'))
49
49
 
50
- feature_id = '59a9ce2b42f7d007c059d2f0'
50
+ feature_id = '59a9ce2b42f7d007c059d2f0'
51
51
 
52
52
  surrounding_buildings = 'None'
53
53
 
@@ -98,7 +98,7 @@ class UrbanGeometryCreationZoningTest < MiniTest::Unit::TestCase
98
98
 
99
99
  geojson_file = File.absolute_path(File.join(File.dirname(__FILE__), 'nrel_stm_footprints.geojson'))
100
100
 
101
- feature_id = '59a9ce2b42f7d007c059d2ee'
101
+ feature_id = '59a9ce2b42f7d007c059d2ee'
102
102
 
103
103
  surrounding_buildings = 'ShadingOnly'
104
104
 
@@ -33,7 +33,6 @@ require 'urbanopt/geojson/feature'
33
33
  module URBANopt
34
34
  module GeoJSON
35
35
  class Building < URBANopt::GeoJSON::Feature
36
-
37
36
  ##
38
37
  # Used to initialize the feature. This method is inherited from the Feature class.
39
38
  def initialize(feature = {})
@@ -88,7 +87,7 @@ module URBANopt
88
87
  # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latitude and longitude of the origin.
89
88
  # * +runner+ - _Type:String_ - An instance of +OpenStudio::Measure::OSRunner+ for the measure run.
90
89
  # * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
91
- # +false+. Zoning is set to False by default.
90
+ # +false+. Zoning is set to False by default.
92
91
  # * +other_building+ - _Type:URBANopt::GeoJSON::Feature - Optional, allow the user to pass in a different building to process. This is used for creating the other buildings for shading.
93
92
  def create_building(create_method, model, origin_lat_lon, runner, zoning = false, other_building = @feature_json)
94
93
  number_of_stories = other_building[:properties][:number_of_stories]
@@ -277,14 +276,13 @@ module URBANopt
277
276
  result[:mixed_type_3_percentage] = @mixed_type_3_percentage if @mixed_type_3_percentage
278
277
  result[:mixed_type_4] = @mixed_type_4 if @mixed_type_4
279
278
  result[:mixed_type_4_percentage] = @mixed_type_4_percentage if @mixed_type_4_percentage
280
- return result
279
+ return result
281
280
  end
282
281
 
283
-
284
282
  private
285
283
 
286
284
  ##
287
- # Returns an array of instances of +OpenStudio::Model::Space+ per building
285
+ # Returns an array of instances of +OpenStudio::Model::Space+ per building.
288
286
  #
289
287
  # [Parameters]
290
288
  # * +min_elevation+ - _Type:Integer_ - Indicates minimum elevation across all buildings.
@@ -294,7 +292,9 @@ module URBANopt
294
292
  # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
295
293
  # * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
296
294
  # +false+. Zoning is set to False by default.
295
+ # rubocop:disable Style/OptionalArguments, Style/CommentedKeyword
297
296
  def create_space_per_building(min_elevation, max_elevation, model, origin_lat_lon, runner, zoning = false, other_building) #:doc:
297
+ # rubocop: enable Style/OptionalArguments, Style/CommentedKeyword
298
298
  if other_building
299
299
  geometry = other_building[:geometry]
300
300
  properties = other_building[:properties]
@@ -338,7 +338,7 @@ module URBANopt
338
338
  result << space
339
339
  end
340
340
  return result
341
- end
341
+ end
342
342
 
343
343
  ##
344
344
  # Returns an array of instances of +OpenStudio::Model::Space+ per floor.
@@ -352,8 +352,10 @@ module URBANopt
352
352
  # origin's latitude and longitude.
353
353
  # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
354
354
  # * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
355
- # +false+. Zoning is set to False by default.
355
+ # +false+. Zoning is set to False by default.
356
+ # rubocop:disable Style/CommentedKeyword
356
357
  def create_space_per_floor(story_number, floor_to_floor_height, model, origin_lat_lon, runner, zoning = false) #:doc:
358
+ # rubocop:enable Style/CommentedKeyword
357
359
  geometry = @feature_json[:geometry]
358
360
  properties = @feature_json[:properties]
359
361
  floor_prints = []
@@ -367,7 +369,7 @@ module URBANopt
367
369
  floor_print = URBANopt::GeoJSON::Helper.floor_print_from_polygon(polygon, elevation, origin_lat_lon, runner, zoning)
368
370
  if floor_print
369
371
  if zoning
370
- this_floor_prints = URBANopt::GeoJSON::Zoning.divide_floor_print(floor_print, 4.0, runner)
372
+ this_floor_prints = URBANopt::GeoJSON::Zoning.divide_floor_print(floor_print, 4.0, runner)
371
373
  floor_prints.concat(this_floor_prints)
372
374
  else
373
375
  floor_prints << floor_print
@@ -377,8 +379,8 @@ module URBANopt
377
379
  end
378
380
  # Subsequent polygons are holes, and are not supported.
379
381
  break
380
- end
381
- end
382
+ end
383
+ end
382
384
  spaces = []
383
385
  floor_prints.each do |floor_print|
384
386
  space = OpenStudio::Model::Space.fromFloorPrint(floor_print, floor_to_floor_height, model)
@@ -394,10 +396,10 @@ module URBANopt
394
396
  surface.setOutsideBoundaryCondition('Ground')
395
397
  end
396
398
  end
397
- end
399
+ end
398
400
  spaces << space
399
- end
400
-
401
+ end
402
+
401
403
  building_story = OpenStudio::Model::BuildingStory.new(model)
402
404
  building_story.setName("Building Story #{story_number}")
403
405
  spaces.each do |space|
@@ -405,11 +407,10 @@ module URBANopt
405
407
  thermal_zone = OpenStudio::Model::ThermalZone.new(model)
406
408
  thermal_zone.setName("Building Story #{story_number} ThermalZone")
407
409
  space.setThermalZone(thermal_zone)
408
- end
409
-
410
+ end
411
+
410
412
  return spaces
411
413
  end
412
-
413
- end
414
- end
415
- end
414
+ end
415
+ end
416
+ end
@@ -44,8 +44,12 @@ module URBANopt
44
44
  @feature_json = validate_feat(feature)
45
45
  end
46
46
 
47
+ # rubocop:disable Style/MethodMissing
47
48
  def method_missing(name, *args, &blk)
49
+ # rubocop:enable Style/MethodMissing
50
+ # rubocop:disable Style/GuardClause
48
51
  if @feature_json[:properties].keys.map(&:to_sym).include? name.to_sym
52
+ # rubocop:enable Style/GuardClause
49
53
  return @feature_json[:properties][name.to_sym]
50
54
  else
51
55
  super
@@ -169,8 +173,9 @@ module URBANopt
169
173
  ##
170
174
  # Used to validate the feature by checking +feature_id+ , +geometry+, +properties+
171
175
  # and +geometry_type+ .
172
-
176
+ # rubocop:disable Style/CommentedKeyword
173
177
  def validate_feat(feature) #:doc:
178
+ # rubocop:enable Style/CommentedKeyword
174
179
  if feature.nil? || feature.empty?
175
180
  raise("Feature '#{feature_id}' could not be found")
176
181
  return false
@@ -80,7 +80,7 @@ module URBANopt
80
80
 
81
81
  # initialize @@logger
82
82
  @@logger ||= URBANopt::GeoJSON.logger
83
-
83
+
84
84
  # validate each feature against schema
85
85
  geojson_file[:features].each do |feature|
86
86
  properties = feature[:properties]
@@ -93,16 +93,16 @@ module URBANopt
93
93
  # Incase detailed_model_filename present check for fewer properties
94
94
  if feature[:properties][:detailed_model_filename]
95
95
  if feature[:properties][:id].nil?
96
- raise("No id found for Building Feature")
96
+ raise('No id found for Building Feature')
97
97
  end
98
98
  if feature[:properties][:name].nil?
99
- raise("No name found for Building Feature")
99
+ raise('No name found for Building Feature')
100
100
  end
101
101
  if feature[:properties][:number_of_stories].nil?
102
102
  @@logger.warn("Number of stories is required to calculate shading using the UrbanGeometryCreation measure...ignoring #{feature[:properties][:id]} in shading calculations")
103
103
  end
104
104
  feature[:additionalProperties] = true
105
- # Else validate for all required properties in the schema
105
+ # Else validate for all required properties in the schema
106
106
  else
107
107
  errors = validate(@@building_schema, properties)
108
108
  end
@@ -114,16 +114,15 @@ module URBANopt
114
114
  errors = validate(@@electrical_junction_schema, properties)
115
115
  when 'ElectricalConnector'
116
116
  errors = validate(@@electrical_connector_schema, properties)
117
- when 'ElectricalJunction'
117
+ when 'ThermalJunction'
118
118
  errors = validate(@@thermal_junction_schema, properties)
119
119
  when 'ThermalConnector'
120
120
  errors = validate(@@thermal_connector_schema, properties)
121
121
  end
122
-
122
+
123
123
  unless errors.empty?
124
- raise ("#{type} does not adhere to schema: \n #{errors.join('\n ')}")
124
+ raise "#{type} does not adhere to schema: \n #{errors.join('\n ')}"
125
125
  end
126
-
127
126
  end
128
127
  return new(geojson_file, path)
129
128
  end
@@ -162,7 +161,9 @@ module URBANopt
162
161
  if f[:properties] && f[:properties][:id] == feature_id
163
162
  # merge site origin properties
164
163
  f = merge_site_properties(f)
164
+ # rubocop:disable Style/GuardClause
165
165
  if f[:properties][:type] == 'Building'
166
+ # rubocop:enable Style/GuardClause
166
167
  return URBANopt::GeoJSON::Building.new(f)
167
168
  elsif f[:properties] && f[:properties][:type] == 'District System'
168
169
  return URBANopt::GeoJSON::DistrictSystem.new(f)
@@ -172,9 +173,9 @@ module URBANopt
172
173
  return nil
173
174
  end
174
175
 
175
- ##
176
- # Merge Site Properties in Feature. Returns feature with site properties added to its properties section. Does not overwrite existing properties.
177
- #
176
+ ##
177
+ # Merge Site Properties in Feature. Returns feature with site properties added to its properties section. Does not overwrite existing properties.
178
+ #
178
179
  # [Parameters]
179
180
  # +feature+ - _Type:Hash_ - feature object.
180
181
  def merge_site_properties(feature)
@@ -183,23 +184,23 @@ module URBANopt
183
184
  project = @geojson_file[:project]
184
185
  end
185
186
 
186
- # this maps site properties to building/district system properties.
187
+ # this maps site properties to building/district system properties.
187
188
  add_props = [
188
- {site: :surface_elevation, feature: :surface_elevation},
189
- {site: :timesteps_per_hour, feature: :timesteps_per_hour},
190
- {site: :begin_date, feature: :begin_date},
191
- {site: :end_date, feature: :end_date},
192
- {site: :cec_climate_zone, feature: :cec_climate_zone},
193
- {site: :climate_zone, feature: :climate_zone},
194
- {site: :default_template, feature: :template},
195
- {site: :weather_filename, feature: :weather_filename},
196
- {site: :tariff_filename, feature: :tariff_filename}
189
+ { site: :surface_elevation, feature: :surface_elevation },
190
+ { site: :timesteps_per_hour, feature: :timesteps_per_hour },
191
+ { site: :begin_date, feature: :begin_date },
192
+ { site: :end_date, feature: :end_date },
193
+ { site: :cec_climate_zone, feature: :cec_climate_zone },
194
+ { site: :climate_zone, feature: :climate_zone },
195
+ { site: :default_template, feature: :template },
196
+ { site: :weather_filename, feature: :weather_filename },
197
+ { site: :tariff_filename, feature: :tariff_filename }
197
198
  ]
198
199
 
199
200
  add_props.each do |prop|
200
- if project.key?(prop[:site]) and project[prop[:site]]
201
+ if project.key?(prop[:site]) && project[prop[:site]]
201
202
  # property exists in site
202
- if !feature[:properties].key?(prop[:feature]) or feature[:properties][prop[:feature]].nil? or feature[:properties][prop[:feature]].empty?
203
+ if !feature[:properties].key?(prop[:feature]) || feature[:properties][prop[:feature]].nil? || feature[:properties][prop[:feature]].empty?
203
204
  # property does not exist in feature or is nil: add site property (don't overwrite)
204
205
  feature[:properties][prop[:feature]] = project[prop[:site]]
205
206
  end
@@ -210,10 +211,10 @@ module URBANopt
210
211
  end
211
212
 
212
213
  ##
213
- # Validate GeoJSON against schema
214
+ # Validate GeoJSON against schema.
214
215
  #
215
216
  # [Parameters]
216
- # * +data+ - + - _Type:Hash_ - Input GeoJSON file
217
+ # * +data+ - + - _Type:Hash_ - Input GeoJSON file
217
218
  def self.validate(schema_json, data)
218
219
  errors = JSON::Validator.fully_validate(schema_json, data, errors_as_objects: true)
219
220
  return errors
@@ -243,7 +244,7 @@ module URBANopt
243
244
  end
244
245
  return result
245
246
  end
246
-
247
+
247
248
  def self.get_district_system_schema(strict)
248
249
  result = nil
249
250
  File.open(File.dirname(__FILE__) + '/schema/district_system_properties.json') do |f|
@@ -256,7 +257,7 @@ module URBANopt
256
257
  end
257
258
  return result
258
259
  end
259
-
260
+
260
261
  def self.get_region_schema(strict)
261
262
  result = nil
262
263
  File.open(File.dirname(__FILE__) + '/schema/region_properties.json') do |f|
@@ -331,7 +332,6 @@ module URBANopt
331
332
  @@electrical_junction_schema = get_electrical_junction_schema(strict)
332
333
  @@thermal_connector_schema = get_thermal_connector_schema(strict)
333
334
  @@thermal_junction_schema = get_thermal_junction_schema(strict)
334
-
335
335
  end
336
336
  end
337
337
  end
@@ -216,13 +216,13 @@ module URBANopt
216
216
  #
217
217
  # [Parameters]
218
218
  # * +building+ - _Type:URBANopt::GeoJSON::Building_ - The core building that other buildings will be referenced.
219
- # * +other_building_type+ - _Type:String_ - Describes the surrounding buildings.
219
+ # * +other_building_type+ - _Type:String_ - Describes the surrounding buildings.
220
220
  # * +other_buildings+ - _Type:URBANopt::GeoJSON::FeatureCollection_ - List of surrounding buildings to include (self will be ignored if present in list).
221
221
  # * +model+ - _Type:OpenStudio::Model::Model_ - An instance of an OpenStudio Model.
222
222
  # * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latitude and longitude of the origin.
223
223
  # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
224
224
  # * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
225
- # +false+. Zoning is set to false by default.
225
+ # +false+. Zoning is set to false by default.
226
226
  def self.process_other_buildings(building, other_building_type, other_buildings, model, origin_lat_lon, runner, zoning = false)
227
227
  # Empty array to store the new OpenStudio model spaces that need to be converted to shading objects
228
228
  feature_points = building.feature_points(origin_lat_lon, runner, zoning)
@@ -255,7 +255,7 @@ module URBANopt
255
255
  # find the polygon of the other_building by passing it to the get_multi_polygons method
256
256
  other_building_points = building.other_points(other_building, other_height, origin_lat_lon, runner, zoning)
257
257
  shadowed = URBANopt::GeoJSON::Helper.is_shadowed(feature_points, other_building_points, origin_lat_lon)
258
- next unless shadowed
258
+ next unless shadowed
259
259
  new_building = building.create_other_building(:space_per_building, model, origin_lat_lon, runner, zoning, other_building)
260
260
  if new_building.nil? || new_building.empty?
261
261
  runner.registerWarning("Failed to create spaces for other building '#{name}'")
@@ -264,7 +264,6 @@ module URBANopt
264
264
 
265
265
  elsif other_building_type == 'None'
266
266
  end
267
-
268
267
  end
269
268
  return other_spaces
270
269
  end
@@ -32,54 +32,54 @@ require 'urbanopt/scenario'
32
32
  require 'json'
33
33
 
34
34
  module URBANopt
35
- module GeoJSON
36
- class Mapper < MapperBase
37
- @@instance_lock = Mutex.new
38
- @@osw = nil
35
+ module GeoJSON
36
+ class Mapper < MapperBase
37
+ @@instance_lock = Mutex.new
38
+ @@osw = nil
39
39
 
40
- ##
41
- # This class inherits from the +MapperBase+ .
42
- # Used to perform initializing functions, used to define the osw_path for
43
- # baseline.osw for the URBANopt GeoJSON example project and the weather file.
40
+ ##
41
+ # This class inherits from the +MapperBase+ .
42
+ # Used to perform initializing functions, used to define the osw_path for
43
+ # baseline.osw for the URBANopt GeoJSON example project and the weather file.
44
44
 
45
- def initialize()
46
- @@instance_lock.synchronize do
47
- if @@osw.nil?
48
- osw_path = File.join(File.dirname(__FILE__), 'baseline.osw')
49
- File.open(osw_path, 'r') do |file|
50
- @@osw = JSON.parse(file.read, symbolize_names: true)
51
- end
52
- @@osw[:file_paths] << File.join(File.dirname(__FILE__), '../weather/')
53
- @@osw = OpenStudio::Extension.configure_osw(@@osw)
54
- end
55
- end
56
-
57
- ##
58
- # Creates an OpenStudio Workflow file for a given ScenarioBase object,
59
- # feature id and feature name.
60
- #
61
- # [Parameters]
62
- # * +scenario+ - _Type:String_ - Used to define the Scenario for the osw.
63
-
64
- # * +feature_id+ - _Type:String/Number_ - Used to define the feature_id for
65
- # which the osw is implemented.
66
- #
67
- # * +feature_name+ - _Type:String_ - The name of the feature.
68
- def create_osw(scenario, feature_id, feature_name)
69
- # get the feature from the scenario's feature_file #:nodoc:
70
- feature_file = scenario.feature_file
71
- feature = feature_file.get_feature_by_id(feature_id)
72
-
73
- raise "Cannot find feature '#{feature_id}' in '#{scenario.geometry_file}'" if feature.nil?
74
-
75
- # deep clone of @@osw before we configure it #:nodoc:
76
- osw = Marshal.load(Marshal.dump(@@osw))
77
-
78
- osw[:name] = feature_name
79
- osw[:description] = feature_name
80
-
81
- return osw
45
+ def initialize
46
+ @@instance_lock.synchronize do
47
+ if @@osw.nil?
48
+ osw_path = File.join(File.dirname(__FILE__), 'baseline.osw')
49
+ File.open(osw_path, 'r') do |file|
50
+ @@osw = JSON.parse(file.read, symbolize_names: true)
82
51
  end
52
+ @@osw[:file_paths] << File.join(File.dirname(__FILE__), '../weather/')
53
+ @@osw = OpenStudio::Extension.configure_osw(@@osw)
54
+ end
83
55
  end
56
+
57
+ ##
58
+ # Creates an OpenStudio Workflow file for a given ScenarioBase object,
59
+ # feature id and feature name.
60
+ #
61
+ # [Parameters]
62
+ # * +scenario+ - _Type:String_ - Used to define the Scenario for the osw.
63
+ # * +feature_id+ - _Type:String/Number_ - Used to define the feature_id for
64
+ # which the osw is implemented.
65
+ #
66
+ # * +feature_name+ - _Type:String_ - The name of the feature.
67
+ # rubocop:disable Lint/NestedMethodDefinition
68
+ def create_osw(scenario, feature_id, feature_name)
69
+ # rubocop:enable Lint/NestedMethodDefinition
70
+ # get the feature from the scenario's feature_file #:nodoc:
71
+ feature_file = scenario.feature_file
72
+ feature = feature_file.get_feature_by_id(feature_id)
73
+ raise "Cannot find feature '#{feature_id}' in '#{scenario.geometry_file}'" if feature.nil?
74
+ # deep clone of @@osw before we configure it #:nodoc:
75
+ osw = Marshal.load(Marshal.dump(@@osw))
76
+ osw[:name] = feature_name
77
+ osw[:description] = feature_name
78
+ end
79
+ # rubocop:disable Lint/ReturnInVoidContext
80
+ return osw
81
+ # rubocop:enable Lint/ReturnInVoidContext
82
+ end
84
83
  end
85
- end
84
+ end
85
+ end
@@ -97,6 +97,6 @@ geojson[:features].each do |feature|
97
97
  # std::vector<Point3d> toLocalCartesian(const std::vector<PointLatLon>& points) const;
98
98
  end
99
99
 
100
- File.open(ARGV[0], 'w') do |file|
100
+ File.open(ARGV[0], 'w') do |file| # rubocop:disable Lint/ShadowingOuterLocalVariable
101
101
  file << JSON.pretty_generate(geojson)
102
102
  end
@@ -133,7 +133,9 @@ Dir.glob('denver_district*.geojson').each do |p|
133
133
  end
134
134
 
135
135
  all_errors[p][-1].concat(errors)
136
+ # rubocop:disable Lint/RescueException
136
137
  rescue Exception => e
138
+ # rubocop:enable Lint/RescueException
137
139
  all_errors[p][-1] << "Error '#{e.message}' occurred: "
138
140
  all_errors[p][-1] << e.backtrace.to_s
139
141
  end
@@ -30,6 +30,6 @@
30
30
 
31
31
  module URBANopt
32
32
  module GeoJSON
33
- VERSION = '0.2.0.pre3'.freeze
33
+ VERSION = '0.2.0'.freeze
34
34
  end
35
35
  end
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  # this is not working right now
29
29
  # spec.required_ruby_version = '~> 2.2.4'
30
-
30
+
31
31
  spec.add_development_dependency 'bundler', '~> 1.14'
32
- spec.add_development_dependency 'rake', '12.3.1'
33
- spec.add_development_dependency 'rspec', '3.7.0'
32
+ spec.add_development_dependency 'rake', '~> 12.3'
33
+ spec.add_development_dependency 'rspec', '~> 3.7'
34
34
 
35
35
  # lock the version of these dependencies due to using older version of Ruby.
36
36
  spec.add_dependency 'public_suffix', '3.1.1'
@@ -38,5 +38,5 @@ Gem::Specification.new do |spec|
38
38
  # other dependencies
39
39
  spec.add_dependency 'json-schema'
40
40
  spec.add_dependency 'openstudio-extension', '~> 0.1.5'
41
- spec.add_dependency 'urbanopt-core', '~> 0.1.0'
41
+ spec.add_dependency 'urbanopt-core', '~> 0.2.0'
42
42
  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.2.0.pre3
4
+ version: 0.2.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-03-20 00:00:00.000000000 Z
13
+ date: 2020-03-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -30,30 +30,30 @@ dependencies:
30
30
  name: rake
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - '='
33
+ - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 12.3.1
35
+ version: '12.3'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - '='
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 12.3.1
42
+ version: '12.3'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rspec
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '='
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 3.7.0
49
+ version: '3.7'
50
50
  type: :development
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '='
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 3.7.0
56
+ version: '3.7'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: public_suffix
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -102,14 +102,14 @@ dependencies:
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: 0.1.0
105
+ version: 0.2.0
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: 0.1.0
112
+ version: 0.2.0
113
113
  description: Library and measures to translate URBANopt GeoJSON format to OpenStudio
114
114
  email:
115
115
  - tanushree.charan@nrel.gov
@@ -232,9 +232,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  requirements:
235
- - - ">"
235
+ - - ">="
236
236
  - !ruby/object:Gem::Version
237
- version: 1.3.1
237
+ version: '0'
238
238
  requirements: []
239
239
  rubyforge_project:
240
240
  rubygems_version: 2.4.5.1