urbanopt-geojson 0.3.1 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +2 -2
- data/CHANGELOG.md +48 -4
- data/CONTRIBUTING.md +1 -1
- data/LICENSE.md +29 -17
- data/RDOC_MAIN.md +26 -22
- data/README.md +2 -2
- data/Rakefile +16 -6
- data/doc_templates/LICENSE.md +27 -17
- data/doc_templates/copyright_erb.txt +40 -30
- data/doc_templates/copyright_js.txt +1 -1
- data/doc_templates/copyright_ruby.txt +17 -7
- data/docs/.vuepress/components/InnerJsonSchema.vue +7 -11
- data/docs/.vuepress/config.js +11 -1
- data/docs/.vuepress/highlight.js +1 -1
- data/docs/.vuepress/json-schema-deref-loader.js +22 -0
- data/docs/README.md +3 -4
- data/docs/package-lock.json +5280 -6960
- data/docs/package.json +10 -8
- data/lib/measures/urban_geometry_creation/LICENSE.md +27 -17
- data/lib/measures/urban_geometry_creation/README.md +8 -0
- data/lib/measures/urban_geometry_creation/measure.rb +34 -9
- data/lib/measures/urban_geometry_creation/measure.xml +33 -14
- data/lib/measures/urban_geometry_creation_zoning/LICENSE.md +27 -17
- data/lib/measures/urban_geometry_creation_zoning/measure.rb +16 -8
- data/lib/measures/urban_geometry_creation_zoning/measure.xml +11 -11
- data/lib/urbanopt-geojson.rb +16 -6
- data/lib/urbanopt/geojson.rb +17 -6
- data/lib/urbanopt/geojson/building.rb +76 -15
- data/lib/urbanopt/geojson/derived_extension.rb +16 -6
- data/lib/urbanopt/geojson/district_system.rb +16 -6
- data/lib/urbanopt/geojson/feature.rb +102 -9
- data/lib/urbanopt/geojson/geo_file.rb +18 -8
- data/lib/urbanopt/geojson/helper.rb +52 -7
- data/lib/urbanopt/geojson/logging.rb +16 -6
- data/lib/urbanopt/geojson/mapper_classes.rb +16 -6
- data/lib/urbanopt/geojson/model.rb +1 -1
- data/lib/urbanopt/geojson/region.rb +1 -1
- data/lib/urbanopt/geojson/scale_area.rb +95 -0
- data/lib/urbanopt/geojson/schema/building_properties.json +57 -13
- data/lib/urbanopt/geojson/schema/electrical_connector_properties.json +24 -15
- data/lib/urbanopt/geojson/schema/thermal_connector_properties.json +1 -1
- data/lib/urbanopt/geojson/schema/thermal_junction_properties.json +1 -1
- data/lib/urbanopt/geojson/update_areas.rb +1 -1
- data/lib/urbanopt/geojson/validate_geojson.rb +1 -1
- data/lib/urbanopt/geojson/version.rb +2 -2
- data/lib/urbanopt/geojson/zoning.rb +21 -16
- data/urbanopt-geojson-gem.gemspec +4 -8
- metadata +12 -24
data/lib/urbanopt/geojson.rb
CHANGED
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
2
|
+
# URBANopt™, Copyright (c) 2019-2021, 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,
|
6
6
|
# are permitted provided that the following conditions are met:
|
7
|
-
|
7
|
+
|
8
8
|
# Redistributions of source code must retain the above copyright notice, this list
|
9
9
|
# of conditions and the following disclaimer.
|
10
|
-
|
10
|
+
|
11
11
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
12
|
# list of conditions and the following disclaimer in the documentation and/or other
|
13
13
|
# materials provided with the distribution.
|
14
|
-
|
14
|
+
|
15
15
|
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
16
|
# used to endorse or promote products derived from this software without specific
|
17
17
|
# prior written permission.
|
18
|
-
|
18
|
+
|
19
|
+
# Redistribution of this software, without modification, must refer to the software
|
20
|
+
# by the same designation. Redistribution of a modified version of this software
|
21
|
+
# (i) may not refer to the modified version by the same designation, or by any
|
22
|
+
# confusingly similar designation, and (ii) must refer to the underlying software
|
23
|
+
# originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
|
24
|
+
# the term “URBANopt”, or any confusingly similar designation may not be used to
|
25
|
+
# refer to any modified version of this software or any modified version of the
|
26
|
+
# underlying software originally provided by Alliance without the prior written
|
27
|
+
# consent of Alliance.
|
28
|
+
|
19
29
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
30
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
31
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -39,3 +49,4 @@ require 'urbanopt/geojson/zoning'
|
|
39
49
|
require 'urbanopt/geojson/model'
|
40
50
|
require 'urbanopt/geojson/derived_extension'
|
41
51
|
require 'urbanopt/geojson/logging'
|
52
|
+
require 'urbanopt/geojson/scale_area'
|
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
2
|
+
# URBANopt™, Copyright (c) 2019-2021, 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,
|
6
6
|
# are permitted provided that the following conditions are met:
|
7
|
-
|
7
|
+
|
8
8
|
# Redistributions of source code must retain the above copyright notice, this list
|
9
9
|
# of conditions and the following disclaimer.
|
10
|
-
|
10
|
+
|
11
11
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
12
|
# list of conditions and the following disclaimer in the documentation and/or other
|
13
13
|
# materials provided with the distribution.
|
14
|
-
|
14
|
+
|
15
15
|
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
16
|
# used to endorse or promote products derived from this software without specific
|
17
17
|
# prior written permission.
|
18
|
-
|
18
|
+
|
19
|
+
# Redistribution of this software, without modification, must refer to the software
|
20
|
+
# by the same designation. Redistribution of a modified version of this software
|
21
|
+
# (i) may not refer to the modified version by the same designation, or by any
|
22
|
+
# confusingly similar designation, and (ii) must refer to the underlying software
|
23
|
+
# originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
|
24
|
+
# the term “URBANopt”, or any confusingly similar designation may not be used to
|
25
|
+
# refer to any modified version of this software or any modified version of the
|
26
|
+
# underlying software originally provided by Alliance without the prior written
|
27
|
+
# consent of Alliance.
|
28
|
+
|
19
29
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
30
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
31
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -87,9 +97,11 @@ module URBANopt
|
|
87
97
|
# * +origin_lat_lon+ - _Type:Float_ - An instance of +OpenStudio::PointLatLon+ indicating the latitude and longitude of the origin.
|
88
98
|
# * +runner+ - _Type:String_ - An instance of +OpenStudio::Measure::OSRunner+ for the measure run.
|
89
99
|
# * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
|
90
|
-
# +false
|
100
|
+
# +false+ Zoning is set to False by default.
|
101
|
+
# * +scaled_footprint_area+ - Used to scale the footprint area using the floor area. 0 by
|
102
|
+
# default (no scaling).
|
91
103
|
# * +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.
|
92
|
-
def create_building(create_method, model, origin_lat_lon, runner, zoning = false, other_building = @feature_json)
|
104
|
+
def create_building(create_method, model, origin_lat_lon, runner, zoning = false, scaled_footprint_area = 0, other_building = @feature_json)
|
93
105
|
number_of_stories = other_building[:properties][:number_of_stories]
|
94
106
|
number_of_stories_above_ground = other_building[:properties][:number_of_stories_above_ground]
|
95
107
|
number_of_stories_below_ground = other_building[:properties][:number_of_stories_below_ground]
|
@@ -128,7 +140,7 @@ module URBANopt
|
|
128
140
|
spaces = []
|
129
141
|
if create_method == :space_per_floor || create_method == :spaces_per_floor
|
130
142
|
(-number_of_stories_below_ground + 1..number_of_stories_above_ground).each do |story_number|
|
131
|
-
new_spaces = create_space_per_floor(story_number, floor_to_floor_height, model, origin_lat_lon, runner, zoning)
|
143
|
+
new_spaces = create_space_per_floor(story_number, floor_to_floor_height, model, origin_lat_lon, runner, zoning, scaled_footprint_area)
|
132
144
|
spaces.concat(new_spaces)
|
133
145
|
end
|
134
146
|
elsif create_method == :space_per_building
|
@@ -248,9 +260,50 @@ module URBANopt
|
|
248
260
|
end
|
249
261
|
|
250
262
|
##
|
251
|
-
#
|
263
|
+
# Used to calculate the perimeter from the floor polygon of a Feature. Returns the perimeter
|
264
|
+
# value.
|
265
|
+
#
|
266
|
+
# [Parameters]
|
267
|
+
# * +feature+ - An instance of URBANopt::GeoJSON::Feature
|
268
|
+
#
|
269
|
+
def calculate_perimeter(feature)
|
270
|
+
model = OpenStudio::Model::Model.new
|
271
|
+
runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
|
272
|
+
origin_lat_lon = nil
|
273
|
+
origin_lat_lon = feature.create_origin_lat_lon(runner)
|
274
|
+
spaces = feature.create_building(:space_per_building, model, origin_lat_lon, runner)
|
275
|
+
surfaces = spaces[0].surfaces
|
276
|
+
ground_surface = nil
|
277
|
+
surfaces.each do |surface|
|
278
|
+
boundary_condition = surface.outsideBoundaryCondition
|
279
|
+
if boundary_condition == 'Ground'
|
280
|
+
ground_surface = surface
|
281
|
+
end
|
282
|
+
end
|
283
|
+
vertices = ground_surface.vertices
|
284
|
+
n = vertices.size
|
285
|
+
perimeter = 0
|
286
|
+
for i in (0..n - 1) do i
|
287
|
+
vertex_1 = nil
|
288
|
+
vertex_2 = nil
|
289
|
+
if i == n - 1
|
290
|
+
vertex_1 = vertices[n - 1]
|
291
|
+
vertex_2 = vertices[0]
|
292
|
+
else
|
293
|
+
vertex_1 = vertices[i]
|
294
|
+
vertex_2 = vertices[i + 1]
|
295
|
+
end
|
296
|
+
length = OpenStudio::Vector3d.new(vertex_2 - vertex_1).length
|
297
|
+
perimeter += length
|
298
|
+
end
|
299
|
+
perimeter = OpenStudio.convert(perimeter, 'm', 'ft').get
|
300
|
+
perimeter = perimeter.round(4)
|
301
|
+
return perimeter
|
302
|
+
end
|
303
|
+
|
252
304
|
##
|
253
|
-
#
|
305
|
+
# Convert to a Hash equivalent for JSON serialization.
|
306
|
+
# Excludes attributes with nil value.
|
254
307
|
##
|
255
308
|
def to_hash
|
256
309
|
result = {}
|
@@ -354,10 +407,18 @@ module URBANopt
|
|
354
407
|
# * +zoning+ - _Type:Boolean_ - Value is +true+ if utilizing detailed zoning, else
|
355
408
|
# +false+. Zoning is set to False by default.
|
356
409
|
# rubocop:disable Style/CommentedKeyword
|
357
|
-
def create_space_per_floor(story_number, floor_to_floor_height, model, origin_lat_lon, runner, zoning = false) #:doc:
|
410
|
+
def create_space_per_floor(story_number, floor_to_floor_height, model, origin_lat_lon, runner, zoning = false, scaled_footprint_area) #:doc:
|
358
411
|
# rubocop:enable Style/CommentedKeyword
|
359
|
-
|
360
|
-
|
412
|
+
begin
|
413
|
+
if other_building
|
414
|
+
geometry = other_building[:geometry]
|
415
|
+
properties = other_building[:properties]
|
416
|
+
else
|
417
|
+
geometry = @feature_json[:geometry]
|
418
|
+
properties = @feature_json[:properties]
|
419
|
+
end
|
420
|
+
rescue StandardError
|
421
|
+
end
|
361
422
|
floor_prints = []
|
362
423
|
multi_polygons = get_multi_polygons
|
363
424
|
multi_polygons.each do |multi_polygon|
|
@@ -366,7 +427,7 @@ module URBANopt
|
|
366
427
|
end
|
367
428
|
multi_polygon.each do |polygon|
|
368
429
|
elevation = (story_number - 1) * floor_to_floor_height
|
369
|
-
floor_print = URBANopt::GeoJSON::Helper.floor_print_from_polygon(polygon, elevation, origin_lat_lon, runner, zoning)
|
430
|
+
floor_print = URBANopt::GeoJSON::Helper.floor_print_from_polygon(polygon, elevation, origin_lat_lon, runner, zoning, scaled_footprint_area)
|
370
431
|
if floor_print
|
371
432
|
if zoning
|
372
433
|
this_floor_prints = URBANopt::GeoJSON::Zoning.divide_floor_print(floor_print, 4.0, runner)
|
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
2
|
+
# URBANopt™, Copyright (c) 2019-2021, 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,
|
6
6
|
# are permitted provided that the following conditions are met:
|
7
|
-
|
7
|
+
|
8
8
|
# Redistributions of source code must retain the above copyright notice, this list
|
9
9
|
# of conditions and the following disclaimer.
|
10
|
-
|
10
|
+
|
11
11
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
12
|
# list of conditions and the following disclaimer in the documentation and/or other
|
13
13
|
# materials provided with the distribution.
|
14
|
-
|
14
|
+
|
15
15
|
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
16
|
# used to endorse or promote products derived from this software without specific
|
17
17
|
# prior written permission.
|
18
|
-
|
18
|
+
|
19
|
+
# Redistribution of this software, without modification, must refer to the software
|
20
|
+
# by the same designation. Redistribution of a modified version of this software
|
21
|
+
# (i) may not refer to the modified version by the same designation, or by any
|
22
|
+
# confusingly similar designation, and (ii) must refer to the underlying software
|
23
|
+
# originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
|
24
|
+
# the term “URBANopt”, or any confusingly similar designation may not be used to
|
25
|
+
# refer to any modified version of this software or any modified version of the
|
26
|
+
# underlying software originally provided by Alliance without the prior written
|
27
|
+
# consent of Alliance.
|
28
|
+
|
19
29
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
30
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
31
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
2
|
+
# URBANopt™, Copyright (c) 2019-2021, 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,
|
6
6
|
# are permitted provided that the following conditions are met:
|
7
|
-
|
7
|
+
|
8
8
|
# Redistributions of source code must retain the above copyright notice, this list
|
9
9
|
# of conditions and the following disclaimer.
|
10
|
-
|
10
|
+
|
11
11
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
12
|
# list of conditions and the following disclaimer in the documentation and/or other
|
13
13
|
# materials provided with the distribution.
|
14
|
-
|
14
|
+
|
15
15
|
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
16
|
# used to endorse or promote products derived from this software without specific
|
17
17
|
# prior written permission.
|
18
|
-
|
18
|
+
|
19
|
+
# Redistribution of this software, without modification, must refer to the software
|
20
|
+
# by the same designation. Redistribution of a modified version of this software
|
21
|
+
# (i) may not refer to the modified version by the same designation, or by any
|
22
|
+
# confusingly similar designation, and (ii) must refer to the underlying software
|
23
|
+
# originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
|
24
|
+
# the term “URBANopt”, or any confusingly similar designation may not be used to
|
25
|
+
# refer to any modified version of this software or any modified version of the
|
26
|
+
# underlying software originally provided by Alliance without the prior written
|
27
|
+
# consent of Alliance.
|
28
|
+
|
19
29
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
30
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
31
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
2
|
+
# URBANopt™, Copyright (c) 2019-2021, 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,
|
6
6
|
# are permitted provided that the following conditions are met:
|
7
|
-
|
7
|
+
|
8
8
|
# Redistributions of source code must retain the above copyright notice, this list
|
9
9
|
# of conditions and the following disclaimer.
|
10
|
-
|
10
|
+
|
11
11
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
12
|
# list of conditions and the following disclaimer in the documentation and/or other
|
13
13
|
# materials provided with the distribution.
|
14
|
-
|
14
|
+
|
15
15
|
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
16
|
# used to endorse or promote products derived from this software without specific
|
17
17
|
# prior written permission.
|
18
|
-
|
18
|
+
|
19
|
+
# Redistribution of this software, without modification, must refer to the software
|
20
|
+
# by the same designation. Redistribution of a modified version of this software
|
21
|
+
# (i) may not refer to the modified version by the same designation, or by any
|
22
|
+
# confusingly similar designation, and (ii) must refer to the underlying software
|
23
|
+
# originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
|
24
|
+
# the term “URBANopt”, or any confusingly similar designation may not be used to
|
25
|
+
# refer to any modified version of this software or any modified version of the
|
26
|
+
# underlying software originally provided by Alliance without the prior written
|
27
|
+
# consent of Alliance.
|
28
|
+
|
19
29
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
30
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
31
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -48,7 +58,7 @@ module URBANopt
|
|
48
58
|
def method_missing(name, *args, &blk)
|
49
59
|
# rubocop:enable Style/MethodMissing
|
50
60
|
if @feature_json[:properties].keys.map(&:to_sym).include? name.to_sym
|
51
|
-
|
61
|
+
|
52
62
|
return @feature_json[:properties][name.to_sym]
|
53
63
|
else
|
54
64
|
super
|
@@ -98,6 +108,89 @@ module URBANopt
|
|
98
108
|
return @@feature_schema[feature_type]
|
99
109
|
end
|
100
110
|
|
111
|
+
##
|
112
|
+
# Used to calculate the aspect ratio for a given floor polygon.
|
113
|
+
#
|
114
|
+
def calculate_aspect_ratio
|
115
|
+
multi_polygons = get_multi_polygons(@feature_json)
|
116
|
+
rad_per_deg = 0.017453293
|
117
|
+
|
118
|
+
multi_polygons.each do |multi_polygon|
|
119
|
+
if multi_polygon.size > 1
|
120
|
+
runner.registerWarning('Ignoring holes in polygon')
|
121
|
+
end
|
122
|
+
multi_polygon.each do |polygon|
|
123
|
+
n = polygon.size
|
124
|
+
length = 0
|
125
|
+
north = 0
|
126
|
+
east = 0
|
127
|
+
south = 0
|
128
|
+
west = 0
|
129
|
+
aspect_ratio = 0
|
130
|
+
|
131
|
+
for i in (0..n - 2) do i
|
132
|
+
vertex_1 = nil
|
133
|
+
vertex_2 = nil
|
134
|
+
if i == n - 2
|
135
|
+
vertex_1 = polygon[n - 2]
|
136
|
+
vertex_2 = polygon[0]
|
137
|
+
else
|
138
|
+
vertex_1 = polygon[i]
|
139
|
+
vertex_2 = polygon[i + 1]
|
140
|
+
end
|
141
|
+
x_1 = vertex_1[0]
|
142
|
+
y_1 = vertex_1[1]
|
143
|
+
x_2 = vertex_2[0]
|
144
|
+
y_2 = vertex_2[1]
|
145
|
+
|
146
|
+
dist = (x_2 - x_1)**2 + (y_2 - y_1)**2
|
147
|
+
|
148
|
+
length = Math.sqrt(dist)
|
149
|
+
|
150
|
+
# delta latitude
|
151
|
+
dlat = x_2 - x_1
|
152
|
+
# delta longitude
|
153
|
+
dlon = y_2 - y_1
|
154
|
+
|
155
|
+
# convert radian to degree
|
156
|
+
sin_angle = Math.asin(dlon / length) * (1 / rad_per_deg)
|
157
|
+
sin_angle = sin_angle.round(4)
|
158
|
+
|
159
|
+
cos_angle = Math.acos(dlat / length) * (1 / rad_per_deg)
|
160
|
+
cos_angle = cos_angle.round(4)
|
161
|
+
|
162
|
+
if cos_angle >= 45 && cos_angle <= 135 && sin_angle >= 45 && sin_angle <= 90
|
163
|
+
north += length
|
164
|
+
elsif cos_angle >= 0 && cos_angle < 45 && sin_angle > -45 && sin_angle < 45
|
165
|
+
east += length
|
166
|
+
elsif cos_angle >= 45 && cos_angle <= 135 && sin_angle >= -90 && sin_angle <= -45
|
167
|
+
south += length
|
168
|
+
elsif cos_angle > 135 && cos_angle <= 180 && sin_angle > -45 && sin_angle < 45
|
169
|
+
west += length
|
170
|
+
end
|
171
|
+
|
172
|
+
if east + west != 0
|
173
|
+
aspect_ratio = (north + south) / (east + west)
|
174
|
+
else
|
175
|
+
aspect_ratio = 1
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
aspect_ratio = aspect_ratio.round(4)
|
181
|
+
return aspect_ratio
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# Used to calculate the perimeter multiplier given the aspect ratio, original perimeter and area.
|
188
|
+
def get_perimeter_multiplier(area, aspect_ratio, perimeter_original)
|
189
|
+
perimeter_new = 2 * (Math.sqrt(area * aspect_ratio) + Math.sqrt(area / aspect_ratio))
|
190
|
+
perimeter_ratio = perimeter_original / perimeter_new
|
191
|
+
return perimeter_ratio
|
192
|
+
end
|
193
|
+
|
101
194
|
##
|
102
195
|
# Returns coordinate with the minimum longitute and latitude within a given +building_json+ .
|
103
196
|
def get_min_lon_lat
|
@@ -179,8 +272,8 @@ module URBANopt
|
|
179
272
|
|
180
273
|
x = y = z = 0.0
|
181
274
|
vertices.each do |station|
|
182
|
-
latitude = station[
|
183
|
-
longitude = station[
|
275
|
+
latitude = station[1] * Math::PI / 180
|
276
|
+
longitude = station[0] * Math::PI / 180
|
184
277
|
|
185
278
|
x += Math.cos(latitude) * Math.cos(longitude)
|
186
279
|
y += Math.cos(latitude) * Math.sin(longitude)
|
@@ -1,21 +1,31 @@
|
|
1
1
|
# *********************************************************************************
|
2
|
-
# URBANopt
|
2
|
+
# URBANopt™, Copyright (c) 2019-2021, 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,
|
6
6
|
# are permitted provided that the following conditions are met:
|
7
|
-
|
7
|
+
|
8
8
|
# Redistributions of source code must retain the above copyright notice, this list
|
9
9
|
# of conditions and the following disclaimer.
|
10
|
-
|
10
|
+
|
11
11
|
# Redistributions in binary form must reproduce the above copyright notice, this
|
12
12
|
# list of conditions and the following disclaimer in the documentation and/or other
|
13
13
|
# materials provided with the distribution.
|
14
|
-
|
14
|
+
|
15
15
|
# Neither the name of the copyright holder nor the names of its contributors may be
|
16
16
|
# used to endorse or promote products derived from this software without specific
|
17
17
|
# prior written permission.
|
18
|
-
|
18
|
+
|
19
|
+
# Redistribution of this software, without modification, must refer to the software
|
20
|
+
# by the same designation. Redistribution of a modified version of this software
|
21
|
+
# (i) may not refer to the modified version by the same designation, or by any
|
22
|
+
# confusingly similar designation, and (ii) must refer to the underlying software
|
23
|
+
# originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
|
24
|
+
# the term “URBANopt”, or any confusingly similar designation may not be used to
|
25
|
+
# refer to any modified version of this software or any modified version of the
|
26
|
+
# underlying software originally provided by Alliance without the prior written
|
27
|
+
# consent of Alliance.
|
28
|
+
|
19
29
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
20
30
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
21
31
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
@@ -162,7 +172,7 @@ module URBANopt
|
|
162
172
|
# merge site origin properties
|
163
173
|
f = merge_site_properties(f)
|
164
174
|
if f[:properties][:type] == 'Building'
|
165
|
-
|
175
|
+
|
166
176
|
return URBANopt::GeoJSON::Building.new(f)
|
167
177
|
elsif f[:properties] && f[:properties][:type] == 'District System'
|
168
178
|
return URBANopt::GeoJSON::DistrictSystem.new(f)
|
@@ -199,7 +209,7 @@ module URBANopt
|
|
199
209
|
add_props.each do |prop|
|
200
210
|
if project.key?(prop[:site]) && project[prop[:site]]
|
201
211
|
# property exists in site
|
202
|
-
if !feature[:properties].key?(prop[:feature]) || feature[:properties][prop[:feature]].nil? || feature[:properties][prop[:feature]].empty?
|
212
|
+
if !feature[:properties].key?(prop[:feature]) || feature[:properties][prop[:feature]].nil? || feature[:properties][prop[:feature]].to_s.empty?
|
203
213
|
# property does not exist in feature or is nil: add site property (don't overwrite)
|
204
214
|
feature[:properties][prop[:feature]] = project[prop[:site]]
|
205
215
|
end
|