예제 #1
0
def test_node_way_ref_after_delete_1():
    """Nodes refereces way"""
    data = t.cache_query(nodes=[20001, 20002], deps=True)
    assert '20001' in data['nodes']['20001']['ways']
    assert '20001' in data['nodes']['20002']['ways']
    assert t.query_row(t.db_conf, 'osm_roads', 20001)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_barrierpoints', 20001)['type'] == 'block'
예제 #2
0
def test_node_way_ref_after_delete_1():
    """Nodes refereces way"""
    data = t.cache_query(nodes=[20001, 20002], deps=True)
    assert '20001' in data['nodes']['20001']['ways']
    assert '20001' in data['nodes']['20002']['ways']
    assert t.query_row(t.db_conf, 'osm_roads', 20001)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_barrierpoints', 20001)['type'] == 'block'
예제 #3
0
def test_partial_delete():
    """Deleted relation but nodes are still cached"""
    t.assert_cached_node(2001)
    t.assert_cached_way(2001)
    t.assert_cached_way(2002)
    assert not t.query_row(t.db_conf, 'osm_landusages', -2001)
    assert not t.query_row(t.db_conf, 'osm_landusages', 2001)
예제 #4
0
def test_node_way_ref_after_delete_2():
    """Node does not referece deleted way"""
    data = t.cache_query(nodes=[20001, 20002], deps=True)
    assert 'ways' not in data['nodes']['20001']
    assert data['nodes']['20002'] == None
    assert t.query_row(t.db_conf, 'osm_roads', 20001) == None
    assert t.query_row(t.db_conf, 'osm_barrierpoints', 20001)['type'] == 'block'
예제 #5
0
def test_ring_with_gap():
    """Multipolygon and way with gap (overlapping but different endpoints) gets closed"""
    park = t.query_row(t.db_conf, 'osm_landusages', -7301)
    assert park['geometry'].is_valid, park

    park = t.query_row(t.db_conf, 'osm_landusages', 7311)
    assert park['geometry'].is_valid, park
예제 #6
0
def test_residential_to_secondary2():
    """New secondary (from residential) is now in roads_gen0/1."""
    assert t.query_row(t.db_conf, 'osm_roads', 40001)['type'] == 'secondary'
    assert t.query_row(t.db_conf, 'osm_roads_gen0',
                       40001)['type'] == 'secondary'
    assert t.query_row(t.db_conf, 'osm_roads_gen1',
                       40001)['type'] == 'secondary'
예제 #7
0
def test_partial_delete():
    """Deleted relation but nodes are still cached"""
    t.assert_cached_node(2001)
    t.assert_cached_way(2001)
    t.assert_cached_way(2002)
    assert not t.query_row(t.db_conf, 'osm_landusages', -2001)
    assert not t.query_row(t.db_conf, 'osm_landusages', 2001)
예제 #8
0
def test_node_way_ref_after_delete_2():
    """Node does not referece deleted way"""
    data = t.cache_query(nodes=[20001, 20002], deps=True)
    assert 'ways' not in data['nodes']['20001']
    assert data['nodes']['20002'] == None
    assert t.query_row(t.db_conf, 'osm_roads', 20001) == None
    assert t.query_row(t.db_conf, 'osm_barrierpoints', 20001)['type'] == 'block'
예제 #9
0
def test_way_rel_ref_after_delete_2():
    """Way does not referece deleted relation"""
    data = t.cache_query(ways=[21001], deps=True)
    assert 'relations' not in data['ways']['21001']
    assert t.query_row(t.db_conf, 'osm_roads', 21001)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_landusages', 21001) == None
    assert t.query_row(t.db_conf, 'osm_landusages', -21001) == None
예제 #10
0
def test_ring_with_gap():
    """Multipolygon and way with gap (overlapping but different endpoints) gets closed"""
    park = t.query_row(t.db_conf, 'osm_landusages', -7301)
    assert park['geometry'].is_valid, park

    park = t.query_row(t.db_conf, 'osm_landusages', 7311)
    assert park['geometry'].is_valid, park
예제 #11
0
def test_way_rel_ref_after_delete_2():
    """Way does not referece deleted relation"""
    data = t.cache_query(ways=[21001], deps=True)
    assert 'relations' not in data['ways']['21001']
    assert t.query_row(t.db_conf, 'osm_roads', 21001)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_landusages', 21001) == None
    assert t.query_row(t.db_conf, 'osm_landusages', -21001) == None
