Skip to content

Commit

Permalink
Merge pull request #116 from urbanopt/add_missing_feature_location
Browse files Browse the repository at this point in the history
added missing feature location arguments to CreateBar & Floorspace workflows #117
  • Loading branch information
kflemin authored Oct 13, 2021
2 parents fc7c7a0 + b24187c commit 7657aff
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
3 changes: 0 additions & 3 deletions example_project/mappers/Baseline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,6 @@ def create_osw(scenario, features, feature_names)
feature_id = feature.id
feature_type = feature.type

# take the first vertex as the location of the building
#feature_location = feature.feature_json[:geometry][:coordinates][0][0].to_s

# take the centroid of the vertices as the location of the building
feature_vertices_coordinates = feature.feature_json[:geometry][:coordinates][0]
feature_location = feature.find_feature_center(feature_vertices_coordinates).to_s
Expand Down
6 changes: 6 additions & 0 deletions example_project/mappers/CreateBar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ def create_osw(scenario, features, feature_names)
feature = features[0]
feature_id = feature.id
feature_type = feature.type
# take the centroid of the vertices as the location of the building
feature_vertices_coordinates = feature.feature_json[:geometry][:coordinates][0]
feature_location = feature.find_feature_center(feature_vertices_coordinates).to_s

feature_name = feature.name

if feature_names.size == 1
feature_name = feature_names[0]
end
Expand Down Expand Up @@ -552,6 +557,7 @@ def time_mapping(time)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_id', feature_id)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_name', feature_name)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_type', feature_type)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_location', feature_location)
end

return osw
Expand Down
6 changes: 6 additions & 0 deletions example_project/mappers/Floorspace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ def create_osw(scenario, features, feature_names)
feature = features[0]
feature_id = feature.id
feature_type = feature.type

# take the centroid of the vertices as the location of the building
feature_vertices_coordinates = feature.feature_json[:geometry][:coordinates][0]
feature_location = feature.find_feature_center(feature_vertices_coordinates).to_s

feature_name = feature.name
if feature_names.size == 1
feature_name = feature_names[0]
Expand Down Expand Up @@ -656,6 +661,7 @@ def time_mapping(time)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_id', feature_id)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_name', feature_name)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_type', feature_type)
OpenStudio::Extension.set_measure_argument(osw, 'default_feature_reports', 'feature_location', feature_location)
end

return osw
Expand Down
3 changes: 2 additions & 1 deletion example_project/mappers/createbar_workflow.osw
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"arguments": {
"feature_id": null,
"feature_name": null,
"feature_type": null
"feature_type": null,
"feature_location": null
}
}
],
Expand Down
3 changes: 2 additions & 1 deletion example_project/mappers/floorspace_workflow.osw
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
"arguments": {
"feature_id": null,
"feature_name": null,
"feature_type": null
"feature_type": null,
"feature_location": null
}
}
],
Expand Down

0 comments on commit 7657aff

Please sign in to comment.