urbanopt-geojson 0.3.0.pre1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,139 +0,0 @@
1
- # *********************************************************************************
2
- # URBANopt, 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
-
31
- require 'openstudio'
32
- require 'openstudio/ruleset/ShowRunnerOutput'
33
- require 'minitest/autorun'
34
- require_relative '../measure.rb'
35
- require 'fileutils'
36
-
37
- class UrbanGeometryCreationZoningTest < MiniTest::Unit::TestCase
38
- def test_one_building
39
- # create an instance of the measure
40
- measure = UrbanGeometryCreationZoning.new
41
-
42
- # create an empty model
43
- model = OpenStudio::Model::Model.new
44
-
45
- # create an instance of a runner
46
- runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
47
-
48
- geojson_file = File.absolute_path(File.join(File.dirname(__FILE__), 'nrel_stm_footprints.geojson'))
49
-
50
- feature_id = '59a9ce2b42f7d007c059d2f0'
51
-
52
- surrounding_buildings = 'None'
53
-
54
- # get arguments
55
- arguments = measure.arguments(model)
56
- argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
57
-
58
- # create hash of argument values.
59
- # If the argument has a default that you want to use, you don't need it in the hash
60
- args_hash = {}
61
- args_hash['geojson_file'] = geojson_file
62
- args_hash['feature_id'] = feature_id
63
- args_hash['surrounding_buildings'] = surrounding_buildings
64
-
65
- # populate argument with specified hash value if specified
66
- arguments.each do |arg|
67
- temp_arg_var = arg.clone
68
- if args_hash[arg.name]
69
- assert(temp_arg_var.setValue(args_hash[arg.name]))
70
- end
71
- argument_map[arg.name] = temp_arg_var
72
- end
73
-
74
- # run the measure
75
- measure.run(model, runner, argument_map)
76
- result = runner.result
77
-
78
- # save the model to test output directory
79
- output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + "/output/#{feature_id}.osm")
80
- model.save(output_file_path, true)
81
-
82
- # show the output
83
- show_output(result)
84
-
85
- # assert that it ran correctly
86
- assert_equal('Success', result.value.valueName)
87
- end
88
-
89
- def test_one_building_w_surrounding_buildings
90
- # create an instance of the measure
91
- measure = UrbanGeometryCreationZoning.new
92
-
93
- # create an empty model
94
- model = OpenStudio::Model::Model.new
95
-
96
- # create an instance of a runner
97
- runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
98
-
99
- geojson_file = File.absolute_path(File.join(File.dirname(__FILE__), 'nrel_stm_footprints.geojson'))
100
-
101
- feature_id = '59a9ce2b42f7d007c059d2ee'
102
-
103
- surrounding_buildings = 'ShadingOnly'
104
-
105
- # get arguments
106
- arguments = measure.arguments(model)
107
- argument_map = OpenStudio::Measure.convertOSArgumentVectorToMap(arguments)
108
-
109
- # create hash of argument values.
110
- # If the argument has a default that you want to use, you don't need it in the hash
111
- args_hash = {}
112
- args_hash['geojson_file'] = geojson_file
113
- args_hash['feature_id'] = feature_id
114
- args_hash['surrounding_buildings'] = surrounding_buildings
115
-
116
- # populate argument with specified hash value if specified
117
- arguments.each do |arg|
118
- temp_arg_var = arg.clone
119
- if args_hash[arg.name]
120
- assert(temp_arg_var.setValue(args_hash[arg.name]))
121
- end
122
- argument_map[arg.name] = temp_arg_var
123
- end
124
-
125
- # run the measure
126
- measure.run(model, runner, argument_map)
127
- result = runner.result
128
-
129
- # save the model to test output directory
130
- output_file_path = OpenStudio::Path.new(File.dirname(__FILE__) + "/output/#{feature_id}.osm")
131
- model.save(output_file_path, true)
132
-
133
- # show the output
134
- show_output(result)
135
-
136
- # assert that it ran correctly
137
- assert_equal('Success', result.value.valueName)
138
- end
139
- end