예제 #12
0
def test_outer_way_not_inserted():
    """Outer way with different tag is not inserted twice into same table"""
    farm = t.query_row(t.db_conf, 'osm_landusages', -19001)
    assert farm['type'] == 'farmland'
    assert not t.query_row(t.db_conf, 'osm_landusages', 19001)

    farmyard = t.query_row(t.db_conf, 'osm_landusages', 19002)
    assert farmyard['type'] == 'farmyard'
예제 #13
0
def test_non_mapped_way_is_missing():
    """Way without mapped tags is missing."""
    t.assert_cached_way(20101)
    assert not t.query_row(t.db_conf, 'osm_all', 20101)
    t.assert_cached_way(20102)
    assert not t.query_row(t.db_conf, 'osm_all', 20102)
    t.assert_cached_way(20103)
    assert not t.query_row(t.db_conf, 'osm_all', 20103)
예제 #14
0
def test_non_mapped_way_is_missing():
    """Way without mapped tags is missing."""
    t.assert_cached_way(20101)
    assert not t.query_row(t.db_conf, 'osm_all', 20101)
    t.assert_cached_way(20102)
    assert not t.query_row(t.db_conf, 'osm_all', 20102)
    t.assert_cached_way(20103)
    assert not t.query_row(t.db_conf, 'osm_all', 20103)
예제 #15
0
def test_no_duplicate_insert():
    """
    Relation is not inserted again if a nother relation with the same way was modified
    Checks #65
    """
    assert t.query_row(t.db_conf, 'osm_landusages', -201191)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages', -201192)['type'] == 'forest'
    assert t.query_row(t.db_conf, 'osm_roads', 201151)['type'] == 'residential'
예제 #16
0
def test_update_node_to_coord_1():
    """Node is inserted with tag."""
    coords = t.cache_query(nodes=(70001, 70002))
    assert coords['nodes']["70001"]["tags"] == {"amenity": "police"}
    assert "tags" not in coords['nodes']["70002"]

    assert t.query_row(t.db_conf, 'osm_amenities', 70001)
    assert not t.query_row(t.db_conf, 'osm_amenities', 70002)
예제 #17
0
def test_update_node_to_coord_1():
    """Node is inserted with tag."""
    coords = t.cache_query(nodes=(70001, 70002))
    assert coords['nodes']["70001"]["tags"] == {"amenity": "police"}
    assert "tags" not in coords['nodes']["70002"]

    assert t.query_row(t.db_conf, 'osm_amenities', 70001)
    assert not t.query_row(t.db_conf, 'osm_amenities', 70002)
예제 #18
0
def test_changed_hole_tags_1():
    """Multipolygon relation with untagged hole"""
    t.assert_cached_way(14001)
    t.assert_cached_way(14011)

    assert not t.query_row(t.db_conf, 'osm_waterareas', 14011)
    assert not t.query_row(t.db_conf, 'osm_waterareas', -14011)
    assert t.query_row(t.db_conf, 'osm_landusages', -14001)['type'] == 'park'
예제 #19
0
def test_relation_without_tags2():
    """Relation without tags is removed."""
    t.cache_query(ways=[50111], deps=True)
    assert t.cache_query(relations=[50121], deps=True)['relations']["50121"] == None

    assert t.query_row(t.db_conf, 'osm_buildings', 50111)['type'] == 'yes'
    assert t.query_row(t.db_conf, 'osm_buildings', 50121) == None
    assert t.query_row(t.db_conf, 'osm_buildings', -50121) == None
예제 #20
0
def test_changed_hole_tags_1():
    """Multipolygon relation with untagged hole"""
    t.assert_cached_way(14001)
    t.assert_cached_way(14011)

    assert not t.query_row(t.db_conf, 'osm_waterareas', 14011)
    assert not t.query_row(t.db_conf, 'osm_waterareas', -14011)
    assert t.query_row(t.db_conf, 'osm_landusages', -14001)['type'] == 'park'
