def test_dispute(self):
        import dsl

        z, x, y = 16, 0, 0

        self.generate_fixtures(
            # way, tagged disputed
            dsl.way(1, dsl.tile_diagonal(z, x, y), {
                'admin_level': '4',
                'boundary': 'administrative',
                'disputed': 'yes',
                'disputed_by': 'XB',
                'name': 'XA internal county border',
                'source': 'openstreetmap.org',
            }),
            # line from relation / county polygon
            dsl.way(3, dsl.tile_diagonal(z, x, y), {
                'admin_level': '6',
                'boundary': 'administrative',
                'name': 'XA county 2',
                'place': 'District',
                'type': 'boundary',
                'mz_boundary_from_polygon': True,  # need this for hack
            }),
        )

        self.assert_has_feature(
            z, x, y, 'boundaries', {
                'kind': 'county',
                'kind:xb': 'unrecognized_county',
                'name': 'XA county 2',
            })
Esempio n. 2
0
    def test_claim(self):
        import dsl

        z, x, y = 16, 0, 0

        self.generate_fixtures(
            # XA's claim relation
            dsl.way(
                1, dsl.tile_diagonal(z, x, y), {
                    'admin_level': '6',
                    'boundary': 'claim',
                    'name': 'XA county claim',
                    'claimed_by': 'XA',
                    'disputed_by': 'XB',
                    'source': 'openstreetmap.org',
                }),
            # XA's claim _way_, disputed by XB
            dsl.way(
                2, dsl.tile_diagonal(z, x, y), {
                    'disputed': 'yes',
                    'disputed_by': 'XB',
                    'source': 'openstreetmap.org',
                }),
        )

        self.assert_has_feature(z, x, y, 'boundaries', {
            'kind': 'unrecognized_county',
            'kind:xa': 'county',
        })
    def test_claim(self):
        import dsl

        z, x, y = 16, 0, 0

        self.generate_fixtures(
            # XA's claim relation
            dsl.way(1, dsl.tile_diagonal(z, x, y), {
                'admin_level': '6',
                'boundary': 'claim',
                'name': 'XA county claim',
                'claimed_by': 'XA',
                'disputed_by': 'XB',
                'source': 'openstreetmap.org',
            }),
            # XA's claim _way_, disputed by XB
            dsl.way(2, dsl.tile_diagonal(z, x, y), {
                'disputed': 'yes',
                'disputed_by': 'XB',
                'source': 'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'boundaries', {
                'kind': 'unrecognized_county',
                'kind:xa': 'county',
            })
Esempio n. 4
0
    def test_county_border(self):
        import dsl

        z, x, y = 16, 10484, 25346

        # SF City/County -- San Mateo County
        self.generate_fixtures(
            # http://www.openstreetmap.org/relation/396487
            dsl.way(
                -396487,
                dsl.tile_diagonal(z, x, y),
                {
                    u'admin_level': u'6',
                    u'attribution': u'CASIL cnty24k09_1_poly.shp',
                    u'name': u'San Francisco City and County',
                    u'county:ansi': u'075',
                    u'county:abbrev': u'SFO',
                    u'source': u'openstreetmap.org',
                    u'county:name': u'San Francisco',
                    u'alt_name': u'San Francisco',
                    u'nist:fips_code': u'6075',
                    u'nist:state_fips': u'6',
                    u'boundary': u'administrative',
                    u'population': u'870887',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
            # http://www.openstreetmap.org/relation/396498
            dsl.way(
                -396498,
                dsl.tile_diagonal(z, x, y),
                {
                    u'admin_level': u'6',
                    u'attribution': u'CASIL cnty24k09_1_poly.shp',
                    u'name': u'San Mateo County',
                    u'county:ansi': u'081',
                    u'county:abbrev': u'SMT',
                    u'way_area': u'3.05109e+09',
                    u'wikipedia': u'en:San Mateo County, California',
                    u'source': u'openstreetmap.org',
                    u'county:name': u'San Mateo',
                    u'wikidata': u'Q108101',
                    u'alt_name': u'San Mateo',
                    u'nist:fips_code': u'6081',
                    u'nist:state_fips': u'6',
                    u'boundary': u'administrative',
                    u'population': u'765135',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
        )

        self.assert_has_feature(z, x, y, 'boundaries', {
            'id': set([-396487, -396498]),
            'kind': 'county',
            'kind_detail': '6'
        })
Esempio n. 5
0
    def test_mendocino_humboldt_county_boundary(self):
        import dsl

        z, x, y = 10, 159, 387

        # county boundary between Mendocino County - Humboldt County
        self.generate_fixtures(
            # https://www.openstreetmap.org/relation/396458
            dsl.way(
                -396458,
                dsl.tile_diagonal(z, x, y),
                {
                    u'admin_level': u'6',
                    u'alt_name': u'Humboldt',
                    u'attribution': u'CASIL cnty24k09_1_poly.shp',
                    u'boundary': u'administrative',
                    u'county:abbrev': u'HUM',
                    u'county:ansi': u'023',
                    u'county:name': u'Humboldt',
                    u'name': u'Humboldt County',
                    u'nist:fips_code': u'6023',
                    u'nist:state_fips': u'6',
                    u'population': u'135727',
                    u'source': u'openstreetmap.org',
                    u'wikidata': u'Q109651',
                    u'wikipedia': u'en:Humboldt County, California',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
            # https://www.openstreetmap.org/relation/396489
            dsl.way(
                -396489,
                dsl.tile_diagonal(z, x, y),
                {
                    u'admin_level': u'6',
                    u'alt_name': u'Mendocino',
                    u'attribution': u'CASIL cnty24k09_1_poly.shp',
                    u'boundary': u'administrative',
                    u'county:abbrev': u'MEN',
                    u'county:ansi': u'045',
                    u'county:name': u'Mendocino',
                    u'name': u'Mendocino County',
                    u'nist:fips_code': u'6045',
                    u'nist:state_fips': u'6',
                    u'source': u'openstreetmap.org',
                    u'wikidata': u'Q108087',
                    u'wikipedia': u'en:Mendocino County, California',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
        )

        self.assert_has_feature(z, x, y, "boundaries", {
            "kind": "county",
            "sort_rank": 254
        })
Esempio n. 6
0
    def test_dispute(self):
        import dsl

        z, x, y = 16, 0, 0

        self.generate_fixtures(
            # way, tagged disputed
            dsl.way(
                1, dsl.tile_diagonal(z, x, y), {
                    'admin_level': '4',
                    'boundary': 'administrative',
                    'disputed': 'yes',
                    'disputed_by': 'XB',
                    'name': 'XA internal region border',
                    'source': 'openstreetmap.org',
                }),
            # way used in relations for region borders
            #
            # NOTE: we won't use this one, since we don't pay attention to
            # admin_level=3, but i included it for completeness, so that the
            # test more closely resembles the data it's based on.
            dsl.way(
                2,
                dsl.tile_diagonal(z, x, y),
                {
                    'admin_level': '3',  # 3?!? as always... data = mess
                    'border_type': 'province',
                    'boundary': 'administrative',
                    'is_in:country_code': 'XA',
                    'name': 'XA region 1',
                    'type': 'boundary',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
            # this one we do pay attention to, admin_level=4
            dsl.way(
                3,
                dsl.tile_diagonal(z, x, y),
                {
                    'admin_level': '4',
                    'boundary': 'administrative',
                    'name': 'XA region 2',
                    'place': 'District',
                    'type': 'boundary',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
        )

        self.assert_has_feature(
            z, x, y, 'boundaries', {
                'kind': 'region',
                'kind:xb': 'unrecognized_region',
                'name': 'XA region 2',
            })
    def test_county_border(self):
        import dsl

        z, x, y = 16, 10484, 25346

        # SF City/County -- San Mateo County
        self.generate_fixtures(
            # http://www.openstreetmap.org/relation/396487
            dsl.way(-396487, dsl.tile_diagonal(z, x, y), {
                u'admin_level': u'6',
                u'attribution': u'CASIL cnty24k09_1_poly.shp',
                u'name': u'San Francisco City and County',
                u'county:ansi': u'075',
                u'county:abbrev': u'SFO',
                u'source': u'openstreetmap.org',
                u'county:name': u'San Francisco',
                u'alt_name': u'San Francisco',
                u'nist:fips_code': u'6075',
                u'nist:state_fips': u'6',
                u'boundary': u'administrative',
                u'population': u'870887',
                'mz_boundary_from_polygon': True,  # need this for hack
            }),
            # http://www.openstreetmap.org/relation/396498
            dsl.way(-396498, dsl.tile_diagonal(z, x, y), {
                u'admin_level': u'6',
                u'attribution': u'CASIL cnty24k09_1_poly.shp',
                u'name': u'San Mateo County',
                u'county:ansi': u'081',
                u'county:abbrev': u'SMT',
                u'way_area': u'3.05109e+09',
                u'wikipedia': u'en:San Mateo County, California',
                u'source': u'openstreetmap.org',
                u'county:name': u'San Mateo',
                u'wikidata': u'Q108101',
                u'alt_name': u'San Mateo',
                u'nist:fips_code': u'6081',
                u'nist:state_fips': u'6',
                u'boundary': u'administrative',
                u'population': u'765135',
                'mz_boundary_from_polygon': True,  # need this for hack
            }),
        )

        self.assert_has_feature(
            z, x, y, 'boundaries',
            {'id': set([-396487, -396498]), 'kind': 'county',
             'kind_detail': '6'})
Esempio n. 8
0
    def test_state_border(self):
        import dsl

        z, x, y = 16, 12553, 24147

        # Relation: Wyoming (161991) & Idaho (162116)
        self.generate_fixtures(
            # http://www.openstreetmap.org/relation/161991
            dsl.way(
                -161991,
                dsl.tile_diagonal(z, x, y),
                {
                    u'ISO3166-2': u'US-WY',
                    u'wikidata': u'Q1214',
                    u'ref:fips': u'56',
                    u'wikipedia': u'en:Wyoming',
                    u'source': u'openstreetmap.org',
                    u'boundary': u'administrative',
                    u'ref': u'WY',
                    u'admin_level': u'4',
                    u'is_in:country_code': u'US',
                    u'name': u'Wyoming',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
            # http://www.openstreetmap.org/relation/162116
            dsl.way(
                -162116,
                dsl.tile_diagonal(z, x, y),
                {
                    u'ISO3166-2': u'US-ID',
                    u'wikidata': u'Q1221',
                    u'ref:fips': u'16',
                    u'wikipedia': u'en:Idaho',
                    u'source': u'openstreetmap.org',
                    u'boundary': u'administrative',
                    u'ref': u'ID',
                    u'admin_level': u'4',
                    u'is_in:country_code': u'US',
                    u'name': u'Idaho',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
        )

        self.assert_has_feature(z, x, y, 'boundaries', {
            'id': set([-161991, -162116]),
            'kind': 'region',
            'kind_detail': '4'
        })
Esempio n. 9
0
    def test_nevada_california_boundary(self):
        import dsl

        z, x, y = 8, 42, 96
        # region boundary between Nevada - California
        self.generate_fixtures(
            # https://www.openstreetmap.org/relation/165473
            dsl.way(
                -165473,
                dsl.tile_diagonal(z, x, y),
                {
                    u'ISO3166-2': u'US-NV',
                    u'admin_level': u'4',
                    u'boundary': u'administrative',
                    u'is_in:country_code': u'US',
                    u'name': u'Nevada',
                    u'ref': u'NV',
                    u'ref:fips': u'32',
                    u'source': u'openstreetmap.org',
                    u'wikidata': u'Q1227',
                    u'wikipedia': u'en:Nevada',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
            # https://www.openstreetmap.org/relation/165475
            dsl.way(
                -165475,
                dsl.tile_diagonal(z, x, y),
                {
                    u'ISO3166-2': u'US-CA',
                    u'admin_level': u'4',
                    u'alt_name:vi': u'California',
                    u'boundary': u'administrative',
                    u'is_in:country_code': u'US',
                    u'name': u'California',
                    u'place': u'state',
                    u'ref': u'CA',
                    u'ref:fips': u'06',
                    u'source': u'openstreetmap.org',
                    u'wikidata': u'Q99',
                    u'wikipedia': u'en:California',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
        )

        self.assert_has_feature(z, x, y, "boundaries", {
            "kind": "region",
            "sort_rank": 256
        })
    def test_railway_embankment_yes_way(self):
        import dsl

        z, x, y = (16, 19278, 24646)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/95467611
            dsl.way(95467611, dsl.tile_diagonal(z, x, y), {
                'electrified': u'no',
                'embankment': u'yes',
                'gauge': u'1435',
                'maxspeed': u'25 mph',
                'name': u'National Docks Branch',
                'old_railway_operator': u'LV',
                'operator': u'Conrail',
                'railway': u'rail',
                'railway:traffic_mode': u'freight',
                'source': u'openstreetmap.org',
                'source:maxspeed': u'Conrail ETT 2013-10-17',
                'usage': u'branch',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 95467611,
                'kind': u'rail',
                'embankment': 'yes',
            })
    def test_embankment_both_way(self):
        import dsl

        z, x, y = (16, 16196, 25177)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/540442026
            dsl.way(540442026, dsl.tile_diagonal(z, x, y), {
                'embankment': u'both',
                'hgv': u'designated',
                'hgv:national_network': u'yes',
                'highway': u'primary',
                'lanes': u'2',
                'maxspeed': u'55 mph',
                'name': u'Highway 50',
                'NHS': u'yes',
                'ref': u'US 50',
                'source': u'openstreetmap.org',
                'surface': u'asphalt',
                'tiger:cfcc': u'A21',
                'tiger:county': u'Franklin, MO',
                'tiger:reviewed': u'no',
            }),
        )

        # NOTE: embankment=both is mapped to embankment:yes.
        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 540442026,
                'kind': u'major_road',
                'kind_detail': 'primary',
                'embankment': 'yes',
            })
    def test_viroads(self):
        # despite the network tag, this is actually in Vietnam (ISO code VN,
        # not VI).
        import dsl

        z, x, y = (16, 51909, 28995)

        self.generate_fixtures(
            dsl.is_in('VN', z, x, y),
            # https://www.openstreetmap.org/way/48844918
            dsl.way(48844918, dsl.tile_diagonal(z, x, y), {
                'highway': u'secondary',
                'ref': u'217',
                'source': u'openstreetmap.org',
            }),
            dsl.relation(1, {
                'network': u'VI-roads',
                'ref': u'217',
                'route': u'road',
                'source': u'openstreetmap.org',
                'type': u'route',
            }, ways=[48844918]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 48844918,
                'shield_text': '217',
                'network': u'VN:road',
            })
    def test_dc86_ro(self):
        import dsl

        z, x, y = (16, 37979, 23748)

        self.generate_fixtures(
            dsl.is_in('RO', z, x, y),
            # https://www.openstreetmap.org/way/12109479
            dsl.way(12109479, dsl.tile_diagonal(z, x, y), {
                'bicycle': u'yes',
                'highway': u'primary',
                'is_in:city': u'Năvodari',
                'lanes': u'2',
                'maxspeed': u'70',
                'oneway': u'no',
                'ref': u'DC86',
                'source': u'openstreetmap.org',
                'surface': u'asphalt',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 12109479,
                'network': u'RO:local',
                'shield_text': u'86',
            })
    def test_rail_rail(self):
        import dsl

        z, x, y = (16, 10504, 25313)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/77517466
            dsl.way(77517466, dsl.tile_diagonal(z, x, y), {
                'electrified': 'no',
                'gauge': '1435',
                'maxspeed': '79 mph',
                'maxspeed:freight': '70 mph',
                'name': 'Martinez Subdivision MT1',
                'owner': 'Union Pacific Railroad',
                'passenger_lines': '2',
                'railway': 'rail',
                'railway:track_ref': '1',
                'source': 'openstreetmap.org',
                'usage': 'main',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 77517466,
                'kind': u'rail',
                'kind_detail': u'rail',
            })
    def test_asianhighway_no_relation(self):
        import dsl

        z, x, y = (16, 55886, 25381)

        self.generate_fixtures(
            dsl.is_in('KR', z, x, y),
            # https://www.openstreetmap.org/way/37399710
            dsl.way(37399710, dsl.tile_diagonal(z, x, y), {
                'tunnel:name:ko_rm': 'Namsan il ho teoneol', 'tunnel': 'yes',
                'layer': '-2', 'name:en': 'Samil-daero', 'name': u'삼일대로',
                'tunnel:name:ko': u'남산1호터널', 'name:ko': u'삼일대로',
                'review': 'no', 'name:ko_rm': 'Samil-daero',
                'tunnel:name:en': 'Namsan 1 Ho Tunnel',
                'source': 'openstreetmap.org', 'ncat': u'광역시도로',
                'oneway': 'yes', 'tunnel:name': u'남산1호터널', 'ref': 'AH1',
                'toll': 'yes', 'highway': 'primary', 'name:ja': u'三一大路',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 37399710,
                'shield_text': '1',
                'network': 'AsianHighway',
            })
Esempio n. 16
0
    def test_mbsa15_mysgrmunicipal(self):
        import dsl

        z, x, y = (16, 51252, 32209)

        self.generate_fixtures(
            dsl.is_in('MY', z, x, y),
            # https://www.openstreetmap.org/way/24701880
            dsl.way(
                24701880, dsl.tile_diagonal(z, x, y), {
                    'highway': u'primary',
                    'is_in': u'Shah Alam, Selangor, Malaysia',
                    'lanes': u'2',
                    'oneway': u'yes',
                    'ref': u'MBSA 15',
                    'source': u'openstreetmap.org',
                }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 24701880,
                'network': u'MY:SGR:municipal',
                'shield_text': u'BSA15',
            })
    def test_br_ERS(self):
        import dsl

        z, x, y = (16, 23101, 38967)

        self.generate_fixtures(
            dsl.is_in('BR', z, x, y),
            # https://www.openstreetmap.org/way/20906150
            dsl.way(20906150, dsl.tile_diagonal(z, x, y), {
                'old_ref': 'RS-602', 'maxspeed': '80', 'surface': 'asphalt',
                'source': 'openstreetmap.org', 'ref': 'ERS-602',
                'highway': 'secondary',
            }),
            dsl.relation(1, {
                'network': 'BR:RS', 'ref': 'ERS-602', 'route': 'road',
                'surface': 'asphalt', 'source': 'openstreetmap.org',
                'type': 'route',
            }, ways=[20906150]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 20906150,
                'shield_text': '602', 'network': 'BR:RS',
                'all_networks': ['BR:RS'],
                'all_shield_texts': ['602'],
            })
Esempio n. 18
0
    def test_train_route(self):
        import dsl

        z, x, y = 9, 150, 192

        self.generate_fixtures(
            dsl.way(1359387, dsl.tile_diagonal(z, x, y), {
                "website": "http://www.amtrak.com",
                "passenger": "national",
                "via": "New York Penn Station",
                "from": "Washington, DC",
                "name": "Vermonter",
                "service": "long_distance",
                "to": "Saint Albans, Vermont",
                "route": "train",
                "wikipedia": "en:Vermonter (train)",
                "route_name": "Vermonter",
                "route_pref_color": "0",
                "public_transport:version": "1",
                "wikidata": "Q1412872",
                "source": "openstreetmap.org",
                "operator": "Amtrak",
                "ref": "54-57",
                "colour": "#005480",
                "network": "Amtrak"
            }),
        )

        self.assert_has_feature(
            z, x, y, 'transit',
            {'min_zoom': 5, 'ref': '54-57',
             'source': 'openstreetmap.org',
             'name': 'Vermonter'})
Esempio n. 19
0
    def test_j137_my_jhr(self):
        import dsl

        z, x, y = (16, 51464, 32364)

        self.generate_fixtures(
            dsl.is_in('MY', z, x, y),
            # https://www.openstreetmap.org/way/5037585
            dsl.way(
                5037585, dsl.tile_diagonal(z, x, y), {
                    'highway': u'primary',
                    'is_in': u'Panchor, Muar, Johor, Malaysia',
                    'is_in:country': u'Malaysia',
                    'is_in:state': u'Johor',
                    'name': u'Jalan Panchor',
                    'ref': u'J137',
                    'source': u'openstreetmap.org',
                }),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 5037585,
            'network': u'MY:JHR',
            'shield_text': u'J137',
        })
    def test_kr_expressway(self):
        import dsl

        z, x, y = (16, 55904, 25415)

        self.generate_fixtures(
            dsl.is_in('KR', z, x, y),
            # https://www.openstreetmap.org/way/59242897
            dsl.way(59242897, dsl.tile_diagonal(z, x, y), {
                'name:en': 'Seoul Ring Expressway', 'lanes': '4',
                'name': u'서울외곽순환고속도로',
                'name:ko': u'서울외곽순환고속도로',
                'name:ko_rm': 'Seouloegwaksunhwangosokdoro',
                'source': 'openstreetmap.org', 'oneway': 'yes', 'ref': '100',
                'highway': 'motorway',
            }),
            dsl.relation(1, {
                'name:en': 'Seoul Ring Expressway(KEC), bound for '
                'Pangyo(Ilsan)',
                'name': u'서울외곽순환고속도로(도로공사) 판교(일산)방향',
                'name:ko': u'서울외곽순환고속도로(도로공사) 판교(일산)방향',
                'route': 'road', 'source': 'openstreetmap.org',
                'operator': 'Korea Expressway Corporation', 'type': 'route',
                'road': 'kr:expressway', 'network': 'KR:expressway',
            }, ways=[59242897]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 59242897,
                'shield_text': '100',
                'network': 'KR:expressway',
            })
    def test_kr_expressway_rel_no_net(self):
        import dsl

        z, x, y = (16, 55975, 25658)

        self.generate_fixtures(
            dsl.is_in('KR', z, x, y),
            # https://www.openstreetmap.org/way/90611594
            dsl.way(90611594, dsl.tile_diagonal(z, x, y), {
                'name:en': u'Tongyeong–Daejeon Expressway', 'lanes': '2',
                'name': u'통영대전고속도로', 'name:ko': u'통영대전고속도로',
                'name:ko_rm': 'Tongyeong-daejeon-gosokdoro',
                'source': 'openstreetmap.org', 'maxspeed': '100',
                'oneway': 'yes', 'ref': '35', 'highway': 'motorway',
            }),
            dsl.relation(1, {
                'layer': '1', 'name:en': u'Tongyeong–Daejeon Expressway',
                'name': u'통영대전고속도로', 'name:ko': u'통영대전고속도로',
                'type': 'route', 'route': 'road',
                'source': 'openstreetmap.org', 'ref': '35',
            }, ways=[90611594]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 90611594,
                'shield_text': '35',
                'network': 'KR:expressway',
            })
    def test_asianhighway(self):
        import dsl

        z, x, y = (16, 55875, 25370)

        self.generate_fixtures(
            dsl.is_in('KR', z, x, y),
            # https://www.openstreetmap.org/way/547188348
            dsl.way(547188348, dsl.tile_diagonal(z, x, y), {
                'name:en': 'Tongil-ro', 'name': u'통일로', 'review': 'no',
                'source': 'openstreetmap.org', 'highway': 'primary',
            }),
            dsl.relation(1, {
                'alt_name': u'아주공로 1호선', 'int_ref': 'AH1', 'layer': '1',
                'section': 'Korea', 'int_name': 'Asian Highway AH1',
                'network': 'AH', 'name': u'아시안 하이웨이 1호선',
                'name:en': 'Asian Highway AH1', 'ref': 'AH1', 'route': 'road',
                'source': 'openstreetmap.org', 'state': 'connection',
                'type': 'route', 'wikidata': 'Q494205', 'wikipedia': 'en:AH1',
            }, ways=[547188348]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 547188348,
                'shield_text': '1',
                'network': 'AsianHighway',
            })
    def test_no(self):
        import dsl

        z, x, y = (16, 10541, 25410)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/518869401
            dsl.way(
                518869401, dsl.tile_diagonal(z, x, y), {
                    'access': u'permissive',
                    'bicycle': u'permissive',
                    'bridge': u'no',
                    'foot': u'permissive',
                    'highway': u'footway',
                    'horse': u'no',
                    'lit': u'yes',
                    'motor_vehicle': u'no',
                    'source': u'openstreetmap.org',
                    'surface': u'concrete',
                }), )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 518869401,
            'is_bridge': type(None),
        })
    def test_54_inmdr(self):
        import dsl

        z, x, y = (16, 46579, 26841)

        self.generate_fixtures(
            dsl.is_in('IN', z, x, y),
            # https://www.openstreetmap.org/way/11760010
            dsl.way(11760010, dsl.tile_diagonal(z, x, y), {
                'highway': u'secondary',
                'name': u'Rahon Road',
                'ref': u'MDR54',
                'source': u'openstreetmap.org',
            }),
            dsl.relation(1, {
                'network': u'IN:SH:PB',
                'ref': u'MDR54',
                'route': u'road',
                'source': u'openstreetmap.org',
                'type': u'route',
            }, ways=[11760010]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 11760010,
                'network': u'IN:MDR',
                'shield_text': u'54',
            })
    def test_se(self):
        import dsl

        z, x, y = (16, 26010, 34601)

        self.generate_fixtures(
            dsl.is_in('BR', z, x, y),
            # https://www.openstreetmap.org/way/31529719
            dsl.way(31529719, dsl.tile_diagonal(z, x, y), {
                'source': 'openstreetmap.org', 'ref': 'SE-200',
                'surface': 'asphalt', 'highway': 'primary',
                'IBGE:CD_ADMINIS': 'estadual',
            }),
            dsl.relation(1, {
                'type': 'route', 'route': 'road', 'ref': 'SE-200',
                'network': 'SE', 'source': 'openstreetmap.org',
            }, ways=[31529719]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 31529719,
                'shield_text': '200', 'network': 'BR:SE',
                'all_shield_texts': ['200'],
                'all_networks': ['BR:SE'],
            })
    def test_20_chnational(self):
        import dsl

        z, x, y = (16, 34009, 23025)

        self.generate_fixtures(
            dsl.is_in('CH', z, x, y),
            # https://www.openstreetmap.org/way/24521024
            dsl.way(24521024, dsl.tile_diagonal(z, x, y), {
                'highway': u'primary',
                'lit': u'yes',
                'name': u'Boulevard de la Liberté',
                'ref': u'20',
                'source': u'openstreetmap.org',
            }),
            dsl.relation(1, {
                'name': u'Hauptstrasse 20',
                'name:fr': u'Route Principale 20',
                'network': u'ch:national',
                'note': u'(F)–Le Locle–La Chaux-de-Fonds–Neuchâtel',
                'ref': u'20',
                'route': u'road',
                'source': u'openstreetmap.org',
                'type': u'route',
            }, ways=[24521024]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 24521024,
                'network': u'CH:national',
                'shield_text': u'20',
            })
    def test_br_PRC(self):
        import dsl

        z, x, y = (16, 23383, 37517)

        self.generate_fixtures(
            dsl.is_in('BR', z, x, y),
            # https://www.openstreetmap.org/way/31611447
            dsl.way(31611447, dsl.tile_diagonal(z, x, y), {
                'maxspeed': '110', 'surface': 'paved',
                'source': 'openstreetmap.org', 'IBGE:CD_ADMINIS': 'federal',
                'nat_ref': 'BR-466', 'ref': 'PRC-466', 'highway': 'primary',
            }),
            dsl.relation(1, {
                'type': 'route', 'route': 'road', 'ref': 'BR-466',
                'network': 'BR', 'source': 'openstreetmap.org',
            }, ways=[31611447]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 31611447,
                'shield_text': '466', 'network': 'BR',
                'all_shield_texts': ['466', '466'],
                'all_networks': ['BR', 'BR:PR']
            })
    def test_dt388_vnprovincial(self):
        import dsl

        z, x, y = (16, 52176, 28882)

        self.generate_fixtures(
            dsl.is_in('VN', z, x, y),
            # https://www.openstreetmap.org/way/160413329
            dsl.way(160413329, dsl.tile_diagonal(z, x, y), {
                'bicycle': u'yes',
                'cycleway': u'no',
                'foot': u'yes',
                'highway': u'secondary',
                'maxspeed': u'40',
                'name': u'Đường 208',
                'oneway': u'no',
                'ref': u'ĐT 388',
                'source': u'openstreetmap.org',
                'surface': u'asphalt',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 160413329,
                'network': u'VN:provincial',
                'shield_text': u'ĐT388',
            })
    def _check_rank(self,
                    tags,
                    zoom=16,
                    source='openstreetmap.org',
                    layer='pois',
                    kind=None,
                    rank=None,
                    geom_type='point'):
        import dsl

        z, x, y = (zoom, 0, 0)

        all_tags = tags.copy()
        all_tags['source'] = source
        if 'name' not in all_tags:
            all_tags['name'] = 'Some name'

        assert geom_type in ('point', 'line', 'polygon')
        if geom_type == 'point':
            shape = dsl.tile_centre_shape(z, x, y)
        elif geom_type == 'line':
            shape = dsl.tile_diagonal(z, x, y)
        elif geom_type == 'polygon':
            shape = dsl.tile_box(z, x, y)

        self.generate_fixtures(dsl.way(1, shape, all_tags))

        self.assert_has_feature(z, x, y, layer, {
            'kind': kind,
            'collision_rank': rank,
        })
    def test_kr_jungbunaeryukgosokdoro(self):
        import dsl

        z, x, y = (16, 56156, 25839)

        self.generate_fixtures(
            dsl.is_in('KR', z, x, y),
            # https://www.openstreetmap.org/way/562319872
            dsl.way(562319872, dsl.tile_diagonal(z, x, y), {
                'name:en': 'Jungbunaeryuk Expressway', 'lanes': '2',
                'name': u'중부내륙고속도로', 'name:ko': u'중부내륙고속도로',
                'review': 'no', 'name:ko_rm': 'Jungbunaeryukgosokdoro',
                'source': 'openstreetmap.org', 'ncat': u'고속도로',
                'oneway': 'yes', 'ref': '45', 'toll': 'yes',
                'highway': 'motorway',
            }),
            dsl.relation(1, {
                'name:en': 'Jungbunaeryuk Expressway',
                'name': u'중부내륙고속도로', 'name:ko': u'중부내륙고속도로',
                'ref': '45', 'route': 'road', 'source': 'openstreetmap.org',
                'type': 'route',
            }, ways=[562319872]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 562319872,
                'shield_text': '45',
                'network': 'KR:expressway',
            })
Esempio n. 31
0
    def test_sa33_my_(self):
        import dsl

        z, x, y = (16, 53870, 31872)

        self.generate_fixtures(
            dsl.is_in('MY', z, x, y),
            # https://www.openstreetmap.org/way/32770972
            dsl.way(
                32770972, dsl.tile_diagonal(z, x, y), {
                    'access': u'yes',
                    'bicycle': u'yes',
                    'cycleway': u'no',
                    'fixme': u'yes',
                    'foot': u'yes',
                    'highway': u'secondary',
                    'horse': u'no',
                    'lanes': u'2',
                    'lit': u'no',
                    'motor_vehicle': u'yes',
                    'name': u'Jalan Paal-Kuala Tomani',
                    'oneway': u'no',
                    'ref': u'SA33',
                    'source': u'openstreetmap.org',
                    'surface': u'asphalt',
                }),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 32770972,
            'network': u'MY:SBH',
            'shield_text': u'SA33',
        })
    def append(self,
               tags={},
               source='openstreetmap.org',
               layer='pois',
               geom_type='point'):
        import dsl

        all_tags = tags.copy()
        all_tags['source'] = source
        if 'name' not in all_tags:
            all_tags['name'] = 'Some name'

        assert geom_type in ('point', 'line', 'polygon')
        if geom_type == 'point':
            shape = dsl.tile_centre_shape(self.z, self.x, self.y)
        elif geom_type == 'line':
            shape = dsl.tile_diagonal(self.z, self.x, self.y)
        elif geom_type == 'polygon':
            shape = dsl.tile_box(self.z, self.x, self.y)

        item_fid = self.id_counter
        self.id_counter += 1

        self.items.append(dsl.way(item_fid, shape, all_tags))
        return item_fid
Esempio n. 33
0
    def test_54_myfederal(self):
        import dsl

        z, x, y = (16, 51239, 32174)

        self.generate_fixtures(
            dsl.is_in('MY', z, x, y),
            # https://www.openstreetmap.org/way/258246542
            dsl.way(
                258246542, dsl.tile_diagonal(z, x, y), {
                    'bicycle': u'yes',
                    'foot': u'yes',
                    'highway': u'trunk',
                    'lanes': u'2',
                    'maxspeed': u'90',
                    'motor_vehicle': u'yes',
                    'name': u'Jalan Kepong - Kuala Selangor',
                    'oneway': u'yes',
                    'ref': u'FT54',
                    'source': u'openstreetmap.org',
                    'surface': u'paved',
                }),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 258246542,
            'network': u'MY:federal',
            'shield_text': u'54',
        })
    def test_road_shield_text(self):
        # if the road has no name, but does have a shield, then we want to give
        # it a collision_rank.
        import dsl

        z, x, y = (16, 0, 0)

        self.generate_fixtures(
            dsl.is_in('US', z, x, y),
            dsl.way(1, dsl.tile_diagonal(z, x, y), {
                'highway': 'motorway',
                'source': 'openstreetmap.org',
            }),
            dsl.relation(1, {
                'network': 'US-I',
                'ref': '101',
                'type': 'route',
                'route': 'road',
            },
                         ways=[1]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'kind': 'highway',
                'name': type(None),
                'shield_text': '101',
                'collision_rank': int,
            })
    def test_orr_innh_chennai(self):
        import dsl

        z, x, y = (16, 47346, 30371)

        self.generate_fixtures(
            dsl.is_in('IN', z, x, y),
            # https://www.openstreetmap.org/way/26807719
            dsl.way(26807719, dsl.tile_diagonal(z, x, y), {
                'highway': u'motorway',
                'lanes': u'3',
                'layer': u'1',
                'maxspeed': u'100',
                'motorroad': u'yes',
                'name': u'Outer Ring Road',
                'oneway': u'yes',
                'ref': u'ORR',
                'source': u'openstreetmap.org',
                'source:lanes': u'DigitalGlobeStandard',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 26807719,
                'network': u'IN:NH',
                'shield_text': u'ORR',
            })
Esempio n. 36
0
    def test_d260_tr(self):
        import dsl

        z, x, y = (16, 38509, 24944)

        self.generate_fixtures(
            dsl.is_in('TR', z, x, y),
            # https://www.openstreetmap.org/way/4636868
            dsl.way(
                4636868, dsl.tile_diagonal(z, x, y), {
                    'highway': u'trunk',
                    'level': u'-1',
                    'oneway': u'yes',
                    'ref': u'D-260',
                    'source': u'openstreetmap.org',
                }),
            dsl.relation(1, {
                'network': u'TR-roads',
                'ref': u'D 260',
                'route': u'road',
                'source': u'openstreetmap.org',
                'type': u'route',
            },
                         ways=[4636868]),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 4636868,
            'network': u'TR:highway',
            'shield_text': u'D260',
        })
    def test_ct01_vnexpressway(self):
        import dsl

        z, x, y = (16, 52150, 30818)

        self.generate_fixtures(
            dsl.is_in('VN', z, x, y),
            # https://www.openstreetmap.org/way/129963821
            dsl.way(129963821, dsl.tile_diagonal(z, x, y), {
                'bridge': u'yes',
                'highway': u'motorway',
                'lanes': u'2',
                'layer': u'1',
                'maxspeed': u'100',
                'name': u'TP Hồ Chí Minh - Trung Lương',
                'oneway': u'yes',
                'ref': u'CT01',
                'source': u'openstreetmap.org',
                'toll': u'yes',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 129963821,
                'network': u'VN:expressway',
                'shield_text': u'CT01',
            })
Esempio n. 38
0
    def test_d965_d060_tr(self):
        import dsl

        z, x, y = (16, 40623, 24630)

        self.generate_fixtures(
            dsl.is_in('TR', z, x, y),
            # https://www.openstreetmap.org/way/47053015
            dsl.way(
                47053015, dsl.tile_diagonal(z, x, y), {
                    'highway': u'primary',
                    'int_ref': u'E 691',
                    'name': u'Kars-Ardahan yolu',
                    'ref': u'D 965 / D 060',
                    'source': u'openstreetmap.org',
                    'surface': u'asphalt',
                }),
            # this is in some relations, but this test is about parsing the ref
            # that has all those spaces and slashes in it.
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 47053015,
                'network': u'TR:highway',
                'shield_text': u'D060',
                'all_networks': ['TR:highway', 'TR:highway'],
                'all_shield_texts': ['D060', 'D965'],
            })
    def test_vntl(self):
        import dsl

        z, x, y = (16, 52078, 29058)

        self.generate_fixtures(
            dsl.is_in('VN', z, x, y),
            # https://www.openstreetmap.org/way/161484320
            dsl.way(161484320, dsl.tile_diagonal(z, x, y), {
                'alt_name': u'Đường Cà Mau',
                'highway': u'secondary',
                'name': u'Tỉnh lộ 481',
                'ref': u'481',
                'source': u'openstreetmap.org',
            }),
            dsl.relation(1, {
                'alt_name': u'Đường Cà Mau',
                'highway': u'secondary',
                'name': u'Tỉnh lộ 481',
                'network': u'VN-TL',
                'ref': u'481',
                'route': u'road',
                'source': u'openstreetmap.org',
                'type': u'route',
            }, ways=[161484320]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 161484320,
                'shield_text': u'TL481',
                'network': u'VN:provincial',
            })
Esempio n. 40
0
    def test_o31_tr(self):
        import dsl

        z, x, y = (16, 37725, 25197)

        self.generate_fixtures(
            dsl.is_in('TR', z, x, y),
            # https://www.openstreetmap.org/way/4392510
            dsl.way(
                4392510, dsl.tile_diagonal(z, x, y), {
                    'highway': u'motorway',
                    'int_ref': u'E 87',
                    'lanes': u'3',
                    'maxspeed': u'120',
                    'oneway': u'yes',
                    'ref': u'O-31',
                    'source': u'openstreetmap.org',
                    'surface': u'asphalt',
                    'toll': u'yes',
                }),
            dsl.relation(1, {
                'name:bg': u'Европейски път Е 87, Турция',
                'name:de': u'Europastraße 87, Türkei',
                'name:en': u'European Route 87, Turkey',
                'network': u'e-road',
                'ref': u'E 87',
                'route': u'road',
                'source': u'openstreetmap.org',
                'type': u'route',
            },
                         ways=[4392510]),
            dsl.relation(2, {
                'e-road': u'A_link',
                'from': u'E 87',
                'network': u'e-road',
                'route': u'road',
                'source': u'openstreetmap.org',
                'to': u'E 96',
                'type': u'route',
            },
                         ways=[4392510]),
            dsl.relation(3, {
                'description': u'İzmir - Aydın otoyolu',
                'network': u'TR-roads',
                'ref': u'O-31',
                'route': u'road',
                'source': u'openstreetmap.org',
                'type': u'route',
            },
                         ways=[4392510]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 4392510,
                'network': u'TR:motorway',
                'shield_text': u'O31',
                'all_networks': ['TR:motorway', 'e-road'],
                'all_shield_texts': ['O31', 'E87'],
            })
    def test_dj200b_ro(self):
        import dsl

        z, x, y = (16, 37519, 23715)

        self.generate_fixtures(
            dsl.is_in('RO', z, x, y),
            # https://www.openstreetmap.org/way/3118247
            dsl.way(3118247, dsl.tile_diagonal(z, x, y), {
                'highway': u'primary',
                'is_in:city': u'București',
                'lanes': u'2',
                'maxspeed': u'50',
                'name': u'Bulevardul Iancu de Hunedoara',
                'oneway': u'yes',
                'ref': u'DJ200B',
                'smoothness': u'excellent',
                'source': u'openstreetmap.org',
                'surface': u'asphalt',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 3118247,
                'network': u'RO:county',
                'shield_text': u'200B',
            })
    def test_railway_cutting_yes_way(self):
        import dsl

        z, x, y = (16, 19279, 24646)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/95467617
            dsl.way(
                95467617, dsl.tile_diagonal(z, x, y), {
                    'cutting': u'yes',
                    'electrified': u'no',
                    'gauge': u'1435',
                    'maxspeed': u'15 mph',
                    'name': u'Bayonne Connection',
                    'railway': u'rail',
                    'railway:traffic_mode': u'freight',
                    'source': u'openstreetmap.org',
                    'source:maxspeed': u'Conrail ETT 2013-10-17',
                    'usage': u'industrial',
                }), )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 95467617,
            'kind': u'rail',
            'cutting': 'yes',
        })
    def test_railway_cutting_yes_way(self):
        import dsl

        z, x, y = (16, 19279, 24646)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/95467617
            dsl.way(95467617, dsl.tile_diagonal(z, x, y), {
                'cutting': u'yes',
                'electrified': u'no',
                'gauge': u'1435',
                'maxspeed': u'15 mph',
                'name': u'Bayonne Connection',
                'railway': u'rail',
                'railway:traffic_mode': u'freight',
                'source': u'openstreetmap.org',
                'source:maxspeed': u'Conrail ETT 2013-10-17',
                'usage': u'industrial',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 95467617,
                'kind': u'rail',
                'cutting': 'yes',
            })
    def test_railway_embankment_yes_way(self):
        import dsl

        z, x, y = (16, 19278, 24646)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/95467611
            dsl.way(
                95467611, dsl.tile_diagonal(z, x, y), {
                    'electrified': u'no',
                    'embankment': u'yes',
                    'gauge': u'1435',
                    'maxspeed': u'25 mph',
                    'name': u'National Docks Branch',
                    'old_railway_operator': u'LV',
                    'operator': u'Conrail',
                    'railway': u'rail',
                    'railway:traffic_mode': u'freight',
                    'source': u'openstreetmap.org',
                    'source:maxspeed': u'Conrail ETT 2013-10-17',
                    'usage': u'branch',
                }), )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 95467611,
            'kind': u'rail',
            'embankment': 'yes',
        })
    def test_embankment_left_way(self):
        import dsl

        z, x, y = (16, 19715, 24176)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/430667681
            dsl.way(430667681, dsl.tile_diagonal(z, x, y), {
                'attribution': u'Office of Geographic and ' \
                u'Environmental Information (MassGIS)',
                'condition': u'fair',
                'embankment': u'left',
                'highway': u'residential',
                'lanes': u'2',
                'massgis:way_id': u'187669',
                'name': u'South Row Road',
                'source': u'openstreetmap.org',
                'width': u'9.1',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 430667681,
                'kind': u'minor_road',
                'kind_detail': 'residential',
                'embankment': 'left',
            })
    def test_embankment_left_way(self):
        import dsl

        z, x, y = (16, 19715, 24176)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/430667681
            dsl.way(430667681, dsl.tile_diagonal(z, x, y), {
                'attribution': u'Office of Geographic and ' \
                u'Environmental Information (MassGIS)',
                'condition': u'fair',
                'embankment': u'left',
                'highway': u'residential',
                'lanes': u'2',
                'massgis:way_id': u'187669',
                'name': u'South Row Road',
                'source': u'openstreetmap.org',
                'width': u'9.1',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 430667681,
                'kind': u'minor_road',
                'kind_detail': 'residential',
                'embankment': 'left',
            })
    def test_viaduct(self):
        import dsl

        z, x, y = (16, 36399, 22206)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/365016934
            dsl.way(
                365016934, dsl.tile_diagonal(z, x, y), {
                    'bicycle': 'use_sidepath',
                    'bridge': 'viaduct',
                    'dual_carriageway': 'yes',
                    'highway': 'primary',
                    'lanes': '2',
                    'layer': '1',
                    'maxspeed': '70',
                    'name': 'Wita Stwosza',
                    'oneway': 'yes',
                    'source': 'openstreetmap.org',
                    'source:maxspeed': 'sign',
                    'surface': 'asphalt',
                }), )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 365016934,
            'is_bridge': True,
        })
    def test_embankment_both_way(self):
        import dsl

        z, x, y = (16, 16196, 25177)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/540442026
            dsl.way(
                540442026, dsl.tile_diagonal(z, x, y), {
                    'embankment': u'both',
                    'hgv': u'designated',
                    'hgv:national_network': u'yes',
                    'highway': u'primary',
                    'lanes': u'2',
                    'maxspeed': u'55 mph',
                    'name': u'Highway 50',
                    'NHS': u'yes',
                    'ref': u'US 50',
                    'source': u'openstreetmap.org',
                    'surface': u'asphalt',
                    'tiger:cfcc': u'A21',
                    'tiger:county': u'Franklin, MO',
                    'tiger:reviewed': u'no',
                }), )

        # NOTE: embankment=both is mapped to embankment:yes.
        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 540442026,
                'kind': u'major_road',
                'kind_detail': 'primary',
                'embankment': 'yes',
            })
    def test_pb(self):
        import dsl

        z, x, y = (16, 25886, 34039)

        self.generate_fixtures(
            dsl.is_in('BR', z, x, y),
            # https://www.openstreetmap.org/way/31514019
            dsl.way(31514019, dsl.tile_diagonal(z, x, y), {
                'horse': 'yes', 'maxspeed': '80', 'bicycle': 'yes',
                'oneway': 'no', 'surface': 'asphalt', 'cycleway': 'no',
                'access': 'yes', 'source': 'openstreetmap.org',
                'IBGE:CD_ADMINIS': 'estadual', 'foot': 'yes', 'lanes': '2',
                'sidewalk': 'none', 'ref': 'PB-366', 'highway': 'secondary',
            }),
            dsl.relation(1, {
                'source': 'openstreetmap.org', 'route': 'road',
                'ref': 'PB-366', 'network': 'BR:PB', 'type': 'route',
            }, ways=[31514019]),
            dsl.relation(2, {
                'type': 'route', 'route': 'road', 'ref': 'BR-426',
                'network': 'BR', 'source': 'openstreetmap.org',
            }, ways=[31514019]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 31514019,
                'shield_text': '426', 'network': 'BR',
                'all_networks': ['BR', 'BR:PB'],
                'all_shield_texts': ['426', '366'],
            })
    def test_rail_rail(self):
        import dsl

        z, x, y = (16, 10504, 25313)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/77517466
            dsl.way(
                77517466, dsl.tile_diagonal(z, x, y), {
                    'electrified': 'no',
                    'gauge': '1435',
                    'maxspeed': '79 mph',
                    'maxspeed:freight': '70 mph',
                    'name': 'Martinez Subdivision MT1',
                    'owner': 'Union Pacific Railroad',
                    'passenger_lines': '2',
                    'railway': 'rail',
                    'railway:track_ref': '1',
                    'source': 'openstreetmap.org',
                    'usage': 'main',
                }), )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 77517466,
            'kind': u'rail',
            'kind_detail': u'rail',
        })
    def test_br_MGC(self):
        import dsl

        z, x, y = (16, 24603, 36244)

        self.generate_fixtures(
            dsl.is_in('BR', z, x, y),
            # https://www.openstreetmap.org/way/31574746
            dsl.way(31574746, dsl.tile_diagonal(z, x, y), {
                'network': 'BR', 'IBGE:CD_ADMINIS': 'estadual',
                'surface': 'paved', 'source': 'openstreetmap.org',
                'incorrect:name': 'MGC-259', 'oneway': 'no',
                'ref': 'MGC-259;BR-259', 'highway': 'primary',
            }),
            dsl.relation(1, {
                'type': 'route', 'route': 'road', 'ref': 'BR-259',
                'network': 'BR', 'source': 'openstreetmap.org',
            }, ways=[31574746]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 31574746,
                'all_shield_texts': ['259', '259'],
                'all_networks': ['BR', 'BR:MG'],
            })
    def test_fr_m_road(self):
        import dsl

        z, x, y = (16, 34078, 23914)

        self.generate_fixtures(
            dsl.is_in('FR', z, x, y),
            # https://www.openstreetmap.org/way/4117272
            dsl.way(
                4117272, dsl.tile_diagonal(z, x, y), {
                    'maxspeed': '70',
                    'bicycle': 'no',
                    'name': 'Promenade Edouard Corniglion-Molinier',
                    'surface': 'asphalt',
                    'source': 'openstreetmap.org',
                    'oneway': 'yes',
                    'ref': 'M 6098',
                    'highway': 'primary',
                }),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 4117272,
            'shield_text': 'M6098',
            'network': 'FR:M-road',
        })
    def test_br_RSC(self):
        import dsl

        z, x, y = (16, 23450, 38314)

        self.generate_fixtures(
            dsl.is_in('BR', z, x, y),
            # https://www.openstreetmap.org/way/25979338
            dsl.way(25979338, dsl.tile_diagonal(z, x, y), {
                'name': 'Rota do Sol', 'surface': 'paved',
                'source': 'openstreetmap.org', 'oneway': 'no',
                'ref': 'RSC-453', 'highway': 'primary',
            }),
            dsl.relation(1, {
                'network': 'BR', 'ref': 'BR-453', 'route': 'road',
                'wikipedia': 'pt:BR-453', 'source': 'openstreetmap.org',
                'wikidata': 'Q2877442', 'type': 'route',
            }, ways=[25979338]),
            dsl.relation(2, {
                'old_ref': 'RST-453', 'name': 'Rota do Sol', 'route': 'road',
                'source:official_name': 'LO 11432/2000', 'type': 'route',
                'official_name': 'Rota do Sol Euclides Triches',
                'source': 'openstreetmap.org', 'ref': 'RSC-453',
                'network': 'BR:RS',
            }, ways=[25979338]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 25979338,
                'shield_text': '453', 'network': 'BR',
                'all_shield_texts': ['453', '453'],
                'all_networks': ['BR', 'BR:RS']
            })
    def test_fr_rnil_road(self):
        import dsl

        z, x, y = (16, 33218, 22520)

        self.generate_fixtures(
            dsl.is_in('FR', z, x, y),
            # https://www.openstreetmap.org/way/10292212
            dsl.way(
                10292212, dsl.tile_diagonal(z, x, y), {
                    'source': 'openstreetmap.org',
                    'old_ref': 'N 2bis;N 2',
                    'ref': 'RNIL 2',
                    'highway': 'primary',
                    'oneway': 'yes',
                }),
            dsl.relation(1, {
                'name': 'RNIL2(FR:93)',
                'ref': 'RNIL 2',
                'route': 'road',
                'source': 'openstreetmap.org',
                'type': 'route',
                'network': 'FR:93:RNIL-road',
            },
                         ways=[10292212]),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 10292212,
            'shield_text': 'N2',
            'network': 'FR:N-road',
        })
    def test_br_SP_many(self):
        import dsl

        z, x, y = (16, 24051, 36887)

        self.generate_fixtures(
            dsl.is_in('BR', z, x, y),
            # https://www.openstreetmap.org/way/258575188
            dsl.way(258575188, dsl.tile_diagonal(z, x, y), {
                'lanes': '1', 'name': 'Rodovia Municipal Domingos Innocentini',
                'wikipedia': 'pt:Rodovia Municipal Domingos Innocentini',
                'surface': 'asphalt', 'source': 'openstreetmap.org',
                'oneway': 'yes', 'ref': 'SPA-149/215;SCA-040',
                'highway': 'primary',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 258575188,
                'shield_text': '149',
                'network': 'BR:SP',
                'all_networks': ['BR:SP', 'BR:SP', 'BR:SP:SCA'],
                'all_shield_texts': ['149', '215', '040'],
            })
    def test_fr_route_nationale(self):
        import dsl

        z, x, y = (16, 33512, 22698)

        self.generate_fixtures(
            dsl.is_in('FR', z, x, y),
            # https://www.openstreetmap.org/way/28470567
            dsl.way(
                28470567, dsl.tile_diagonal(z, x, y), {
                    'maxspeed': '50',
                    'lanes': '2',
                    'name': 'Avenue du 1er Mai',
                    'lit': 'yes',
                    'source': 'openstreetmap.org',
                    'oneway': 'yes',
                    'ref': 'RN 19',
                    'highway': 'primary',
                }),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 28470567,
            'shield_text': 'N19',
            'network': 'FR:N-road',
        })
    def test_jp_national(self):
        import dsl

        z, x, y = (16, 57463, 26016)

        self.generate_fixtures(
            dsl.is_in('JP', z, x, y),
            # https://www.openstreetmap.org/way/242802845
            dsl.way(
                242802845, dsl.tile_diagonal(z, x, y), {
                    'name:en': 'National Route 163',
                    'name': u'\u56fd\u9053163\u53f7',
                    'oneway:bicycle': 'yes',
                    'source': 'openstreetmap.org',
                    'maxspeed': '50',
                    'oneway': 'yes',
                    'ref': '163',
                    'highway': 'trunk',
                    'name:ja': u'\u56fd\u9053163\u53f7',
                }),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 242802845,
            'shield_text': '163',
            'network': 'JP:national',
        })
    def test_fr_d_road_relation(self):
        import dsl

        z, x, y = (16, 33716, 23296)

        self.generate_fixtures(
            dsl.is_in('FR', z, x, y),
            # https://www.openstreetmap.org/way/137943124
            dsl.way(
                137943124, dsl.tile_diagonal(z, x, y), {
                    'source': 'openstreetmap.org',
                    'ref': 'D 17',
                    'highway': 'secondary',
                }),
            dsl.relation(1, {
                'name': 'D17(FR:01)',
                'ref': 'D 17',
                'route': 'road',
                'source': 'openstreetmap.org',
                'type': 'route',
                'network': 'FR:01:D-road',
            },
                         ways=[137943124]),
        )

        self.assert_has_feature(z, x, y, 'roads', {
            'id': 137943124,
            'shield_text': 'D17',
            'network': 'FR:D-road',
        })