urbanopt-geojson 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0ca815fb64a026cf561556acb856f0444f4664f6be01567ead91fbdf37610ba
4
- data.tar.gz: edeab51cd720952088f9fea05e2f023033a5b2a53884fa50354f7c1401c1d64d
3
+ metadata.gz: 700036e12142797f840026f8de8304ef5fdb00a3a0b0feac79b497374da21d51
4
+ data.tar.gz: 2cb649aba1432668cc39bf054711be6417bcde28f0f04c38679912ee64e91bd6
5
5
  SHA512:
6
- metadata.gz: b44aabc97d7682989ec08f7239259d82545e88535bfe970f94e03d2d5082bd81dbe00443320cf22be79fb1ad758347b3d69ee425ed91efb351534f796b9a812d
7
- data.tar.gz: f1b53991b8f1bf7d9727c72a6b7e4bd77b363b79f395832c7f939eda86609979f1a7c35b574828ced50b5e8808e536fdd0a0d1347a6270ea615f040332928939
6
+ metadata.gz: e52c94d2cbf68d902eb5346882ebdb731f7e12d03e28052ac1ac730b0719b340a1325c7f9dc3740d05380e1702e7d42b3ceee685a9c6ba9caef8d7164107bd8b
7
+ data.tar.gz: f2f18a2a9455c7a6e2f7ab1e278384cf8fa4f91761c6533b0fad4553da80c7e0e334181f279c630883f42739aacaa13e0b57f4c972d28b352863c2eb17238114
@@ -1,4 +1,4 @@
1
- ### Addresses #[issue number here]
1
+ ### Resolves #[issue number here]
2
2
 
3
3
  ### Pull Request Description
4
4
 
@@ -9,5 +9,5 @@
9
9
  - [ ] Unit tests have been added or updated
10
10
  - [ ] Documentation has been modified appropriately
11
11
  - [ ] All ci tests pass (green)