예제 #21
0
def test_outer_way_not_inserted():
    """Outer way with different tag is not inserted twice into same table"""
    farm = t.query_row(t.db_conf, 'osm_landusages', -19001)
    assert farm['type'] == 'farmland'
    assert not t.query_row(t.db_conf, 'osm_landusages', 19001)

    farmyard = t.query_row(t.db_conf, 'osm_landusages', 19002)
    assert farmyard['type'] == 'farmyard'
예제 #22
0
def test_no_duplicate_insert():
    """
    Relation is not inserted again if a nother relation with the same way was modified
    Checks #65
    """
    assert t.query_row(t.db_conf, 'osm_landusages', -201191)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages', -201192)['type'] == 'forest'
    assert t.query_row(t.db_conf, 'osm_roads', 201151)['type'] == 'residential'
예제 #23
0
def test_relation_without_tags2():
    """Relation without tags is removed."""
    t.cache_query(ways=[50111], deps=True)
    assert t.cache_query(relations=[50121], deps=True)['relations']["50121"] == None

    assert t.query_row(t.db_conf, 'osm_buildings', 50111)['type'] == 'yes'
    assert t.query_row(t.db_conf, 'osm_buildings', 50121) == None
    assert t.query_row(t.db_conf, 'osm_buildings', -50121) == None
예제 #24
0
def test_changed_hole_tags_2():
    """Newly tagged hole is inserted"""
    t.assert_cached_way(14001)
    t.assert_cached_way(14011)

    assert t.query_row(t.db_conf, 'osm_waterareas', 14011)['type'] == 'water'
    assert t.query_row(t.db_conf, 'osm_landusages', -14001)['type'] == 'park'
    t.assert_almost_equal(t.query_row(t.db_conf, 'osm_waterareas', 14011)['geometry'].area, 26672000000, -6)
    t.assert_almost_equal(t.query_row(t.db_conf, 'osm_landusages', -14001)['geometry'].area, 10373600000, -6)
예제 #25
0
def test_updated_nodes():
    """Nodes were added, modified or deleted"""
    t.assert_missing_node(10000)
    t.assert_cached_node(10001, (10.0, 40.0))
    t.assert_cached_node(10002, (10.1, 40.0))
    place_10001 = t.query_row(t.db_conf, 'osm_places', 10001)
    assert place_10001['name'] == 'Bar', place_10001
    place_10002 = t.query_row(t.db_conf, 'osm_places', 10002)
    assert place_10002['name'] == 'Baz', place_10002
예제 #26
0
def test_update_node_to_coord_2():
    """Node is becomes coord after tags are removed."""
    coords = t.cache_query(nodes=(70001, 70002))

    assert "tags" not in coords['nodes']["70001"]
    assert coords['nodes']["70002"]["tags"] == {"amenity": "police"}

    assert not t.query_row(t.db_conf, 'osm_amenities', 70001)
    assert t.query_row(t.db_conf, 'osm_amenities', 70002)
예제 #27
0
def test_updated_nodes():
    """Nodes were added, modified or deleted"""
    t.assert_missing_node(10000)
    t.assert_cached_node(10001, (10.0, 40.0))
    t.assert_cached_node(10002, (10.1, 40.0))
    place_10001 = t.query_row(t.db_conf, 'osm_places', 10001)
    assert place_10001['name'] == 'Bar', place_10001
    place_10002 = t.query_row(t.db_conf, 'osm_places', 10002)
    assert place_10002['name'] == 'Baz', place_10002
예제 #28
0
def test_changed_hole_tags_2():
    """Newly tagged hole is inserted"""
    t.assert_cached_way(14001)
    t.assert_cached_way(14011)

    assert t.query_row(t.db_conf, 'osm_waterareas', 14011)['type'] == 'water'
    assert t.query_row(t.db_conf, 'osm_landusages', -14001)['type'] == 'park'
    t.assert_almost_equal(t.query_row(t.db_conf, 'osm_waterareas', 14011)['geometry'].area, 26672000000, -6)
    t.assert_almost_equal(t.query_row(t.db_conf, 'osm_landusages', -14001)['geometry'].area, 10373600000, -6)
예제 #29
0
def test_update_node_to_coord_2():
    """Node is becomes coord after tags are removed."""
    coords = t.cache_query(nodes=(70001, 70002))

    assert "tags" not in coords['nodes']["70001"]
    assert coords['nodes']["70002"]["tags"] == {"amenity": "police"}

    assert not t.query_row(t.db_conf, 'osm_amenities', 70001)
    assert t.query_row(t.db_conf, 'osm_amenities', 70002)
