示例#1
0
def workstations_test(port_id):
    response = requests.get('http://localhost:5000/workstations/' + port_id)
    info = response.json()['work_stations']
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(port_id)
    floor_plan = FloorPlan(corner_list, wall_list, room_list, item_list=item_list)
    floor_plan.draw_all()
    xs, ys = [], []
    for desk in info:
        xs.append(desk['position'].get('x'))
        ys.append(desk['position'].get('z'))
    plt.plot(xs, ys, 'go')
    plt.show()
    return
示例#2
0
def field_of_view_test(port_id):
    url = 'http://localhost:5000/viewpoint/' + port_id
    response = requests.get(url, data=json.dumps({"x": 12565, "z": 22166}))
    info = response.json()['polygon_points']
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(port_id)
    floor_plan = FloorPlan(corner_list, wall_list, room_list, item_list=item_list)
    xs, ys = [], []
    floor_plan.draw_rooms_all()
    for point in info:
        xs.append(point['x'])
        ys.append(point['z'])
    plt.fill(xs, ys, alpha=0.5)
    plt.show()
    return
示例#3
0
def privacy_test(port_id):
    response = requests.get('http://localhost:5000/privacy/' + port_id)
    info = response.json()['nodes']
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(port_id, 450)
    floor_plan = FloorPlan(corner_list, wall_list, room_list, interval=450, item_list=item_list)
    xs, ys, color_bar = [], [], []
    fig, ax = plt.subplots()
    floor_plan.draw_all()
    for n in info:
        xs.append(n['position'].get('x'))
        ys.append(n['position'].get('z'))
        color_bar.append(n['value'])
    im = ax.scatter(xs, ys, c=color_bar, cmap=cmap)
    im.set_clim(0.0, 1.0)
    plt.show()
    return
示例#4
0
def covid_test(port_id):
    response = requests.get('http://localhost:5000/covid/' + port_id)
    info = response.json()['covid_rooms']
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(port_id, 500)
    floor_plan = FloorPlan(corner_list, wall_list, room_list, interval=500, item_list=item_list)
    xs, ys, color_bar = [], [], []
    fig, ax = plt.subplots()
    floor_plan.draw_rooms_all()
    for chair in info:
        for c in chair['chairs']:
            xs.append(c['position'].get('x'))
            ys.append(c['position'].get('z'))
            color_bar.append(c['total_score'])
    im = ax.scatter(xs, ys, c=color_bar, cmap=cmap2)
    im.set_clim(0.0, 1.0)
    plt.show()
    return
def get_probability(port_id):
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(
        port_id)
    floor_plan = FloorPlan(corner_list,
                           wall_list,
                           room_list,
                           item_list=item_list)
    return analysis.probability_all(floor_plan.rooms)
def get_work_stations(port_id):
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(
        port_id)
    floor_plan = FloorPlan(corner_list,
                           wall_list,
                           room_list,
                           item_list=item_list)
    return analysis.work_station_all(floor_plan.rooms)
def get_privacy(port_id):
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(
        port_id, 450)
    floor_plan = FloorPlan(corner_list,
                           wall_list,
                           room_list,
                           interval=450,
                           item_list=item_list)
    return analysis.privacy_all(floor_plan)
def get_human_movement(port_id):
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(
        port_id, 450)
    floor_plan = FloorPlan(corner_list,
                           wall_list,
                           room_list,
                           interval=450,
                           item_list=item_list)
    return analysis.human_movement(floor_plan)
def get_covid_score(port_id):
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(
        port_id, 500)
    floor_plan = FloorPlan(corner_list,
                           wall_list,
                           room_list,
                           interval=500,
                           item_list=item_list)
    return corona.score_all(floor_plan.rooms)
def get_field_of_view(port_id):
    corner_list, wall_list, room_list, item_list = api_manager.create_objects(
        port_id)
    floor_plan = FloorPlan(corner_list,
                           wall_list,
                           room_list,
                           item_list=item_list)
    data = request.data.decode('utf-8')
    try:
        data = json.loads(data)
        return analysis.point_view_all(floor_plan, data['x'], data['z'])

    except:
        message = 'The input is not JSON format'
        return json.dumps({'status': 'FAILED', 'message': message})
             [rooms] = List of Room objects (floor_plan.py)
             [items] = List of Item objects (floor_plan.py)
    """
    corners_json, walls_json, rooms_json, items_json = get_room_and_items(
        port_id)

    corners = [Corner(c['id'], c['position']) for c in corners_json]
    walls = [
        Wall(w['start'], w['end'], w['height'], w['thickness'])
        for w in walls_json
    ]
    rooms = [
        Room(r['corners'], r['inner_points'], r['height'], r['label'],
             r['type'], interval) for r in rooms_json
    ]
    items = [
        Item(i['archi_id'], i['category'], i['archiCategory'], i['dimensions'],
             i['position'], i['code'], i['rotation'], i['scale'])
        for i in items_json
    ]
    return corners, walls, rooms, items


if __name__ == '__main__':
    # EXAMPLE: 'XOOErmT8302DC3437D34541': test_room 9, 'XN6RiYo132FC530F34C4A01': test_room 1
    corner_list, wall_list, room_list, item_list = create_objects(
        'XN6RiYo132FC530F34C4A01', 500)
    floor_plan = FloorPlan(corner_list, wall_list, room_list, 500, item_list)
    test_room = floor_plan.rooms[1]
    print(analysis.privacy_all(floor_plan))