urbanopt-geojson 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.rakeTasks +7 -0
  4. data/.rdoc_options +43 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +10 -0
  7. data/.travis.yml +35 -0
  8. data/CHANGELOG.md +5 -0
  9. data/Gemfile +27 -0
  10. data/Jenkinsfile +10 -0
  11. data/LICENSE.md +27 -0
  12. data/RDOC_MAIN.md +48 -0
  13. data/README.md +40 -0
  14. data/Rakefile +45 -0
  15. data/deploy_docs.sh +4 -0
  16. data/doc_templates/LICENSE.md +27 -0
  17. data/doc_templates/README.md.erb +42 -0
  18. data/doc_templates/copyright_erb.txt +31 -0
  19. data/doc_templates/copyright_js.txt +4 -0
  20. data/doc_templates/copyright_ruby.txt +29 -0
  21. data/docs/.gitignore +3 -0
  22. data/docs/.vuepress/components/BuildingProperties.vue +12 -0
  23. data/docs/.vuepress/components/DistrictSystemProperties.vue +12 -0
  24. data/docs/.vuepress/components/ElectricalConnectorProperties.vue +12 -0
  25. data/docs/.vuepress/components/ElectricalJunctionProperties.vue +12 -0
  26. data/docs/.vuepress/components/InnerJsonSchema.vue +80 -0
  27. data/docs/.vuepress/components/JsonSchema.vue +12 -0
  28. data/docs/.vuepress/components/RegionProperties.vue +12 -0
  29. data/docs/.vuepress/components/SiteProperties.vue +12 -0
  30. data/docs/.vuepress/components/StaticLink.vue +8 -0
  31. data/docs/.vuepress/components/ThermalConnectorProperties.vue +12 -0
  32. data/docs/.vuepress/components/ThermalJunctionProperties.vue +12 -0
  33. data/docs/.vuepress/config.js +22 -0
  34. data/docs/.vuepress/highlight.js +8 -0
  35. data/docs/.vuepress/public/custom_rdoc_styles.css +64 -0
  36. data/docs/.vuepress/utils.js +17 -0
  37. data/docs/README.md +30 -0
  38. data/docs/doc/created.rid +0 -0
  39. data/docs/package-lock.json +11771 -0
  40. data/docs/package.json +22 -0
  41. data/docs/schemas/building-properties.md +3 -0
  42. data/docs/schemas/district-system-properties.md +3 -0
  43. data/docs/schemas/electrical-connector-properties.md +3 -0
  44. data/docs/schemas/electrical-junction-properties.md +3 -0
  45. data/docs/schemas/region-properties.md +3 -0
  46. data/docs/schemas/site-properties.md +3 -0
  47. data/docs/schemas/thermal-connector-properties.md +3 -0
  48. data/docs/schemas/thermal-junction-properties.md +3 -0
  49. data/lib/measures/.rubocop.yml +5 -0
  50. data/lib/measures/urban_geometry_creation/LICENSE.md +27 -0
  51. data/lib/measures/urban_geometry_creation/README.md +48 -0
  52. data/lib/measures/urban_geometry_creation/README.md.erb +42 -0
  53. data/lib/measures/urban_geometry_creation/measure.rb +199 -0
  54. data/lib/measures/urban_geometry_creation/measure.xml +139 -0
  55. data/lib/measures/urban_geometry_creation/tests/nrel_stm_footprints.geojson +3238 -0
  56. data/lib/measures/urban_geometry_creation/tests/shadowed_tests.rb +80 -0
  57. data/lib/measures/urban_geometry_creation/tests/urban_geometry_creation_test.rb +143 -0
  58. data/lib/measures/urban_geometry_creation_zoning/LICENSE.md +27 -0
  59. data/lib/measures/urban_geometry_creation_zoning/README.md +48 -0
  60. data/lib/measures/urban_geometry_creation_zoning/README.md.erb +42 -0
  61. data/lib/measures/urban_geometry_creation_zoning/measure.rb +203 -0
  62. data/lib/measures/urban_geometry_creation_zoning/measure.xml +133 -0
  63. data/lib/measures/urban_geometry_creation_zoning/tests/nrel_stm_footprints.geojson +3238 -0
  64. data/lib/measures/urban_geometry_creation_zoning/tests/urban_geometry_creation_test.rb +143 -0
  65. data/lib/urbanopt/geojson.rb +41 -0
  66. data/lib/urbanopt/geojson/building.rb +341 -0
  67. data/lib/urbanopt/geojson/district_system.rb +53 -0
  68. data/lib/urbanopt/geojson/extension.rb +63 -0
  69. data/lib/urbanopt/geojson/feature.rb +206 -0
  70. data/lib/urbanopt/geojson/geo_file.rb +154 -0
  71. data/lib/urbanopt/geojson/helper.rb +340 -0
  72. data/lib/urbanopt/geojson/logging.rb +46 -0
  73. data/lib/urbanopt/geojson/mapper_classes.rb +85 -0
  74. data/lib/urbanopt/geojson/model.rb +133 -0
  75. data/lib/urbanopt/geojson/region.rb +55 -0
  76. data/lib/urbanopt/geojson/schema/building_properties.json +358 -0
  77. data/lib/urbanopt/geojson/schema/district_system_properties.json +137 -0
  78. data/lib/urbanopt/geojson/schema/electrical_connector_properties.json +77 -0
  79. data/lib/urbanopt/geojson/schema/electrical_junction_properties.json +64 -0
  80. data/lib/urbanopt/geojson/schema/geojson_schema.json +323 -0
  81. data/lib/urbanopt/geojson/schema/region_properties.json +93 -0
  82. data/lib/urbanopt/geojson/schema/site_properties.json +87 -0
  83. data/lib/urbanopt/geojson/schema/thermal_connector_properties.json +107 -0
  84. data/lib/urbanopt/geojson/schema/thermal_junction_properties.json +83 -0
  85. data/lib/urbanopt/geojson/update_areas.rb +102 -0
  86. data/lib/urbanopt/geojson/validate_geojson.rb +147 -0
  87. data/lib/urbanopt/geojson/version.rb +35 -0
  88. data/lib/urbanopt/geojson/workflows/building.osw +187 -0
  89. data/lib/urbanopt/geojson/workflows/building.osw.out +2806 -0
  90. data/lib/urbanopt/geojson/workflows/district_system.osw +84 -0
  91. data/lib/urbanopt/geojson/workflows/district_system.osw.out +646 -0
  92. data/lib/urbanopt/geojson/zoning.rb +134 -0
  93. data/package-lock.json +3 -0
  94. data/urbanopt-geojson-gem.gemspec +39 -0
  95. metadata +238 -0
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "id": "http://json-schema.org/openstudio-urban-modeling/region_properties.json#",
4
+ "title": "URBANopt Region",
5
+ "description": "Schema for an URBANopt Region object",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "description": "Unique id used to refer to this feature within this dataset.",
10
+ "type": "string"
11
+ },
12
+ "project_id": {
13
+ "description": "Project which this feature belongs to.",
14
+ "type": "string"
15
+ },
16
+ "type": {
17
+ "description": "Type of feature.",
18
+ "type": "string",
19
+ "enum": [
20
+ "Region"
21
+ ]
22
+ },
23
+ "region_type": {
24
+ "description": "Type of region.",
25
+ "type": "string",
26
+ "enum": [
27
+ "Taxlot",
28
+ "Park",
29
+ "Road",
30
+ "Lake",
31
+ "Obstacle"
32
+ ]
33
+ },
34
+ "source_name": {
35
+ "description": "Name of the original data source.",
36
+ "type": "string"
37
+ },
38
+ "source_id": {
39
+ "description": "Id of the feature in original data source.",
40
+ "type": "string"
41
+ },
42
+ "name": {
43
+ "description": "Feature name.",
44
+ "type": "string"
45
+ },
46
+ "legal_name": {
47
+ "description": "Legal name used to identify this feature.",
48
+ "type": "string"
49
+ },
50
+ "address": {
51
+ "description": "Street address.",
52
+ "type": "string"
53
+ },
54
+ "footprint_area": {
55
+ "description": "Area of the footprint (ft^2). Calculated on export.",
56
+ "type": "number"
57
+ },
58
+ "footprint_perimeter": {
59
+ "description": "Perimeter of the footprint (ft). Calculated on export.",
60
+ "type": "number"
61
+ },
62
+ "exterior_lighting_zone": {
63
+ "description": "Choice of exterior lighting zone.",
64
+ "type": "string",
65
+ "enum": [
66
+ "0 - Undeveloped Areas Parks",
67
+ "1 - Developed Areas Parks",
68
+ "2 - Neighborhood",
69
+ "3 - All Other Areas",
70
+ "4 - High Activity"
71
+ ]
72
+ },
73
+ "taxlot_zoning": {
74
+ "description": "Type of zoning if this feature is a taxlot.",
75
+ "type": "string",
76
+ "enum": [
77
+ "Vacant",
78
+ "Mixed",
79
+ "Residential",
80
+ "Commercial",
81
+ "OpenSpace"
82
+ ]
83
+ },
84
+ "user_data": {
85
+ "description": "Arbitrary user data"
86
+ }
87
+ },
88
+ "required": [
89
+ "type",
90
+ "region_type"
91
+ ],
92
+ "additionalProperties": false
93
+ }
@@ -0,0 +1,87 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "id": "http://json-schema.org/openstudio-urban-modeling/taxlot_properties.json#",
4
+ "title": "URBANopt Site",
5
+ "description": "Schema for an URBANopt Site object",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "description": "Unique id used to refer to this feature within this dataset, generated by database.",
10
+ "type": "string"
11
+ },
12
+ "project_id": {
13
+ "description": "Project which this feature belongs to.",
14
+ "type": "string"
15
+ },
16
+ "name": {
17
+ "description": "Feature name",
18
+ "type": "string"
19
+ },
20
+ "state": {
21
+ "description": "State name",
22
+ "type": "string"
23
+ },
24
+ "city": {
25
+ "description": "City name",
26
+ "type": "string"
27
+ },
28
+ "latitude": {
29
+ "description": "Latitude of site origin in WGS 84 coordinate system (deg)",
30
+ "type": "number"
31
+ },
32
+ "longitude": {
33
+ "description": "Longitude of site origin in WGS 84 coordinate system (deg)",
34
+ "type": "number"
35
+ },
36
+ "surface_elevation": {
37
+ "description": "The surface elevation (above NAVD88 datum) of the project (ft). ",
38
+ "type": "number"
39
+ },
40
+ "import_surrounding_buildings_as_shading": {
41
+ "description": "If true, import geometry from surrounding buildings when performing energy calculations.",
42
+ "type": "boolean"
43
+ },
44
+ "timesteps_per_hour": {
45
+ "description": "Number of timesteps per hour for energy simulations.",
46
+ "type": "integer",
47
+ "minimum": 1,
48
+ "maximum": 60
49
+ },
50
+ "begin_date": {
51
+ "description": "Date to begin simulation, format YYYY-MM-DD.",
52
+ "type": "string"
53
+ },
54
+ "end_date": {
55
+ "description": "Date to end simulation, format YYYY-MM-DD.",
56
+ "type": "string"
57
+ },
58
+ "climate_zone": {
59
+ "description": "ASHRAE 169 climate zone.",
60
+ "type": "string"
61
+ },
62
+ "cec_climate_zone": {
63
+ "description": "CEC Title24 climate zone.",
64
+ "type": "string"
65
+ },
66
+ "default_template": {
67
+ "description": "Default OpenStudio Standards template.",
68
+ "type": "string"
69
+ },
70
+ "weather_filename": {
71
+ "description": "Name of weather file in EPW format.",
72
+ "type": "string"
73
+ },
74
+ "tariff_filename": {
75
+ "description": "Name of utility tariff file in IDF or URDB format.",
76
+ "type": "string"
77
+ },
78
+ "user_data": {
79
+ "description": "Arbitrary user data"
80
+ }
81
+ },
82
+ "required": [
83
+ "latitude",
84
+ "longitude"
85
+ ],
86
+ "additionalProperties": false
87
+ }
@@ -0,0 +1,107 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "id": "http://json-schema.org/openstudio-urban-modeling/district_system_properties.json#",
4
+ "title": "URBANopt Thermal Connector",
5
+ "description": "Schema for an URBANopt Thermal Connector object",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "description": "Unique id used to refer to this feature within this dataset.",
10
+ "type": "string"
11
+ },
12
+ "project_id": {
13
+ "description": "Project which this feature belongs to.",
14
+ "type": "string"
15
+ },
16
+ "type": {
17
+ "description": "Type of feature.",
18
+ "type": "string",
19
+ "enum": [
20
+ "ThermalConnector"
21
+ ]
22
+ },
23
+ "source_name": {
24
+ "description": "Name of the original data source.",
25
+ "type": "string"
26
+ },
27
+ "source_id": {
28
+ "description": "Id of the feature in original data source.",
29
+ "type": "string"
30
+ },
31
+ "name": {
32
+ "description": "Feature name",
33
+ "type": "string"
34
+ },
35
+ "connector_type": {
36
+ "$ref": "#/definitions/ThermalConnectorType"
37
+ },
38
+ "lengths": {
39
+ "description": "Length of each segment in ft, generated on export.",
40
+ "type": "array",
41
+ "items": {
42
+ "type": "number"
43
+ }
44
+ },
45
+ "total_length": {
46
+ "description": "Total length of the connector in ft, generated on export.",
47
+ "type": "number"
48
+ },
49
+ "start_junction_id": {
50
+ "description": "Id of the junction that this connector starts at.",
51
+ "type": "string"
52
+ },
53
+ "end_junction_id": {
54
+ "description": "Id of the junction that this connector ends at.",
55
+ "type": "string"
56
+ },
57
+ "fluid_temperature_type": {
58
+ "description": "Classification of temperature range of fluid in this connector",
59
+ "$ref": "#/definitions/TemperatureType"
60
+ },
61
+ "flow_direction": {
62
+ "description": "Charcterization of connector, relative to the central plant",
63
+ "$ref": "#/definitions/FlowDirection"
64
+ },
65
+ "user_data": {
66
+ "description": "Arbitrary user data"
67
+ }
68
+ },
69
+ "required": [
70
+ "type",
71
+ "connector_type",
72
+ "start_junction_id",
73
+ "end_junction_id",
74
+ "fluid_temperature_type",
75
+ "flow_direction"
76
+ ],
77
+ "additionalProperties": false,
78
+ "definitions": {
79
+ "ThermalConnectorType": {
80
+ "description": "Type of thermal connector.",
81
+ "type": "string",
82
+ "enum": [
83
+ "OnePipe",
84
+ "TwoPipe",
85
+ "ThreePipe",
86
+ "FourPipe"
87
+ ]
88
+ },
89
+ "TemperatureType": {
90
+ "description": "Temperature of fluid flowing in connector.",
91
+ "type": "string",
92
+ "enum": [
93
+ "Hot",
94
+ "Cold",
95
+ "Ambient"
96
+ ]
97
+ },
98
+ "FlowDirection": {
99
+ "description": "Direction of flow from start junction to end junction.",
100
+ "type": "string",
101
+ "enum": [
102
+ "Supply",
103
+ "Return"
104
+ ]
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,83 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "id": "http://json-schema.org/openstudio-urban-modeling/district_system_properties.json#",
4
+ "title": "URBANopt Thermal Junction",
5
+ "description": "Schema for an URBANopt Thermal Junction object",
6
+ "type": "object",
7
+ "properties": {
8
+ "id": {
9
+ "description": "Unique id used to refer to this feature within this dataset.",
10
+ "type": "string"
11
+ },
12
+ "project_id": {
13
+ "description": "Project which this feature belongs to.",
14
+ "type": "string"
15
+ },
16
+ "type": {
17
+ "description": "Type of feature.",
18
+ "type": "string",
19
+ "enum": [
20
+ "ThermalJunction"
21
+ ]
22
+ },
23
+ "source_name": {
24
+ "description": "Name of the original data source.",
25
+ "type": "string"
26
+ },
27
+ "source_id": {
28
+ "description": "Id of the feature in original data source.",
29
+ "type": "string"
30
+ },
31
+ "name": {
32
+ "description": "Feature name",
33
+ "type": "string"
34
+ },
35
+ "connector_type": {
36
+ "$ref": "#/definitions/ThermalJunctionType"
37
+ },
38
+ "building_id": {
39
+ "description": "Id of building if this junction is inside a building.",
40
+ "type": "string"
41
+ },
42
+ "district_system_id": {
43
+ "description": "Id of district system if this junction is inside a district system.",
44
+ "type": "string"
45
+ },
46
+ "pump_presence": {
47
+ "description": "Presence of pump: true if present, false if absent",
48
+ "type": "boolean"
49
+ },
50
+ "connection_type": {
51
+ "description": "Characterize the connection as series or parallel",
52
+ "$ref": "#/definitions/ThermalJunctionConnectionType"
53
+ },
54
+ "user_data": {
55
+ "description": "Arbitrary user data"
56
+ }
57
+ },
58
+ "required": [
59
+ "type",
60
+ "connector_type",
61
+ "connection_type"
62
+ ],
63
+ "additionalProperties": false,
64
+ "definitions": {
65
+ "ThermalJunctionType": {
66
+ "description": "Type of thermal junction.",
67
+ "type": "string",
68
+ "enum": [
69
+ "DES",
70
+ "ETS",
71
+ "Valve"
72
+ ]
73
+ },
74
+ "ThermalJunctionConnectionType": {
75
+ "description": "Type of connection for connectors meeting at this junction.",
76
+ "type": "string",
77
+ "enum": [
78
+ "Series",
79
+ "Parallel"
80
+ ]
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,102 @@
1
+ # *********************************************************************************
2
+ # URBANopt, Copyright (c) 2019, 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 'json'
33
+
34
+ file = ARGV[0]
35
+
36
+ geojson = JSON.parse(File.open(file, 'r').read, symbolize_names: true)
37
+
38
+ geojson[:features].each do |feature|
39
+ properties = feature[:properties]
40
+ geometry = feature[:geometry]
41
+
42
+ number_of_stories = properties[:number_of_stories]
43
+ if number_of_stories.nil?
44
+ number_of_stories = 1
45
+ end
46
+
47
+ maximum_roof_height = properties[:maximum_roof_height]
48
+ # if maximum_roof_height.nil?
49
+ maximum_roof_height = 10 * number_of_stories
50
+ # end
51
+
52
+ multi_polygons = nil
53
+ if geometry[:type] == 'Polygon'
54
+ polygons = geometry[:coordinates]
55
+ multi_polygons = [polygons]
56
+ elsif geometry[:type] == 'MultiPolygon'
57
+ multi_polygons = geometry[:coordinates]
58
+ end
59
+
60
+ area = 0
61
+ distance = 0
62
+ multi_polygons[0].each do |polygon|
63
+ origin_lat_lon = nil
64
+ floor_print = OpenStudio::Point3dVector.new
65
+ polygon.each do |p|
66
+ lon = p[0]
67
+ lat = p[1]
68
+ origin_lat_lon = OpenStudio::PointLatLon.new(lat, lon, 0) if origin_lat_lon.nil?
69
+ point_3d = origin_lat_lon.toLocalCartesian(OpenStudio::PointLatLon.new(lat, lon, 0))
70
+ point_3d = OpenStudio::Point3d.new(point_3d.x, point_3d.y, 0)
71
+ floor_print << point_3d
72
+ end
73
+ area += OpenStudio.getArea(floor_print).get
74
+
75
+ polygon.each_index do |i|
76
+ if i == (polygon.size - 1)
77
+ distance += OpenStudio.getDistance(floor_print[i], floor_print[0])
78
+ else
79
+ distance += OpenStudio.getDistance(floor_print[i], floor_print[i + 1])
80
+ end
81
+ end
82
+ end
83
+
84
+ if number_of_stories == 0
85
+ floor_area = area
86
+ else
87
+ floor_area = number_of_stories * area
88
+ end
89
+
90
+ properties[:footprint_area] = OpenStudio.convert(area, 'm^2', 'ft^2').get
91
+ properties[:footprint_perimeter] = OpenStudio.convert(distance, 'm', 'ft').get
92
+ properties[:floor_area] = OpenStudio.convert(floor_area, 'm^2', 'ft^2').get
93
+ properties[:number_of_stories] = number_of_stories
94
+ properties[:maximum_roof_height] = maximum_roof_height
95
+
96
+ # Point3d toLocalCartesian(const PointLatLon& point) const;
97
+ # std::vector<Point3d> toLocalCartesian(const std::vector<PointLatLon>& points) const;
98
+ end
99
+
100
+ File.open(ARGV[0], 'w') do |file|
101
+ file << JSON.pretty_generate(geojson)
102
+ end