예제 #30
0
def test_generalized_banana_polygon_is_valid():
    """Generalized polygons are valid."""
    park = t.query_row(t.db_conf, 'osm_landusages', 7101)
    # geometry is not valid
    assert not park['geometry'].is_valid, park
    park = t.query_row(t.db_conf, 'osm_landusages_gen0', 7101)
    # but simplified geometies are valid
    assert park['geometry'].is_valid, park
    park = t.query_row(t.db_conf, 'osm_landusages_gen1', 7101)
    assert park['geometry'].is_valid, park
예제 #31
0
def test_generalized_banana_polygon_is_valid():
    """Generalized polygons are valid."""
    park = t.query_row(t.db_conf, 'osm_landusages', 7101)
    # geometry is not valid
    assert not park['geometry'].is_valid, park
    park = t.query_row(t.db_conf, 'osm_landusages_gen0', 7101)
    # but simplified geometies are valid
    assert park['geometry'].is_valid, park
    park = t.query_row(t.db_conf, 'osm_landusages_gen1', 7101)
    assert park['geometry'].is_valid, park
예제 #32
0
def test_outer_way_inserted():
    """Outer way with different tag is inserted twice into different table"""
    farm = t.query_row(t.db_conf, 'osm_landusages', 19101)
    assert farm['type'] == 'farm'
    assert not t.query_row(t.db_conf, 'osm_landusages', -19101)

    farmyard = t.query_row(t.db_conf, 'osm_landusages', 19102)
    assert farmyard['type'] == 'farmyard'

    admin = t.query_row(t.db_conf, 'osm_admin', -19101)
    assert admin['type'] == 'administrative'
예제 #33
0
def test_split_outer_multipolygon_way_2():
    """Splitted outer way of multipolygon was inserted"""
    data = t.cache_query(ways=[15001, 15002], deps=True)
    assert data['ways']['15001']['relations'].keys() == ['15001']
    assert data['ways']['15002']['relations'].keys() == ['15001']

    assert t.query_row(t.db_conf, 'osm_landusages', 15001) == None
    park_15001 = t.query_row(t.db_conf, 'osm_landusages', -15001)
    assert park_15001['type'] == 'park'
    t.assert_almost_equal(park_15001['geometry'].area, 9816216452, -1)
    assert t.query_row(t.db_conf, 'osm_roads', 15002)['type'] == 'residential'
예제 #34
0
def test_outer_way_inserted():
    """Outer way with different tag is inserted twice into different table"""
    farm = t.query_row(t.db_conf, 'osm_landusages', 19101)
    assert farm['type'] == 'farm'
    assert not t.query_row(t.db_conf, 'osm_landusages', -19101)

    farmyard = t.query_row(t.db_conf, 'osm_landusages', 19102)
    assert farmyard['type'] == 'farmyard'

    admin = t.query_row(t.db_conf, 'osm_admin', -19101)
    assert admin['type'] == 'administrative'
예제 #35
0
def test_split_outer_multipolygon_way_2():
    """Splitted outer way of multipolygon was inserted"""
    data = t.cache_query(ways=[15001, 15002], deps=True)
    assert data['ways']['15001']['relations'].keys() == ['15001']
    assert data['ways']['15002']['relations'].keys() == ['15001']

    assert t.query_row(t.db_conf, 'osm_landusages', 15001) == None
    park_15001 = t.query_row(t.db_conf, 'osm_landusages', -15001)
    assert park_15001['type'] == 'park'
    t.assert_almost_equal(park_15001['geometry'].area, 9816216452, -1)
    assert t.query_row(t.db_conf, 'osm_roads', 15002)['type'] == 'residential'
예제 #36
0
def test_relation_way_not_inserted():
    """Part of relation was inserted only once."""
    park = t.query_row(t.db_conf, 'osm_landusages', -9001)
    assert park['type'] == 'park'
    assert park['name'] == 'rel 9001'
    assert t.query_row(t.db_conf, 'osm_landusages', 9009) == None

    park = t.query_row(t.db_conf, 'osm_landusages', -9101)
    assert park['type'] == 'park'
    assert park['name'] == 'rel 9101'
    assert t.query_row(t.db_conf, 'osm_landusages', 9109) == None

    scrub = t.query_row(t.db_conf, 'osm_landusages', 9110)
    assert scrub['type'] == 'scrub'
