Esempio n. 1
0
def test_relation_plaza_with_single_polygon(config):
    """ test a relation with 1 polygon with inner rings """
    holder = testfilemanager.import_testfile('bahnhofplatz_bern', config)
    bahnhofplatz = get_plazas_by_id(holder.plazas, 5117701)
    assert len(bahnhofplatz) == 1
    bahnhofplatz = bahnhofplatz[0]
    assert bahnhofplatz['geometry']
    assert len(bahnhofplatz['geometry'].interiors) == 5
Esempio n. 2
0
def process_plaza(testfile, plaza_id, process_strategy, shortest_path_strategy,
                  config):
    holder = testfilemanager.import_testfile(testfile, config)
    plaza = get_plaza_by_id(holder.plazas, plaza_id)

    processor = optimizer.PlazaPreprocessor(holder, process_strategy,
                                            shortest_path_strategy, config)
    return processor._process_plaza(plaza)
Esempio n. 3
0
def test_multiple_plazas(process_strategy, shortest_path_strategy, config):
    holder = testfilemanager.import_testfile('helvetiaplatz', config)
    processed_plazas = optimizer.preprocess_plazas(holder, process_strategy,
                                                   shortest_path_strategy,
                                                   config)

    assert len(processed_plazas) == 7
    all_edges = [
        edge.coords for plaza in processed_plazas
        for edge in plaza["graph_edges"]
    ]
    assert len(set(all_edges)) == len(all_edges)  # check for duplicates
Esempio n. 4
0
def test_simple_plaza(config):
    holder = testfilemanager.import_testfile('helvetiaplatz', config)
    assert len(holder.plazas) == 9
    assert len(holder.buildings) > 1000
    assert len(holder.lines) > 800
    assert len(holder.points) > 550

    helvetiaplatz = get_plazas_by_id(holder.plazas, 4533221)
    assert len(helvetiaplatz) == 1
    helvetiaplatz = helvetiaplatz[0]
    assert helvetiaplatz['geometry']
    assert helvetiaplatz['geometry'].area > 0
Esempio n. 5
0
def test_optimized_lines_inside_plaza(process_strategy, shortest_path_strategy,
                                      config):
    holder = testfilemanager.import_testfile('bahnhofplatz_bern', config)
    plaza = utils.get_plaza_by_id(holder.plazas, 5117701)
    plaza_geometry = plaza['geometry']

    processor = optimizer.PlazaPreprocessor(holder, process_strategy,
                                            shortest_path_strategy, config)
    result_plaza = processor._process_plaza(plaza)

    assert result_plaza
    # all optimized lines should be inside the plaza geometry
    assert all(
        abs(plaza_geometry.intersection(line).length - line.length) <= 0.05
        for line in result_plaza['graph_edges'])
Esempio n. 6
0
def test_relation_with_unclosed_ways(config):
    """ test a relation with unclosed ways """
    holder = testfilemanager.import_testfile('unclosed_ways', config)
    # plaza should not be discarded
    assert len(holder.plazas) == 1
Esempio n. 7
0
def test_multipolygon_plaza(config):
    """ test a relation with 2 independent plazas """
    holder = testfilemanager.import_testfile('zentrum_witikon', config)
    assert len(holder.plazas) == 2
    assert all([p['osm_id'] == 4105514 for p in holder.plazas])
Esempio n. 8
0
def test_empty_file(config):
    with pytest.raises(RuntimeError):
        testfilemanager.import_testfile('empty_file', config)