12
- - [ ] An [ISSUE](https://github.com/urbanopt/urbanopt-geojson-gem/issues) has been created that this is addressing. Issues will get added to the Change Log when the change_log.rb script is run.
12
+ - [ ] An [issue](https://github.com/urbanopt/urbanopt-geojson-gem/issues) has been created (which will be used for the changelog)
13
13
  - [ ] This branch is up-to-date with develop
@@ -1,7 +1,14 @@
1
1
  # URBANopt GeoJSON Gem
2
2
 
3
+ ## Version 0.5.0
4
+ Date Range 09/26/20 - 12/02/20
5
+
6
+ - Fixed [#124]( https://github.com/urbanopt/urbanopt-geojson-gem/issues/124 ), DOCUMENTATION: Add docs on scaling for building footprint using building area
7
+ - Fixed [#126]( https://github.com/urbanopt/urbanopt-geojson-gem/issues/126 ), [BUG] setting timesteps_per_hour in a feature throws an error
8
+ - Fixed [#131]( https://github.com/urbanopt/urbanopt-geojson-gem/issues/131 ), OpenStudio 3.1.0 support
9
+
3
10
  ## Version 0.4.0
4
- Date Rage 08/08/20 - 09/25/20
11
+ Date Range 08/08/20 - 09/25/20
5
12
 
6
13
  Accepted Pull Requests: 11
7
14
  - Fixed [#92]( https://github.com/urbanopt/urbanopt-geojson-gem/pull/92 ), Adds scaling for building footprint using building area
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Version 1.0
4
4
 
5
- The URBANopt<sup>&trade;</sup> team welcomes your contribution to the project. You can contribute to the URBANopt project in several ways: by using the software, reporting issues, contributing documentation, or contributing code back to the project. The GitHub [Contributing to Open Source](https://opensource.guide/how-to-contribute/) guide provides a good overview. If you contribute code, you agree that your contribution may be incorporated into the URBANopt Software Development Kit (SDK) and made available under the URBANopt SDK license.
5
+ The URBANopt&trade; team welcomes your contribution to the project. You can contribute to the URBANopt project in several ways: by using the software, reporting issues, contributing documentation, or contributing code back to the project. The GitHub [Contributing to Open Source](https://opensource.guide/how-to-contribute/) guide provides a good overview. If you contribute code, you agree that your contribution may be incorporated into the URBANopt Software Development Kit (SDK) and made available under the URBANopt SDK license.
6
6
 
7
7
  The contribution process for URBANopt is composed of three steps:
8
8
 
@@ -2,53 +2,57 @@
2
2
 
3
3
  ### [back to main docs](../)
4
4
 
5
- The URBANopt<sup>&trade;</sup> GeoJSON Gem has been developed by restructuring methods extracted from the
5
+ The URBANopt&trade; GeoJSON Gem has been developed by restructuring methods extracted from the
6
6
  [urban_geometry_creation](https://github.com/NREL/openstudio-urban-measures/tree/develop/measures/urban_geometry_creation)
7
7
  and
8
8
  [urban_geometry_creation_zoning.](https://github.com/NREL/openstudio-urban-measures/tree/develop/measures/urban_geometry_creation_zoning)
9
9
 
10
- The +urban_geometry_creation+ measure can be used to create an OpenStudio Model for a
10
+ The `urban_geometry_creation` measure can be used to create an OpenStudio Model for a
11
11
  building feature from the feature file and create the surrounding buildings that are shading the
12
12
  building feature as shading objects.
13
- The arguments used in the measure are the +GeoJSON File+, +Feature ID+ of the building and +Surrounding Buildings+. The
14
- Surrounding Buildings argument takes two possible choices - None or Shading Only. The None choice
13
+ The arguments used in the measure are the `geojson_file`, `feature_id` of the building, `surrounding_buildings` and `scale_footprint_area_by_floor_area`. The
14
+ `surrounding_buildings` argument takes two possible choices - None or Shading Only. The None choice
15
15
  would create no other buildings adjacent to the building feature while the Shading Only option
16
- determines what other buildings are shading the building feature and creates them as OpenStudio Shading Surfaces.
16
+ determines what other buildings are shading the building feature and creates them as OpenStudio
17
+ Shading Surfaces. The `scale_footprint_area_by_floor_area` is an optional argument that is set to
18
+ false by default. When set to true, the building footprint area is calculated from the
19
+ floor_area/number_of_stories for the building in the GeoJSON file and this footprint area is used to
20
+ scale the building coordinates and create the building.
17
21
 
18
- The +urban_geometry_creation_zoning+ measure has the same capabilities as the
19
- +urban_geometry_creation+ measure, however it also creates core and perimeter zones for the spaces
20
- in the OpenStudio Model. It takes in the same arguments as the +urban_geometry_creation+ measure.
22
+ The `urban_geometry_creation_zoning` measure has the same capabilities as the
23
+ `urban_geometry_creation` measure, however it also creates core and perimeter zones for the spaces
24
+ in the OpenStudio Model. It takes in the `geojson_file`, `feature_id` of the building,
25
+ `surrounding_buildings` as arguments.
21
26
 
22
27
  The main components of the gem are:
23
28
 
24
- - geojson.rb : Base gem file that imports all modules and classes.
29
+ - geojson.rb : Base gem file that imports all modules and classes.
25
30
  - extension.rb : The extension class inherits from OpenStudio::Extension::Extension, and
26
- overrides the following methods as needed -
31
+ overrides the following methods as needed
27
32
  - _measures_dir_
28
33
  - _files_dir_
29
34
  - _doc_templates_dir_
30
- - Gemfile and .gemspec : Describe the extension dependencies on other gems.
31
- - Classes and Modules within +lib/urbanopt/geojson+ -
32
-
35
+ - Gemfile and .gemspec : Describe the extension dependencies on other gems.
36
+ - Classes and Modules within `lib/urbanopt/geojson`
33
37
 
34
38
  *Modules that do not require instances for calling the methods:*
35
39
 
36
40
  - URBANopt::GeoJSON::Helper : Contains methods extracted from the two measures to
37
- perform utility-like tasks like - +is_shaded+ and +is_shadowed+.
41
+ perform utility-like tasks like - `is_shaded` and `is_shadowed`.
38
42
  - URBANopt::GeoJSON::Zoning : Contains methods extracted from
39
- +urban_geometry_creation_zoning+ .
43
+ `urban_geometry_creation_zoning`.
40
44
  - URBANopt::GeoJSON::Model : Contains methods that perform tasks on an instance of
41
- +OpenStudio::Model::Model+.
45
+ `OpenStudio::Model::Model`.
42
46
 
43
47
  *Classes and subclasses that contain instance-dependant methods and private methods
44
48
  that perform tasks on the given feature.*
45
49
 
46
- - URBANopt::GeoJSON::GeoFile : Contains a +get_feature+ method that returns an
50
+ - URBANopt::GeoJSON::GeoFile : Contains a `get_feature` method that returns an
47
51
  instance of a Feature Subclass for the the feature type. Also contains methods to validate the GeoJSON
48
- file against the GeoJSON schema.
49
- - URBANopt::GeoJSON::Feature : Contains methods to return +feature+ +id+ , +name+ ,
50
- +multiple+ +polygons+ +coordinates+ which are inherited by classes for all feature types.
52
+ file against the GeoJSON schema.
53
+ - URBANopt::GeoJSON::Feature : Contains methods to return `feature id` , `name` ,
54
+ `multiple polygons coordinates` which are inherited by classes for all feature types.
51
55
  - URBANopt::GeoJSON::Building : A subclass of Feature, contains class methods that
52
- are specific to handling features of the Building type.
56
+ are specific to handling features of the Building type.
53
57
  - URBANopt::GeoJSON::DistrictSystem : A subclass of Feature, contains class methods
54
- that are specific to handling features of District System type. *Note: This subclass does not contain any methods yet*.
58
+ that are specific to handling features of District System type. *Note: This subclass does not contain any methods yet*.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # URBANopt GeoJSON Gem
2
2
 
3
- Library and measures to translate URBANopt<sup>&trade;</sup> GeoJSON format to OpenStudio. See the [developer documentation](https://urbanopt.github.io/urbanopt-geojson-gem/) for more details.
3
+ Library and measures to translate URBANopt&trade; GeoJSON format to OpenStudio. See the [developer documentation](https://urbanopt.github.io/urbanopt-geojson-gem/) for more details.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,7 +12,7 @@ gem 'urbanopt-geojson'
12
12
 
13
13
  And then execute:
14
14
 
15
- $ bundle
15
+ $ bundle install
16
16
 
17
17
  Or install it yourself as:
18
18
 
@@ -13,7 +13,6 @@ import highlightJson from "../highlight";
13
13
  import { emptyPromise } from '../utils';
14
14
 
15
15
  const JSONSchemaViewP = emptyPromise();
16
- const $RefParserP = emptyPromise();
17
16
 
18
17
  export default {
19
18
  name: "InnerJsonSchema",
@@ -24,19 +23,16 @@ export default {
24
23
  };
25
24
  },
26
25
  created() {
26
+ // created only runs on the client, which is good because
27
+ // this module causes an error if we load it in a server context
27
28
  import("json-schema-view-js").then(JSONSchemaViewP.resolve);
28
- import("json-schema-ref-parser/dist/ref-parser.js").then($RefParserP.resolve);
29
29
  },
30
30
  computed: {
31
31
  view() {
32
- return Promise.all([$RefParserP, JSONSchemaViewP])
33
- .then(([$RefParser]) => $RefParser.default.dereference(this.schema))
34
- .then(
35
- s =>
36
- new window.JSONSchemaView(s, 2, {
37
- theme: "dark"
38
- })
39
- );
32
+ return JSONSchemaViewP
33
+ .then( () => new window.JSONSchemaView(this.schema, 2, {
34
+ theme: "dark"
35
+ }));
40
36
  },
41
37
  schemaFormatted() {
42
38
  return highlightJson(JSON.stringify(this.schema, null, 2));
@@ -44,7 +40,7 @@ export default {
44
40
  },
45
41
  methods: {
46
42
  async replaceRenderedSchema() {
47
- const v = await this.view;
43
+ const v = await this.view; // this never resolves on the server
48
44
  this.$refs.schemaTarget.innerHtml = "";
49
45
  this.$refs.schemaTarget.appendChild(v.render());
50
46
  }
@@ -1,3 +1,5 @@
1
+ const path = require('path');
2
+
1
3
  module.exports = {
2
4
  base: '/urbanopt-geojson-gem/',
3
5
  themeConfig: {
@@ -18,5 +20,13 @@ module.exports = {
18
20
  ]
19
21
  }
20
22
  ]
21
- }
23
+ },
24
+ chainWebpack: config => {
25
+ config.module
26
+ .rule('json')
27
+ .test(/\.json$/)
28
+ .use(path.join(__dirname, 'json-schema-deref-loader.js'))
29
+ .loader(path.join(__dirname, 'json-schema-deref-loader.js'))
30
+ .end()
31
+ },
22
32
  };
@@ -1,4 +1,4 @@
1
- import hljs from "highlight.js/lib/highlight.js";
1
+ import hljs from "highlight.js";
2
2
  import json from "highlight.js/lib/languages/json";
3
3
 
4
4
  hljs.registerLanguage("json", json);
@@ -0,0 +1,22 @@
1
+ // thanks to https://gist.github.com/mgesmundo/07d6ea3958ed4c7d19d1161551fa46ca
2
+ const $RefParser = require('@apidevtools/json-schema-ref-parser')
3
+
4
+ module.exports = async function () {
5
+ const parser = new $RefParser()
6
+ const schema = await parser.dereference(this.resourcePath, {
7
+ dereference: {
8
+ circular: false
9
+ }
10
+ })
11
+ const resolve = await parser.resolve(this.resourcePath, {
12
+ dereference: {
13
+ circular: false
14
+ }
15
+ })
16
+
17
+ for (const dep in resolve._$refs) {
18
+ this.addDependency(dep)
19
+ }
20
+
21
+ return JSON.stringify(schema)
22
+ }
@@ -2,9 +2,9 @@
2
2
 
3
3
  ### <StaticLink href="rdoc/">Rdocs</StaticLink>
4
4
 
5
- The URBANopt<sup>&trade;</sup> GeoJSON Gem is an OpenStudio Extension Gem with functionality to translate
5
+ The URBANopt&trade; GeoJSON Gem is an OpenStudio Extension Gem with functionality to translate
6
6
  information in a GeoJSON format to energy model inputs. GeoJSON is a commonly used
7
- format for describing geospatial data related to the built environment.
7
+ format for describing geospatial data related to the built environment.
8
8
 
9
9
  A JSON schema for the GeoJSON format is available at [geojson
10
10
  schema](https://github.com/geojson/schema).
@@ -26,5 +26,4 @@ The current functionalities of the URBANopt GeoJSON gem include:
26
26
  - Translate Building Feature to an OpenStudio Model.
27
27
  - Translate Building Feature to OpenStudio Shading Objects.
28
28
 
29
- The <StaticLink href="rdoc/">Rdocs</StaticLink> contain more information about the URBANopt GeoJSON Gem architecture.
30
-
29
+ The <StaticLink href="rdoc/">Rdocs</StaticLink> contain more information about the URBANopt GeoJSON Gem architecture.
@@ -6771,8 +6771,7 @@
6771
6771
  "picomatch": {
6772
6772
  "version": "2.2.2",
6773
6773
  "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz",
6774
- "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
6775
- "optional": true
6774
+ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg=="
6776
6775
  },
6777
6776
  "pify": {
6778
6777
  "version": "4.0.1",
@@ -249,6 +249,13 @@ module URBANopt
249
249
  end
250
250
  end
251
251
 
252
+ ##
253
+ # Used to calculate the perimeter from the floor polygon of a Feature. Returns the perimeter
254
+ # value.
255
+ #
256
+ # [Parameters]
257
+ # * +feature+ - An instance of URBANopt::GeoJSON::Feature
258
+ #
252
259
  def calculate_perimeter(feature)
253
260
  model = OpenStudio::Model::Model.new
254
261
  runner = OpenStudio::Measure::OSRunner.new(OpenStudio::WorkflowJSON.new)
@@ -285,9 +292,8 @@ module URBANopt
285
292
  end
286
293
 
287
294
  ##
288
- # Convert to a Hash equivalent for JSON serialization
289
- ##
290
- # - Exclude attributes with nil values.
295
+ # Convert to a Hash equivalent for JSON serialization.
296
+ # Excludes attributes with nil value.
291
297
  ##
292
298
  def to_hash
293
299
  result = {}
@@ -98,6 +98,9 @@ module URBANopt
98
98
  return @@feature_schema[feature_type]
99
99
  end
100
100
 
101
+ ##
102
+ # Used to calculate the aspect ratio for a given floor polygon.
103
+ #
101
104
  def calculate_aspect_ratio
102
105
  multi_polygons = get_multi_polygons(@feature_json)
103
106
  rad_per_deg = 0.017453293
@@ -170,6 +173,8 @@ module URBANopt
170
173
  end
171
174
  end
172
175
 
176
+ ##
177
+ # Used to calculate the perimeter multiplier given the aspect ratio, original perimeter and area.
173
178
  def get_perimeter_multiplier(area, aspect_ratio, perimeter_original)
174
179
  perimeter_new = 2 * (Math.sqrt(area * aspect_ratio) + Math.sqrt(area / aspect_ratio))
175
180
  perimeter_ratio = perimeter_original / perimeter_new
@@ -199,7 +199,7 @@ module URBANopt
199
199
  add_props.each do |prop|
200
200
  if project.key?(prop[:site]) && project[prop[:site]]
201
201
  # property exists in site
202
- if !feature[:properties].key?(prop[:feature]) || feature[:properties][prop[:feature]].nil? || feature[:properties][prop[:feature]].empty?
202
+ if !feature[:properties].key?(prop[:feature]) || feature[:properties][prop[:feature]].nil? || feature[:properties][prop[:feature]].to_s.empty?
203
203
  # property does not exist in feature or is nil: add site property (don't overwrite)
204
204
  feature[:properties][prop[:feature]] = project[prop[:site]]
205
205
  end
@@ -229,7 +229,14 @@ module URBANopt
229
229
  return floor_print
230
230
  end
231
231
 
232
- # scale footprint to desired area, keeping the shape
232
+ ##
233
+ # Used to scale footprint to desired area while keeping the original shape.
234
+ #
235
+ # [Parameters]
236
+ # * +vertices+ - _Type:Array_ - An array of vertices for the original floorprint
237
+ # * +desired_area+ - _Type:String_ - Area to which you want to scale the vertices to
238
+ # * +runner+ - _Type:String_ - An instance of +Openstudio::Measure::OSRunner+ for the measure run.
239
+ #
233
240
  def self.adjust_vertices_to_area(vertices, desired_area, runner, eps = 0.1)
234
241
  ar = ScaleArea.new(vertices, desired_area, runner, eps)
235
242
 
@@ -62,7 +62,7 @@ module URBANopt
62
62
  @one = BigDecimal('1.0')
63
63
  @two = BigDecimal('2.0')
64
64
  @ten = BigDecimal('10.0')
65
- @eps = eps # BigDecimal::new(eps)
65
+ @eps = eps
66
66
  end
67
67
 
68
68
  attr_reader :zero
@@ -75,7 +75,10 @@ module URBANopt
75
75
 
76
76
  attr_reader :eps
77
77
 
78
- # compute value
78
+ ##
79
+ # Used to determine new scaled vertices, by iteratively passing in the perimeter distance to
80
+ # minimise the difference of the new and scaled area. Returns the difference of the new area and desired area.
81
+ #
79
82
  def values(x)
80
83
  @new_vertices = URBANopt::GeoJSON::Zoning.divide_floor_print(@vertices, x[0].to_f, @runner, scale = true)
81
84
  new_area = OpenStudio.getArea(@new_vertices)
@@ -30,6 +30,6 @@
30
30
 
31
31
  module URBANopt
32
32
  module GeoJSON
33
- VERSION = '0.4.0'.freeze
33
+ VERSION = '0.5.0'.freeze
34
34
  end
35
35
  end
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'rspec', '~> 3.7'
31
31
 
32
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'
33
+ spec.add_runtime_dependency 'openstudio-extension', '~> 0.3.1'
34
+ spec.add_runtime_dependency 'urbanopt-core', '~> 0.5.0'
35
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.4.0
4
+ version: 0.5.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-09-25 00:00:00.000000000 Z
13
+ date: 2020-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -74,28 +74,28 @@ dependencies:
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 0.2.5
77
+ version: 0.3.1
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.5
84
+ version: 0.3.1
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.4.0
91
+ version: 0.5.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.4.0
98
+ version: 0.5.0
99
99
  description: Library and measures to translate URBANopt GeoJSON format to OpenStudio
100
100
  email:
101
101
  - tanushree.charan@nrel.gov
@@ -141,6 +141,7 @@ files:
141
141
  - docs/.vuepress/components/ThermalJunctionProperties.vue
142
142
  - docs/.vuepress/config.js
143
143
  - docs/.vuepress/highlight.js
144
+ - docs/.vuepress/json-schema-deref-loader.js
144
145
  - docs/.vuepress/public/custom_rdoc_styles.css
145
146
  - docs/.vuepress/utils.js
146
147
  - docs/README.md