예제 #37
0
def test_relation_way_not_inserted():
    """Part of relation was inserted only once."""
    park = t.query_row(t.db_conf, 'osm_landusages', -9001)
    assert park['type'] == 'park'
    assert park['name'] == 'rel 9001'
    assert t.query_row(t.db_conf, 'osm_landusages', 9009) == None

    park = t.query_row(t.db_conf, 'osm_landusages', -9101)
    assert park['type'] == 'park'
    assert park['name'] == 'rel 9101'
    assert t.query_row(t.db_conf, 'osm_landusages', 9109) == None

    scrub = t.query_row(t.db_conf, 'osm_landusages', 9110)
    assert scrub['type'] == 'scrub'
예제 #38
0
def test_merge_outer_multipolygon_way_2():
    """Merged outer way of multipolygon was inserted"""
    data = t.cache_query(ways=[16001, 16002], deps=True)
    assert data['ways']['16001']['relations'].keys() == ['16001']
    assert data['ways']['16002'] == None

    data = t.cache_query(relations=[16001], full=True)
    assert sorted(data['relations']['16001']['ways'].keys()) == ['16001', '16011']

    assert t.query_row(t.db_conf, 'osm_landusages', 16001) == None
    park_16001 = t.query_row(t.db_conf, 'osm_landusages', -16001)
    assert park_16001['type'] == 'park'
    t.assert_almost_equal(park_16001['geometry'].area, 12779350582, -1)
    assert t.query_row(t.db_conf, 'osm_roads', 16002) == None
예제 #39
0
def test_merge_outer_multipolygon_way_2():
    """Merged outer way of multipolygon was inserted"""
    data = t.cache_query(ways=[16001, 16002], deps=True)
    assert data['ways']['16001']['relations'].keys() == ['16001']
    assert data['ways']['16002'] == None

    data = t.cache_query(relations=[16001], full=True)
    assert sorted(data['relations']['16001']['ways'].keys()) == ['16001', '16011']

    assert t.query_row(t.db_conf, 'osm_landusages', 16001) == None
    park_16001 = t.query_row(t.db_conf, 'osm_landusages', -16001)
    assert park_16001['type'] == 'park'
    t.assert_almost_equal(park_16001['geometry'].area, 12779350582, -1)
    assert t.query_row(t.db_conf, 'osm_roads', 16002) == None
예제 #40
0
def test_generalized_linestring_is_valid():
    """Generalized linestring is valid."""
    road = t.query_row(t.db_conf, 'osm_roads', 7201)
    # geometry is not simple, but valid
    # check that geometry 'survives' simplification
    assert not road['geometry'].is_simple, road['geometry'].wkt
    assert road['geometry'].is_valid, road['geometry'].wkt
    assert road['geometry'].length > 1000000
    road = t.query_row(t.db_conf, 'osm_roads_gen0', 7201)
    # but simplified geometies are simple
    assert road['geometry'].is_valid, road['geometry'].wkt
    assert road['geometry'].length > 1000000
    road = t.query_row(t.db_conf, 'osm_roads_gen1', 7201)
    assert road['geometry'].is_valid, road['geometry'].wkt
    assert road['geometry'].length > 1000000
예제 #41
0
def test_generalized_linestring_is_valid():
    """Generalized linestring is valid."""
    road = t.query_row(t.db_conf, 'osm_roads', 7201)
    # geometry is not simple, but valid
    # check that geometry 'survives' simplification
    assert not road['geometry'].is_simple, road['geometry'].wkt
    assert road['geometry'].is_valid, road['geometry'].wkt
    assert road['geometry'].length > 1000000
    road = t.query_row(t.db_conf, 'osm_roads_gen0', 7201)
    # but simplified geometies are simple
    assert road['geometry'].is_valid, road['geometry'].wkt
    assert road['geometry'].length > 1000000
    road = t.query_row(t.db_conf, 'osm_roads_gen1', 7201)
    assert road['geometry'].is_valid, road['geometry'].wkt
    assert road['geometry'].length > 1000000
