def test_building_footprint_courtyard(): """Test the building footprint method with courtyard geometry.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 5, 3), Point3D(15, 5, 3), Point3D(15, 0, 3)) pts_2 = (Point3D(15, 0, 3), Point3D(15, 15, 3), Point3D(20, 15, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 5, 3), Point3D(0, 20, 3), Point3D(5, 20, 3), Point3D(5, 5, 3)) pts_4 = (Point3D(5, 15, 3), Point3D(5, 20, 3), Point3D(20, 20, 3), Point3D(20, 15, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) room2d_4 = Room2D('Office4', Face3D(pts_4), 3) int_rms = Room2D.intersect_adjacency( [room2d_1, room2d_2, room2d_3, room2d_4], 0.01) story = Story('Office_Floor', int_rms) story.rotate_xy(5, Point3D(0, 0, 0)) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 building = Building('Office_Building', [story]) footprint = building.footprint(0.01) assert len(footprint) == 1 assert isinstance(footprint[0], Face3D) assert len(footprint[0].boundary) == 8 assert len(footprint[0].holes) == 1 assert len(footprint[0].holes[0]) == 4
def test_building_footprint_simple(): """Test the building footprint method with simple geometry.""" pts_1 = (Point3D(0, 0, 3), Point3D(0, 10, 3), Point3D(10, 10, 3), Point3D(10, 0, 3)) pts_2 = (Point3D(10, 0, 3), Point3D(10, 10, 3), Point3D(20, 10, 3), Point3D(20, 0, 3)) pts_3 = (Point3D(0, 10, 3), Point3D(0, 20, 3), Point3D(10, 20, 3), Point3D(10, 10, 3)) pts_4 = (Point3D(10, 10, 3), Point3D(10, 20, 3), Point3D(20, 20, 3), Point3D(20, 10, 3)) room2d_1 = Room2D('Office1', Face3D(pts_1), 3) room2d_2 = Room2D('Office2', Face3D(pts_2), 3) room2d_3 = Room2D('Office3', Face3D(pts_3), 3) room2d_4 = Room2D('Office4', Face3D(pts_4), 3) story = Story('Office_Floor', [room2d_1, room2d_2, room2d_3, room2d_4]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 4 building = Building('Office_Building', [story]) footprint = building.footprint(0.01) assert len(footprint) == 1 assert isinstance(footprint[0], Face3D) assert footprint[0].holes is None assert len(footprint[0].vertices) == 8 assert footprint[0].min == Point3D(0, 0, 3) assert footprint[0].max == Point3D(20, 20, 3)
def test_from_geojson_coordinates_simple_location(): """Test the Model coordinates from_geojson method with different location inputs. """ # Test 1: The location is equal to the point (0, 0) in model space. # Construct Model pts_1 = (Point3D(50, 50, 0), Point3D(60, 50, 0), Point3D(60, 60, 0), Point3D(50, 60, 0)) pts_2 = (Point3D(60, 50, 0), Point3D(70, 50, 0), Point3D(70, 60, 0), Point3D(60, 60, 0)) room2d_1 = Room2D('Residence1', Face3D(pts_1), 3) room2d_2 = Room2D('Residence2', Face3D(pts_2), 3) story = Story('ResidenceFloor', [room2d_1, room2d_2]) story.solve_room_2d_adjacency(0.01) story.set_outdoor_window_parameters(SimpleWindowRatio(0.4)) story.multiplier = 3 test_building = Building('ResidenceBuilding', [story]) # Convert to geojson. Location defines the origin of the model space. test_model = Model('TestGeoJSON_coords1', [test_building]) location = Location('Boston', 'MA', 'USA', 42.366151, -71.019357) # bottom-left geojson_folder = './tests/geojson/' test_model.to_geojson(location, folder=geojson_folder) geo_fp = os.path.join(geojson_folder, test_model.identifier, '{}.geojson'.format(test_model.identifier)) # Convert back to Model. Location defines the origin. model, loc = Model.from_geojson(geo_fp, location=location, point=Point2D(0, 0)) assert len(model.buildings) == 1 # Test geometric properties of building bldg1 = model.buildings[0] # Check story height for story in bldg1.unique_stories: assert 3.0 == pytest.approx(story.floor_to_floor_height, abs=1e-10) assert pytest.approx(bldg1.footprint_area, test_building.footprint_area, abs=1e-10) vertices = bldg1.footprint()[0].vertices test_vertices = test_building.footprint()[0].vertices for point, test_point in zip(vertices, test_vertices): assert point.is_equivalent(test_point, 1e-5) # Test 2: Change the location to equal to the point (70, 60) in model space, which is # the top-right corner of the building footprints. # Construct model with a new location that defines the top-right corner in lon/lat degrees. location2 = Location('Boston', 'MA', 'USA', 42.366690813294774, -71.01850462247945) # We define the point at the top-right corner in model units. model, loc = Model.from_geojson(geo_fp, location=location2, point=Point2D(70, 60)) assert len(model.buildings) == 1 # Test geometric properties of building bldg1 = model.buildings[0] assert test_building.footprint_area == pytest.approx(bldg1.footprint_area, abs=1e-5) vertices = bldg1.footprint()[0].vertices test_vertices = test_building.footprint()[0].vertices for point, test_point in zip(vertices, test_vertices): assert point.is_equivalent(test_point, 1e-3) # reduce precision due to conversion nukedir(os.path.join(geojson_folder, test_model.identifier), True)