예제 #42
0
def test_node_way_inserted_twice():
    """Way with multiple mappings is inserted twice in same table"""
    rows = t.query_row(t.db_conf, 'osm_roads', 18001)
    rows.sort(key=lambda x: x['type'])

    assert rows[0]['type'] == 'residential'
    assert rows[1]['type'] == 'tram'
예제 #43
0
def test_node_way_inserted_twice():
    """Way with multiple mappings is inserted twice in same table"""
    rows = t.query_row(t.db_conf, 'osm_roads', 18001)
    rows.sort(key=lambda x: x['type'])

    assert rows[0]['type'] == 'residential'
    assert rows[1]['type'] == 'tram'
예제 #44
0
def test_imported_landusage():
    """Multipolygon relation is inserted"""
    t.assert_cached_node(1001, (13, 47.5))
    landusage_1001 = t.query_row(t.db_conf, 'osm_landusages', -1001)
    # point in polygon
    assert landusage_1001['geometry'].intersects(t.merc_point(13.4, 47.5))
    # hole in multipolygon relation
    assert not landusage_1001['geometry'].intersects(t.merc_point(14.75, 47.75))
예제 #45
0
def test_duplicate_ids_1():
    """Points/lines/polygons with same ID are inserted."""
    node = t.query_row(t.db_conf, 'osm_all', 31101)
    assert node['geometry'].type == 'Point', node['geometry'].type
    assert node['tags'] == {'amenity': 'cafe'}
    assert node['geometry'].distance(t.merc_point(80, 47)) < 1

    ways = t.query_row(t.db_conf, 'osm_all', -31101)
    ways.sort(key=lambda x: x['geometry'].type)
    assert ways[0]['geometry'].type == 'LineString', ways[0]['geometry'].type
    assert ways[0]['tags'] == {'landuse': 'park', 'highway': 'secondary'}
    assert ways[1]['geometry'].type == 'Polygon', ways[1]['geometry'].type
    assert ways[1]['tags'] == {'landuse': 'park', 'highway': 'secondary'}

    rel = t.query_row(t.db_conf, 'osm_all', RELOFFSET-31101L)
    assert rel['geometry'].type == 'Polygon', rel['geometry'].type
    assert rel['tags'] == {'building': 'yes'}
예제 #46
0
def test_duplicate_ids_1():
    """Points/lines/polygons with same ID are inserted."""
    node = t.query_row(t.db_conf, 'osm_all', 31101)
    assert node['geometry'].type == 'Point', node['geometry'].type
    assert node['tags'] == {'amenity': 'cafe'}
    assert node['geometry'].distance(t.merc_point(80, 47)) < 1

    ways = t.query_row(t.db_conf, 'osm_all', -31101)
    ways.sort(key=lambda x: x['geometry'].type)
    assert ways[0]['geometry'].type == 'LineString', ways[0]['geometry'].type
    assert ways[0]['tags'] == {'landuse': 'park', 'highway': 'secondary'}
    assert ways[1]['geometry'].type == 'Polygon', ways[1]['geometry'].type
    assert ways[1]['tags'] == {'landuse': 'park', 'highway': 'secondary'}

    rel = t.query_row(t.db_conf, 'osm_all', RELOFFSET - 31101L)
    assert rel['geometry'].type == 'Polygon', rel['geometry'].type
    assert rel['tags'] == {'building': 'yes'}
예제 #47
0
def test_imported_landusage():
    """Multipolygon relation is inserted"""
    t.assert_cached_node(1001, (13, 47.5))
    landusage_1001 = t.query_row(t.db_conf, 'osm_landusages', -1001)
    # point in polygon
    assert landusage_1001['geometry'].intersects(t.merc_point(13.4, 47.5))
    # hole in multipolygon relation
    assert not landusage_1001['geometry'].intersects(t.merc_point(14.75, 47.75))
예제 #48
0
def test_relation_ways_inserted():
    """Outer ways of multipolygon are inserted. """
    park = t.query_row(t.db_conf, 'osm_landusages', -9201)
    assert park['type'] == 'park'
    assert park['name'] == '9209'
    assert not t.query_row(t.db_conf, 'osm_landusages', 9201)

    # outer ways of multipolygon stand for their own
    road = t.query_row(t.db_conf, 'osm_roads', 9209)
    assert road['type'] == 'secondary'
    assert road['name'] == '9209'
    road = t.query_row(t.db_conf, 'osm_roads', 9210)
    assert road['type'] == 'residential'
    assert road['name'] == '9210'

    park = t.query_row(t.db_conf, 'osm_landusages', -9301)
    assert park['type'] == 'park'
    assert park['name'] == '' # no name on relation

    # outer ways of multipolygon stand for their own
    road = t.query_row(t.db_conf, 'osm_roads', 9309)
    assert road['type'] == 'secondary'
    assert road['name'] == '9309'
    road = t.query_row(t.db_conf, 'osm_roads', 9310)
    assert road['type'] == 'residential'
    assert road['name'] == '9310'
예제 #49
0
def test_relation_ways_inserted():
    """Outer ways of multipolygon are inserted. """
    park = t.query_row(t.db_conf, 'osm_landusages', -9201)
    assert park['type'] == 'park'
    assert park['name'] == '9209'
    assert not t.query_row(t.db_conf, 'osm_landusages', 9201)

    # outer ways of multipolygon stand for their own
    road = t.query_row(t.db_conf, 'osm_roads', 9209)
    assert road['type'] == 'secondary'
    assert road['name'] == '9209'
    road = t.query_row(t.db_conf, 'osm_roads', 9210)
    assert road['type'] == 'residential'
    assert road['name'] == '9210'

    park = t.query_row(t.db_conf, 'osm_landusages', -9301)
    assert park['type'] == 'park'
    assert park['name'] == '' # no name on relation

    # outer ways of multipolygon stand for their own
    road = t.query_row(t.db_conf, 'osm_roads', 9309)
    assert road['type'] == 'secondary'
    assert road['name'] == '9309'
    road = t.query_row(t.db_conf, 'osm_roads', 9310)
    assert road['type'] == 'residential'
    assert road['name'] == '9310'
예제 #50
0
def test_mapped_closed_way_area_yes():
    """Closed way with area=yes is not stored as linestring."""
    t.assert_cached_way(20501)
    elem = t.query_row(t.db_conf, 'osm_all', -20501)
    assert elem['geometry'].type == 'Polygon', elem['geometry'].type
    assert elem['tags'] == {
        'random': 'tag',
        'landuse': 'grass',
        'highway': 'pedestrian',
        'area': 'yes'
    }
예제 #51
0
def test_mapped_closed_way_area_no():
    """Closed way with area=no is not stored as polygon."""
    t.assert_cached_way(20502)
    elem = t.query_row(t.db_conf, 'osm_all', -20502)
    assert elem['geometry'].type == 'LineString', elem['geometry'].type
    assert elem['tags'] == {
        'random': 'tag',
        'landuse': 'grass',
        'highway': 'pedestrian',
        'area': 'no'
    }
예제 #52
0
def test_mapped_closed_way_without_area():
    """Closed way without area is stored as mapped (linestring and polygon)."""
    t.assert_cached_way(20601)
    elems = t.query_row(t.db_conf, 'osm_all', 20601)
    assert len(elems) == 2
    elems.sort(key=lambda x: x['geometry'].type)

    assert elems[0]['geometry'].type == 'LineString', elem['geometry'].type
    assert elems[0]['tags'] == {'random': 'tag', 'landuse': 'grass', 'highway': 'pedestrian'}
    assert elems[1]['geometry'].type == 'Polygon', elem['geometry'].type
    assert elems[1]['tags'] == {'random': 'tag', 'landuse': 'grass', 'highway': 'pedestrian'}
예제 #53
0
def test_broken_multipolygon_ways():
    """MultiPolygons with broken outer ways are handled."""
    # outer way does not merge (17002 has one node)
    assert t.query_row(t.db_conf, 'osm_landusages', -17001) == None
    assert t.query_row(t.db_conf, 'osm_roads', 17001)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_roads', 17002) == None

    # outer way does not merge (17102 has no nodes)
    assert t.query_row(t.db_conf, 'osm_landusages', -17101) == None
    assert t.query_row(t.db_conf, 'osm_roads', 17101)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_roads', 17102) == None
예제 #54
0
def test_broken_multipolygon_ways():
    """MultiPolygons with broken outer ways are handled."""
    # outer way does not merge (17002 has one node)
    assert t.query_row(t.db_conf, 'osm_landusages', -17001) == None
    assert t.query_row(t.db_conf, 'osm_roads', 17001)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_roads', 17002) == None

    # outer way does not merge (17102 has no nodes)
    assert t.query_row(t.db_conf, 'osm_landusages', -17101) == None
    assert t.query_row(t.db_conf, 'osm_roads', 17101)['type'] == 'residential'
    assert t.query_row(t.db_conf, 'osm_roads', 17102) == None
예제 #55
0
def test_mapped_closed_way_without_area():
    """Closed way without area is stored as mapped (linestring and polygon)."""
    t.assert_cached_way(20601)
    elems = t.query_row(t.db_conf, 'osm_all', -20601)
    assert len(elems) == 2
    elems.sort(key=lambda x: x['geometry'].type)

    assert elems[0]['geometry'].type == 'LineString', elems[0]['geometry'].type
    assert elems[0]['tags'] == {
        'random': 'tag',
        'landuse': 'grass',
        'highway': 'pedestrian'
    }
    assert elems[1]['geometry'].type == 'Polygon', elems[1]['geometry'].type
    assert elems[1]['tags'] == {
        'random': 'tag',
        'landuse': 'grass',
        'highway': 'pedestrian'
    }
예제 #56
0
def test_merge_outer_multipolygon_way_1():
    """Splitted outer way of multipolygon was inserted."""
    park_16001 = t.query_row(t.db_conf, 'osm_landusages', -16001)
    assert park_16001['type'] == 'park'
    t.assert_almost_equal(park_16001['geometry'].area, 12779350582, -1)
    assert t.query_row(t.db_conf, 'osm_roads', 16002)['type'] == 'residential'
예제 #57
0
def test_split_outer_multipolygon_way_1():
    """Single outer way of multipolygon was inserted."""
    park_15001 = t.query_row(t.db_conf, 'osm_landusages', -15001)
    assert park_15001['type'] == 'park'
    t.assert_almost_equal(park_15001['geometry'].area, 9816216452, -1)
    assert t.query_row(t.db_conf, 'osm_roads', 15002) == None
예제 #58
0
def test_landusage_to_waterarea_1():
    """Parks inserted into landusages"""
    t.assert_cached_way(11001)
    t.assert_cached_way(12001)
    t.assert_cached_way(13001)

    assert not t.query_row(t.db_conf, 'osm_waterareas', 11001)
    assert not t.query_row(t.db_conf, 'osm_waterareas', -12001)
    assert not t.query_row(t.db_conf, 'osm_waterareas', -13001)

    assert not t.query_row(t.db_conf, 'osm_waterareas_gen0', 11001)
    assert not t.query_row(t.db_conf, 'osm_waterareas_gen0', -12001)
    assert not t.query_row(t.db_conf, 'osm_waterareas_gen0', -13001)

    assert not t.query_row(t.db_conf, 'osm_waterareas_gen1', 11001)
    assert not t.query_row(t.db_conf, 'osm_waterareas_gen1', -12001)
    assert not t.query_row(t.db_conf, 'osm_waterareas_gen1', -13001)

    assert t.query_row(t.db_conf, 'osm_landusages', 11001)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages', -12001)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages', -13001)['type'] == 'park'

    assert t.query_row(t.db_conf, 'osm_landusages_gen0', 11001)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages_gen0', -12001)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages_gen0', -13001)['type'] == 'park'

    assert t.query_row(t.db_conf, 'osm_landusages_gen1', 11001)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages_gen1', -12001)['type'] == 'park'
    assert t.query_row(t.db_conf, 'osm_landusages_gen1', -13001)['type'] == 'park'
예제 #59
0
def test_merge_outer_multipolygon_way_1():
    """Splitted outer way of multipolygon was inserted."""
    park_16001 = t.query_row(t.db_conf, 'osm_landusages', -16001)
    assert park_16001['type'] == 'park'
    t.assert_almost_equal(park_16001['geometry'].area, 12779350582, -1)
    assert t.query_row(t.db_conf, 'osm_roads', 16002)['type'] == 'residential'
예제 #60
0
def test_unsupported_relation():
    """
    Unsupported relation type is not inserted with update
    """
    assert not t.query_row(t.db_conf, 'osm_landusages', -201291)
    assert t.query_row(t.db_conf, 'osm_landusages', 201251)['type'] == 'park'