def _check_downgrade_poi(self, tags, kind, min_zoom):
        import dsl

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

        full_tags = tags.copy()
        full_tags['source'] = 'openstreetmap.org'

        # test without a name
        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), full_tags),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'kind': kind,
                'min_zoom': min_zoom,
            })

        # and with a name
        full_tags['name'] = 'Some kind of name'
        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), full_tags),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'kind': kind,
                'name': full_tags['name'],
                'min_zoom': lambda z: z < min_zoom,
            })
Beispiel #2
0
    def test_wetland_above_water(self):
        import dsl

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

        self.generate_fixtures(
            dsl.way(
                1, dsl.tile_box(z, x, y), {
                    'natural': 'wetland',
                    'wetland': 'bog',
                    'source': 'openstreetmap.org',
                }),
            dsl.way(2, dsl.tile_box(z, x, y), {
                'natural': 'water',
                'source': 'openstreetmap.org',
            }),
        )

        # set here for convenience, in case we change them later. the exact
        # values aren't as important as the wetland one being more than the
        # water one.
        wetland_rank = 220
        water_rank = 204

        self.assertTrue(wetland_rank > water_rank)
        self.assert_has_feature(z, x, y, 'landuse', {
            'id': 1,
            'kind': 'wetland',
            'sort_rank': wetland_rank,
        })
        self.assert_has_feature(z, x, y, 'water', {
            'id': 2,
            'kind': 'water',
            'sort_rank': water_rank,
        })
Beispiel #3
0
    def _check_downgrade_poi(self, tags, kind, min_zoom):
        import dsl

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

        full_tags = tags.copy()
        full_tags['source'] = 'openstreetmap.org'

        # test without a name
        self.generate_fixtures(dsl.way(1, dsl.tile_box(z, x, y), full_tags), )

        self.assert_has_feature(z, x, y, 'pois', {
            'kind': kind,
            'min_zoom': min_zoom,
        })

        # and with a name
        full_tags['name'] = 'Some kind of name'
        self.generate_fixtures(dsl.way(1, dsl.tile_box(z, x, y), full_tags), )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'kind': kind,
                'name': full_tags['name'],
                'min_zoom': lambda z: z < min_zoom,
            })
    def test_mud_sort_rank(self):
        # Mud landuse should sort above water, below wetland
        import dsl

        z, x, y = (16, 0, 0)
        water_sort_rank = 204
        mud_sort_rank = 219
        wetland_sort_rank = 220

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'natural': 'mud',
                'source': 'openstreetmap.org',
            }),
            dsl.way(2, dsl.tile_box(z, x, y), {
                'natural': 'water',
                'source': 'openstreetmap.org',
            }),
            dsl.way(3, dsl.tile_box(z, x, y), {
                'natural': 'wetland',
                'source': 'openstreetmap.org',
            }),
        )

        # first, check the ordering
        self.assertTrue(water_sort_rank < mud_sort_rank)
        self.assertTrue(mud_sort_rank < wetland_sort_rank)

        # now check features match that
        self.assert_has_feature(
            z, x, y, 'landuse', {
                'id': 1,
                'kind': 'mud',
                'sort_rank': mud_sort_rank,
            })

        self.assert_has_feature(
            z, x, y, 'water', {
                'id': 2,
                'kind': 'water',
                'sort_rank': water_sort_rank,
            })

        self.assert_has_feature(
            z, x, y, 'landuse', {
                'id': 3,
                'kind': 'wetland',
                'sort_rank': wetland_sort_rank,
            })
    def test_backfill_more_important_than_eroad(self):
        import dsl

        # randomly chosen tile with the M4 motorway west of London, GB
        z, x, y = (16, 32680, 21796)

        # although we model these both as "ways", this is really just a way to
        # get geometry into the pipeline. in real usage, the admin_area comes
        # from a static shapefile.
        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y),
                    {'kind': 'admin_area', 'iso_code': 'GB',
                     'source': 'openstreetmap.org'}),
            dsl.way(2, dsl.tile_diagonal(z, x, y),
                    {'highway': 'motorway', 'ref': 'M4',
                     'source': 'openstreetmap.org'}),
            dsl.relation(
                1, {
                    'network': 'e-road',
                    'route': 'road',
                    'ref': 'E 30',
                    'type': 'route',
                },
                ways=[2],
            ),
        )

        # the main network should be GB, not e-road
        self.assert_has_feature(
            z, x, y, 'roads',
            {'id': 2, 'network': 'GB:M-road', 'shield_text': 'M4'})
    def test_post_office(self):
        import dsl

        z, x, y = (14, 2627, 6327)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/28842845
            dsl.way(28842845, dsl.tile_box(z, x, y), {
                'addr:city': 'Berkeley',
                'addr:country': 'US',
                'addr:housenumber': '2000',
                'addr:postcode': '94704',
                'addr:state': 'CA',
                'addr:street': 'Allston Way',
                'amenity': 'post_office',
                'building': 'civic',
                'name': 'Berkeley Main Post Office',
                'opening_hours': 'Mo-Fr 06:00-20:00; Sa 06:00-18:00',
                'source': 'openstreetmap.org',
                'wheelchair': 'yes',
                'wikidata': 'Q16902347',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 28842845,
                'kind': 'post_office',
                'min_zoom': 14,
            })
    def test_post_office_14_way(self):
        import dsl

        z, x, y = (14, 2857, 6541)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/45274545
            dsl.way(45274545, dsl.tile_box(z, x, y), {
                'addr:city': 'San Bernardino',
                'addr:housenumber': '1900',
                'addr:postcode': '92403',
                'addr:state': 'CA',
                'addr:street': 'West Redlands Boulevard',
                'amenity': 'post_office',
                'building': 'yes',
                'name': 'USPS San Bernardino Processing & Distribution Center',
                'operator': 'United States Postal Service',
                'source': 'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 45274545,
                'kind': 'post_office',
                'min_zoom': 14,
            })
    def test_embassy_14_way(self):
        import dsl

        z, x, y = (14, 2808, 6541)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/427270582
            dsl.way(427270582, dsl.tile_box(z, x, y), {
                'amenity': 'embassy',
                'building': 'yes',
                'country': 'ID',
                'diplomatic': 'consulate_general',
                'ele': '94.9',
                'height': '30.1',
                'lacounty:ain': '5502031015',
                'lacounty:bld_id': '470938845107',
                'name': 'Consulat General of the Republic of Indonesia',
                'name:id': 'Konsulat Jenderal Republik Indonesian',
                'source': 'openstreetmap.org',
                'start_date': '1946',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 427270582,
                'kind': 'embassy',
                'min_zoom': 14,
            })
    def test_s_road_not_in_t_relation(self):
        import dsl

        z, x, y = (16, 60607, 37966)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org'
            }),
            # https://www.openstreetmap.org/way/13851986
            dsl.way(13851986, dsl.tile_diagonal(z, x, y), {
                'source': 'openstreetmap.org', 'ref': '31;T8',
                'name': 'Waterworks Road', 'highway': 'primary',
                'surface': 'paved'
            }),
            dsl.relation(1, {
                'network': 'S', 'ref': '31', 'route': 'road',
                'addr:state': 'QLD', 'source': 'openstreetmap.org',
                'type': 'route', 'addr:country': 'AU'
            }, ways=[13851986]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 13851986, 'shield_text': '31', 'network': 'AU:S-route',
                'all_networks': ['AU:S-route', 'AU:T-drive'],
                'all_shield_texts': ['31', '8'],
            })
    def test_s_road_in_both_relations(self):
        import dsl

        z, x, y = (16, 60644, 38056)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org'
            }),
            # https://www.openstreetmap.org/way/240922938
            dsl.way(240922938, dsl.tile_diagonal(z, x, y), {
                'source:name': 'survey', 'maxspeed': '60', 'lanes': '2',
                'name': 'Beaudesert Beenleigh Road',
                'source:maxspeed': 'sign', 'surface': 'asphalt',
                'source': 'openstreetmap.org', 'source:ref': 'survey',
                'ref': '92;T8', 'highway': 'primary', 'network': 'S',
            }),
            dsl.relation(1, {
                'network': 'S', 'ref': '92', 'route': 'road',
                'addr:state': 'QLD', 'source': 'openstreetmap.org',
                'type': 'route', 'addr:country': 'AU',
            }, ways=[240922938]),
            dsl.relation(2, {
                'type': 'route', 'route': 'road', 'ref': '8', 'network': 'T',
                'source': 'openstreetmap.org'
            }, ways=[240922938]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 240922938, 'shield_text': '92', 'network': 'AU:S-route',
                'all_networks': ['AU:S-route', 'AU:T-drive'],
                'all_shield_texts': ['92', '8'],
            })
Beispiel #11
0
    def test_backfill_more_important_than_eroad(self):
        import dsl

        # randomly chosen tile with the M4 motorway west of London, GB
        z, x, y = (16, 32680, 21796)

        # although we model these both as "ways", this is really just a way to
        # get geometry into the pipeline. in real usage, the admin_area comes
        # from a static shapefile.
        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y),
                    {'kind': 'admin_area', 'iso_code': 'GB',
                     'source': 'openstreetmap.org'}),
            dsl.way(2, dsl.tile_diagonal(z, x, y),
                    {'highway': 'motorway', 'ref': 'M4',
                     'source': 'openstreetmap.org'}),
            dsl.relation(
                1, {
                    'network': 'e-road',
                    'route': 'road',
                    'ref': 'E 30',
                    'type': 'route',
                },
                ways=[2],
            ),
        )

        # the main network should be GB, not e-road
        self.assert_has_feature(
            z, x, y, 'roads',
            {'id': 2, 'network': 'GB:M-road', 'shield_text': 'M4'})
Beispiel #12
0
    def test_generative_non_maritime(self):
        import dsl

        z, x, y = (8, 44, 88)

        self.generate_fixtures(
            dsl.way(
                1, dsl.tile_box(z, x, y), {
                    'source': 'tilezen.org',
                    'maritime_boundary': True,
                    'min_zoom': 0,
                    'kind': 'maritime',
                }),
            dsl.way(
                2,
                dsl.tile_diagonal(z, x, y),
                {
                    'source': 'openstreetmap.org',
                    'boundary': 'administrative',
                    'admin_level': '2',
                    'mz_boundary_from_polygon': True,  # need this for hack
                }),
        )

        self.assert_has_feature(z, x, y, 'boundaries', {
            'kind': 'country',
            'maritime_boundary': type(None),
        })
    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_allotments_way(self):
        import dsl

        z, x, y = (16, 32748, 21779)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/32055218
            dsl.way(
                32055218, dsl.tile_box(z, x, y), {
                    'landuse': u'allotments',
                    'name': u'Arvon Road allotments',
                    'source': u'openstreetmap.org',
                }), )

        # should have point in POIs
        self.assert_has_feature(z, x, y, 'pois', {
            'id': 32055218,
            'kind': u'allotments',
            'min_zoom': 16,
        })

        # and polygon in landuse
        self.assert_has_feature(z, x, y, 'landuse', {
            'id': 32055218,
            'kind': u'allotments',
        })
    def test_ring_route(self):
        import dsl

        z, x, y = (16, 58001, 39557)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org',
            }),
            # https://www.openstreetmap.org/way/7795168
            dsl.way(7795168, dsl.tile_diagonal(z, x, y), {
                'maxspeed': '60', 'name': 'Hackney Road', 'surface': 'asphalt',
                'cycleway': 'lane', 'source': 'openstreetmap.org',
                'postal_code': '5069', 'oneway': 'yes', 'ref': 'R1',
                'highway': 'primary',
            }),
            dsl.relation(1, {
                'ref': 'R1', 'route': 'road', 'addr:state': 'SA',
                'source': 'openstreetmap.org', 'type': 'route',
                'addr:country': 'AU'
            }, ways=[7795168]),
        )

        self.assert_has_feature(
            z, x, y, 'roads',
            {'id': 7795168, 'shield_text': '1', 'network': 'AU:R-route'})
    def test_metroad(self):
        import dsl

        z, x, y = (16, 60622, 37990)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org',
            }),
            # https://www.openstreetmap.org/way/463027243
            dsl.way(463027243, dsl.tile_diagonal(z, x, y), {
                'maxspeed': '60', 'lanes': '2', 'name': 'Granard Road',
                'surface': 'asphalt', 'source': 'openstreetmap.org',
                'oneway': 'yes', 'ref': 'MR2', 'highway': 'trunk',
                'network': 'MR',
            }),
            dsl.relation(1, {
                'type': 'route', 'route': 'road', 'ref': '2', 'network': 'MR',
                'source': 'openstreetmap.org',
            }, ways=[463027243]),
        )

        self.assert_has_feature(
            z, x, y, 'roads',
            {'id': 463027243, 'shield_text': '2', 'network': 'AU:Metro-road'})
Beispiel #17
0
    def test_add_country_code_to_road(self):
        import dsl

        # randomly chosen tile with the M4 motorway west of London, GB
        z, x, y = (16, 32680, 21796)

        # although we model these both as "ways", this is really just a way to
        # get geometry into the pipeline. in real usage, the admin_area comes
        # from a static shapefile.
        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y),
                    {'kind': 'admin_area', 'iso_code': 'GB',
                     'source': 'openstreetmap.org'}),
            dsl.way(2, dsl.tile_diagonal(z, x, y),
                    {'highway': 'motorway', 'ref': 'M4',
                     'source': 'openstreetmap.org'}),
        )

        # should have deleted this layer before output.
        with self.layers_in_tile(z, x, y) as layers:
            self.assertNotIn('admin_areas', layers)

        # but should have used it to add a "country_code" parameter to the
        # road.
        self.assert_has_feature(
            z, x, y, 'roads',
            {'id': 2, 'country_code': 'GB', 'network': 'GB:M-road'})
    def test_a_road_in_relation(self):
        import dsl

        z, x, y = (16, 58007, 39547)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org'
            }),
            # https://www.openstreetmap.org/way/582052008
            dsl.way(582052008, dsl.tile_diagonal(z, x, y), {
                'maxspeed': '60', 'lanes': '2', 'name': 'North East Road',
                'surface': 'paved', 'cycleway': 'lane',
                'source': 'openstreetmap.org', 'oneway': 'yes', 'ref': 'A10',
                'highway': 'primary'
            }),
            dsl.relation(1, {
                'type': 'route', 'route': 'road', 'ref': 'A10',
                'addr:country': 'AU', 'addr:state': 'SA',
                'source': 'openstreetmap.org'
            }, ways=[582052008]),
        )

        self.assert_has_feature(
            z, x, y, 'roads',
            {'id': 582052008, 'shield_text': 'A10', 'network': 'AU:A-road',
             'all_networks': ['AU:A-road'], 'all_shield_texts': ['A10']})
    def test_nursing_home_area(self):
        import dsl

        z, x, y = (15, 5237, 12667)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/267296981
            dsl.way(267296981, dsl.tile_box(z, x, y), {
                'addr:city': u'San Francisco',
                'addr:country': u'US',
                'addr:housenumber': u'1575',
                'addr:postcode': u'94122',
                'addr:state': u'CA',
                'addr:street': u'7th Avenue',
                'amenity': u'nursing_home',
                'building': u'yes',
                'height': u'5',
                'name': (u'Kindred Transitional Care and Rehabilitation - '
                         u'Lawton'),
                'phone': u'+1 (415) 566-1200',
                'source': u'openstreetmap.org',
                'website': u'http://www.lawtonhealthcare.com',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 267296981,
                'kind': u'nursing_home',
                'min_zoom': 15,
            })
    def test_s_road_not_in_s_relation(self):
        import dsl

        z, x, y = (16, 60571, 37936)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org'
            }),
            # https://www.openstreetmap.org/way/16477624
            dsl.way(16477624, dsl.tile_diagonal(z, x, y), {
                'source': 'openstreetmap.org', 'ref': '31;T9',
                'name': 'Mount Glorious Road', 'highway': 'secondary'
            }),
            dsl.relation(1, {
                'network': 'T', 'ref': '9', 'route': 'road',
                'addr:state': 'QLD', 'source': 'openstreetmap.org',
                'type': 'route', 'addr:country': 'AU'
            }, ways=[16477624]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 16477624, 'shield_text': '9', 'network': 'AU:T-drive',
                'all_networks': ['AU:T-drive', 'AU'],
                'all_shield_texts': ['9', '31'],
            })
    def test_generative_non_maritime(self):
        import dsl

        z, x, y = (8, 44, 88)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'source': 'tilezen.org',
                'maritime_boundary': True,
                'min_zoom': 0,
                'kind': 'maritime',
            }),
            dsl.way(2, dsl.tile_diagonal(z, x, y), {
                'source': 'openstreetmap.org',
                'boundary': 'administrative',
                'admin_level': '2',
                'mz_boundary_from_polygon': True,  # need this for hack
            }),
        )

        self.assert_has_feature(
            z, x, y, 'boundaries', {
                'kind': 'country',
                'maritime_boundary': type(None),
            })
    def _check(self, props, landuse_zoom, poi_zoom=None, kind=None):
        import dsl

        if kind is None:
            assert len(props) == 1
            kind = props.values()[0]

        if poi_zoom is None:
            poi_zoom = landuse_zoom

        x, y = 0, 0
        tags = {
            'source': 'openstreetmap.org',
            'name': 'Insert Name Here',
        }
        tags.update(props)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(landuse_zoom, x, y), tags),
        )

        self.assert_has_feature(
            landuse_zoom, x, y, 'landuse', {
                'min_zoom': landuse_zoom,
            })
        zdiff = landuse_zoom - poi_zoom
        pcoord = (1 << (zdiff - 1)) - 1 if zdiff > 0 else 0
        self.assert_has_feature(
            poi_zoom, pcoord, pcoord, 'pois', {
                'min_zoom': poi_zoom,
            })
    def test_c_road(self):
        import dsl

        z, x, y = (16, 59435, 40315)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org',
            }),
            # https://www.openstreetmap.org/way/7787334
            dsl.way(7787334, dsl.tile_diagonal(z, x, y), {
                'name': 'Churchill - Traralgon Road', 'surface': 'paved',
                'source': 'openstreetmap.org', 'oneway': 'yes',
                'ref': 'C475;C476', 'highway': 'secondary',
            }),
            dsl.relation(1, {
                'name': 'Mattingley Hill Road', 'ref': 'C475', 'route': 'road',
                'addr:state': 'VIC', 'source': 'openstreetmap.org',
                'type': 'route', 'addr:country': 'AU',
            }, ways=[7787334]),
            dsl.relation(2, {
                'ref': 'C476', 'route': 'road', 'addr:state': 'VIC',
                'source': 'openstreetmap.org', 'type': 'route',
                'addr:country': 'AU',
            }, ways=[7787334]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 7787334, 'shield_text': 'C475', 'network': 'AU:C-road',
                'all_shield_texts': ['C475', 'C476'],
                'all_networks': ['AU:C-road', 'AU:C-road'],
            })
    def test_fire_station_14_way(self):
        import dsl

        z, x, y = (14, 2841, 6539)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/35261044
            dsl.way(35261044, dsl.tile_box(z, x, y), {
                'addr:city': 'Rancho Cucamonga',
                'addr:housenumber': '11297',
                'addr:postcode': '91730',
                'addr:state': 'CA',
                'addr:street': 'Jersey Boulevard',
                'amenity': 'fire_station',
                'name': 'RCFD Jersey Station',
                'ref': '#174',
                'source': 'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 35261044,
                'kind': 'fire_station',
                'min_zoom': 14,
            })
    def test_d_road(self):
        import dsl

        z, x, y = (16, 57903, 38425)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org'
            }),
            # https://www.openstreetmap.org/way/229978585
            dsl.way(229978585, dsl.tile_diagonal(z, x, y), {
                'maxspeed': '80', 'lanes': '2', 'name': 'The Outback Highway',
                'source': 'openstreetmap.org', 'surface': 'paved',
                'name:source': 'data.sa.gov.au roads', 'ref': 'D83',
                'highway': 'secondary',
            }),
            dsl.relation(1, {
                'type': 'route', 'route': 'road', 'ref': 'D83',
                'source': 'openstreetmap.org'
            }, ways=[229978585]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 229978585, 'shield_text': '83', 'network': 'AU',
            })
    def test_fuel_14_way(self):
        import dsl

        z, x, y = (14, 2660, 6284)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/199461228
            dsl.way(199461228, dsl.tile_box(z, x, y), {
                'addr:city': 'Sacramento',
                'addr:housenumber': '2701',
                'addr:postcode': '95833',
                'addr:street': 'Orchard Lane',
                'amenity': 'fuel',
                'landuse': 'commercial',
                'name': 'Arco',
                'source': 'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 199461228,
                'kind': 'fuel',
                'min_zoom': 14,
            })
    def test_m_road(self):
        import dsl

        z, x, y = (16, 60296, 39327)

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'AU',
                'source': 'openstreetmap.org'
            }),
            # https://www.openstreetmap.org/way/3188239
            dsl.way(3188239, dsl.tile_diagonal(z, x, y), {
                'old_ref': '1', 'maxspeed': '60', 'lanes': '2',
                'name': 'Cahill Expressway', 'toll': 'yes',
                'surface': 'asphalt', 'source': 'openstreetmap.org',
                'ref:start_date': '2013-08', 'oneway': 'yes', 'ref': 'M1',
                'highway': 'motorway', 'old_network': 'MR',
            }),
            dsl.relation(1, {
                'ref': 'M1', 'route': 'road', 'addr:state': 'NSW',
                'source': 'openstreetmap.org', 'type': 'route',
                'addr:country': 'AU'
            }, ways=[3188239]),
        )

        self.assert_has_feature(
            z, x, y, 'roads',
            {'id': 3188239, 'shield_text': 'M1', 'network': 'AU:M-road'})
    def test_courthouse_14_way(self):
        import dsl

        z, x, y = (14, 2655, 6395)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/36802788
            dsl.way(36802788, dsl.tile_box(z, x, y), {
                'ALAND': '27250',
                'amenity': 'courthouse',
                'AREAID': '110411442188',
                'AWATER': '0',
                'COUNTYFP': '053',
                'latitude': '+36.6740857',
                'longitude': '-121.6593174',
                'MTFCC': 'K2165',
                'name': 'Salinas Civic Center',
                'source': 'openstreetmap.org',
                'STATEFP': '06',
                'Tiger:MTFCC': 'K2165',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 36802788,
                'kind': 'courthouse',
                'min_zoom': 14,
            })
    def test_allotments_way(self):
        import dsl

        z, x, y = (16, 32748, 21779)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/32055218
            dsl.way(32055218, dsl.tile_box(z, x, y), {
                'landuse': u'allotments',
                'name': u'Arvon Road allotments',
                'source': u'openstreetmap.org',
            }),
        )

        # should have point in POIs
        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 32055218,
                'kind': u'allotments',
                'min_zoom': 16,
            })

        # and polygon in landuse
        self.assert_has_feature(
            z, x, y, 'landuse', {
                'id': 32055218,
                'kind': u'allotments',
            })
Beispiel #30
0
    def test_physiotherapist(self):
        import dsl

        z, x, y = (16, 11428, 26418)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/31815993
            dsl.way(31815993, dsl.tile_box(z, x, y), {
                'addr:city': u'San Diego',
                'addr:country': u'US',
                'addr:housenumber': u'10803',
                'addr:state': u'CA',
                'building': u'yes',
                'building_type': u'industrial',
                'healthcare': u'physiotherapist',
                'name': u'Function Smart Physical Therapy',
                'sangis:OBJECTID': u'9872',
                'sangis:TYPE': u'Industrial',
                'source': u'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 31815993,
                'kind': u'physiotherapist',
            })
    def test_b_road_with_spaces(self):
        import dsl

        z, x, y = (16, 60720, 38212)

        self.generate_fixtures(
            dsl.way(
                1, dsl.tile_box(z, x, y), {
                    'kind': 'admin_area',
                    'iso_code': 'AU',
                    'source': 'openstreetmap.org',
                }),
            # https://www.openstreetmap.org/way/131293316
            dsl.way(
                131293316, dsl.tile_diagonal(z, x, y), {
                    'source:name': 'NSW LPI Base Map',
                    'name': 'Myocum Road',
                    'source:name:date': '2016-02',
                    'surface': 'asphalt',
                    'source:date': '2016-07',
                    'source': 'openstreetmap.org',
                    'oneway': 'yes',
                    'ref': 'B62;T 28;T 30',
                    'highway': 'primary',
                }),
            dsl.relation(1, {
                'ref': 'B62',
                'route': 'road',
                'addr:state': 'NSW',
                'source': 'openstreetmap.org',
                'type': 'route',
                'addr:country': 'AU',
            },
                         ways=[131293316]),
            dsl.relation(2, {
                'type': 'route',
                'route': 'road',
                'ref': '30',
                'network': 'T',
                'source': 'openstreetmap.org',
            },
                         ways=[131293316]),
            dsl.relation(3, {
                'type': 'route',
                'route': 'road',
                'ref': '28',
                'network': 'T',
                'source': 'openstreetmap.org',
            },
                         ways=[131293316]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 131293316,
                'shield_text': '62',
                'network': 'AU:B-road',
                'all_networks': ['AU:B-road', 'AU:T-drive', 'AU:T-drive'],
                'all_shield_texts': ['62', '28', '30'],
            })
    def test_sand_beach_way(self):
        import dsl

        z, x, y = (16, 19335, 24602)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/108403305
            dsl.way(
                108403305, dsl.tile_box(z, x, y), {
                    'ele': u'2',
                    'gnis:feature_id': u'959437',
                    'name': u'Orchard Beach',
                    'natural': u'beach',
                    'source': u'openstreetmap.org',
                    'surface': u'sand',
                    'wikidata': u'Q7100176',
                    'wikipedia': u'en:Orchard Beach, Bronx',
                }), )

        for layer in ('pois', 'landuse'):
            self.assert_has_feature(z, x, y, layer, {
                'id': 108403305,
                'kind': u'beach',
                'kind_detail': u'sand',
            })
    def test_island_should_only_get_one_label_placement(self):
        # island polygon split across multiple tiles shouldn't get a label
        # placement in each tile, only one.
        # Treasure Island, San Francisco
        self.generate_fixtures(
            dsl.way(26767313, dsl.tile_box(14, 2622, 6329), {
                u'name': u'Treasure Island',
                u'way_area': u'2.61873e+06',
                u'wikipedia': u'en:Treasure Island, San Francisco',
                u'name:de': u'Schatzinsel',
                u'source': u'openstreetmap.org',
                u'wikidata': u'Q778565',
                u'place': u'island',
            }))

        self.assert_has_feature(
            14, 2622, 6329, 'earth',
            {'kind': 'island', 'label_placement': True,
             'name': 'Treasure Island'})

        # neighbouring tiles should not have a placement
        for (x, y) in ((2623, 6329), (2622, 6340), (2623, 6340)):
            self.assert_no_matching_feature(
                14, x, y, 'earth',
                {'kind': 'island', 'label_placement': True,
                 'name': 'Treasure Island'})
    def test_cosmetics_way(self):
        import dsl

        z, x, y = (16, 19305, 24637)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/280081650
            dsl.way(
                280081650, dsl.tile_box(z, x, y), {
                    'addr:city': u'Brooklyn',
                    'addr:housenumber': u'95',
                    'addr:postcode': u'11222',
                    'addr:state': u'NY',
                    'addr:street': u'Nassau Avenue',
                    'building': u'yes',
                    'height': u'15.1',
                    'name': u'Ziolko Cosmetics & Herbal',
                    'nycdoitt:bin': u'3322680',
                    'phone': u'718 609 9279',
                    'shop': u'cosmetics',
                    'source': u'openstreetmap.org',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 280081650,
            'kind': u'cosmetics',
        })
    def test_post_office(self):
        import dsl

        z, x, y = (14, 2627, 6327)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/28842845
            dsl.way(
                28842845, dsl.tile_box(z, x, y), {
                    'addr:city': 'Berkeley',
                    'addr:country': 'US',
                    'addr:housenumber': '2000',
                    'addr:postcode': '94704',
                    'addr:state': 'CA',
                    'addr:street': 'Allston Way',
                    'amenity': 'post_office',
                    'building': 'civic',
                    'name': 'Berkeley Main Post Office',
                    'opening_hours': 'Mo-Fr 06:00-20:00; Sa 06:00-18:00',
                    'source': 'openstreetmap.org',
                    'wheelchair': 'yes',
                    'wikidata': 'Q16902347',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 28842845,
            'kind': 'post_office',
            'min_zoom': 14,
        })
    def test_obelisco_macuteo(self):
        import dsl

        z, x, y = (16, 35039, 24352)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/128740184
            dsl.way(128740184, dsl.tile_box(z, x, y), {
                'artwork_type': u'obelisk',
                'height': u'14.52',
                'historic': u'monument',
                'historic:civilization': u'ancient_egyptian',
                'historic:era': u'dynasty_XIX',
                'historic:period': u'new_kingdom',
                'man_made': u'obelisk',
                'name': u'Obelisco Macuteo',
                'obelisk:height': u'6.34',
                'obelisk:material': u'red_granite',
                'obelisk:size': u'monumental',
                'source': u'openstreetmap.org',
                'start_date': u'C13 BC',
                'tourism': u'artwork',
                'wikidata': u'Q3348569',
                'wikipedia': u'it:Obelisco del Pantheon',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 128740184,
                'kind': u'obelisk',
                'min_zoom': 15,
            })
    def test_fishmonger_way(self):
        import dsl

        z, x, y = (16, 19331, 24643)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/283172152
            dsl.way(283172152, dsl.tile_box(z, x, y), {
                'addr:city': u'Jamaica',
                'addr:housenumber': u'91-02',
                'addr:postcode': u'11435',
                'addr:street': u'Sutphin Boulevard',
                'building': u'yes',
                'height': u'10.0',
                'name': u'Corner Fish Market',
                'nycdoitt:bin': u'4213900',
                'shop': u'fishmonger',
                'source': u'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 283172152,
                'kind': u'fishmonger',
            })
    def test_monument_obelisk_way(self):
        import dsl

        z, x, y = (16, 19439, 24108)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/178594567
            dsl.way(178594567, dsl.tile_box(z, x, y), {
                'building': u'yes',
                'height': u'267',
                'historic': u'monument',
                'man_made': u'obelisk',
                'name': u'Bennington Battle Monument',
                'obelisk:size': u'monumental',
                'ref:nrhp': u'71000054',
                'source': u'openstreetmap.org',
                'website': u'http://historicsites.vermont.gov',
                'wikidata': u'Q4889875',
                'wikipedia': u'en:Bennington Battle Monument',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 178594567,
                'kind': u'obelisk',
                'kind_detail': u'monument',
            })
    def test_cafe(self):
        import dsl

        z, x, y = (15, 5241, 12664)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/256045050
            dsl.way(256045050, dsl.tile_box(z, x, y), {
                'addr:city': 'San Francisco',
                'addr:housenumber': '614',
                'addr:street': 'Polk Street',
                'amenity': 'cafe',
                'building': 'yes',
                'height': '21',
                'name': "Emile's Coffee & Tea",
                'source': 'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 256045050,
                'kind': 'cafe',
                'min_zoom': 15,
            })
    def test_fire_station_14_way(self):
        import dsl

        z, x, y = (14, 2841, 6539)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/35261044
            dsl.way(
                35261044, dsl.tile_box(z, x, y), {
                    'addr:city': 'Rancho Cucamonga',
                    'addr:housenumber': '11297',
                    'addr:postcode': '91730',
                    'addr:state': 'CA',
                    'addr:street': 'Jersey Boulevard',
                    'amenity': 'fire_station',
                    'name': 'RCFD Jersey Station',
                    'ref': '#174',
                    'source': 'openstreetmap.org',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 35261044,
            'kind': 'fire_station',
            'min_zoom': 14,
        })
    def test_embassy_14_way(self):
        import dsl

        z, x, y = (14, 2808, 6541)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/427270582
            dsl.way(
                427270582, dsl.tile_box(z, x, y), {
                    'amenity': 'embassy',
                    'building': 'yes',
                    'country': 'ID',
                    'diplomatic': 'consulate_general',
                    'ele': '94.9',
                    'height': '30.1',
                    'lacounty:ain': '5502031015',
                    'lacounty:bld_id': '470938845107',
                    'name': 'Consulat General of the Republic of Indonesia',
                    'name:id': 'Konsulat Jenderal Republik Indonesian',
                    'source': 'openstreetmap.org',
                    'start_date': '1946',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 427270582,
            'kind': 'embassy',
            'min_zoom': 14,
        })
    def test_courthouse_14_way(self):
        import dsl

        z, x, y = (14, 2655, 6395)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/36802788
            dsl.way(
                36802788, dsl.tile_box(z, x, y), {
                    'ALAND': '27250',
                    'amenity': 'courthouse',
                    'AREAID': '110411442188',
                    'AWATER': '0',
                    'COUNTYFP': '053',
                    'latitude': '+36.6740857',
                    'longitude': '-121.6593174',
                    'MTFCC': 'K2165',
                    'name': 'Salinas Civic Center',
                    'source': 'openstreetmap.org',
                    'STATEFP': '06',
                    'Tiger:MTFCC': 'K2165',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 36802788,
            'kind': 'courthouse',
            'min_zoom': 14,
        })
    def test_post_office_14_way(self):
        import dsl

        z, x, y = (14, 2857, 6541)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/45274545
            dsl.way(
                45274545, dsl.tile_box(z, x, y), {
                    'addr:city': 'San Bernardino',
                    'addr:housenumber': '1900',
                    'addr:postcode': '92403',
                    'addr:state': 'CA',
                    'addr:street': 'West Redlands Boulevard',
                    'amenity': 'post_office',
                    'building': 'yes',
                    'name':
                    'USPS San Bernardino Processing & Distribution Center',
                    'operator': 'United States Postal Service',
                    'source': 'openstreetmap.org',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 45274545,
            'kind': 'post_office',
            'min_zoom': 14,
        })
    def test_obelisco_macuteo(self):
        import dsl

        z, x, y = (16, 35039, 24352)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/128740184
            dsl.way(
                128740184, dsl.tile_box(z, x, y), {
                    'artwork_type': u'obelisk',
                    'height': u'14.52',
                    'historic': u'monument',
                    'historic:civilization': u'ancient_egyptian',
                    'historic:era': u'dynasty_XIX',
                    'historic:period': u'new_kingdom',
                    'man_made': u'obelisk',
                    'name': u'Obelisco Macuteo',
                    'obelisk:height': u'6.34',
                    'obelisk:material': u'red_granite',
                    'obelisk:size': u'monumental',
                    'source': u'openstreetmap.org',
                    'start_date': u'C13 BC',
                    'tourism': u'artwork',
                    'wikidata': u'Q3348569',
                    'wikipedia': u'it:Obelisco del Pantheon',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 128740184,
            'kind': u'obelisk',
            'min_zoom': 15,
        })
    def test_monument_obelisk_way(self):
        import dsl

        z, x, y = (16, 19439, 24108)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/178594567
            dsl.way(
                178594567, dsl.tile_box(z, x, y), {
                    'building': u'yes',
                    'height': u'267',
                    'historic': u'monument',
                    'man_made': u'obelisk',
                    'name': u'Bennington Battle Monument',
                    'obelisk:size': u'monumental',
                    'ref:nrhp': u'71000054',
                    'source': u'openstreetmap.org',
                    'website': u'http://historicsites.vermont.gov',
                    'wikidata': u'Q4889875',
                    'wikipedia': u'en:Bennington Battle Monument',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 178594567,
            'kind': u'obelisk',
            'kind_detail': u'monument',
        })
    def test_rocky_beach_way(self):
        import dsl

        z, x, y = (16, 19039, 24855)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/322805403
            dsl.way(
                322805403,
                dsl.tile_box(z, x, y),
                {
                    'access': u'no',
                    'natural': u'beach',
                    'source': u'openstreetmap.org',
                    'surface': u'rocky',
                    # fake name to get the POI to appear
                    'name': 'Fake beach name',
                }), )

        for layer in ('pois', 'landuse'):
            self.assert_has_feature(z, x, y, layer, {
                'id': 322805403,
                'kind': u'beach',
                'kind_detail': u'rocky',
            })
    def test_fishmonger_way(self):
        import dsl

        z, x, y = (16, 19331, 24643)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/283172152
            dsl.way(
                283172152, dsl.tile_box(z, x, y), {
                    'addr:city': u'Jamaica',
                    'addr:housenumber': u'91-02',
                    'addr:postcode': u'11435',
                    'addr:street': u'Sutphin Boulevard',
                    'building': u'yes',
                    'height': u'10.0',
                    'name': u'Corner Fish Market',
                    'nycdoitt:bin': u'4213900',
                    'shop': u'fishmonger',
                    'source': u'openstreetmap.org',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 283172152,
            'kind': u'fishmonger',
        })
    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
    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_sand_beach_way(self):
        import dsl

        z, x, y = (16, 19335, 24602)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/108403305
            dsl.way(108403305, dsl.tile_box(z, x, y), {
                'ele': u'2',
                'gnis:feature_id': u'959437',
                'name': u'Orchard Beach',
                'natural': u'beach',
                'source': u'openstreetmap.org',
                'surface': u'sand',
                'wikidata': u'Q7100176',
                'wikipedia': u'en:Orchard Beach, Bronx',
            }),
        )

        for layer in ('pois', 'landuse'):
            self.assert_has_feature(
                z, x, y, layer, {
                    'id': 108403305,
                    'kind': u'beach',
                    'kind_detail': u'sand',
                })
    def test_s_road_in_zero_relations(self):
        import dsl

        z, x, y = (16, 60644, 38056)

        self.generate_fixtures(
            dsl.way(
                1, dsl.tile_box(z, x, y), {
                    'kind': 'admin_area',
                    'iso_code': 'AU',
                    'source': 'openstreetmap.org'
                }),
            # https://www.openstreetmap.org/way/240922938
            dsl.way(
                240922938, dsl.tile_diagonal(z, x, y), {
                    'source:name': 'survey',
                    'maxspeed': '60',
                    'lanes': '2',
                    'name': 'Beaudesert Beenleigh Road',
                    'source': 'openstreetmap.org',
                    'source:ref': 'survey',
                    'ref': '92;T8',
                    'highway': 'primary',
                    'network': 'S',
                }),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 240922938,
                'shield_text': '92',
                'network': 'AU:S-route',
                'all_networks': ['AU:S-route', 'AU:T-drive'],
                'all_shield_texts': ['92', '8'],
            })
    def test_cosmetics_way(self):
        import dsl

        z, x, y = (16, 19305, 24637)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/280081650
            dsl.way(280081650, dsl.tile_box(z, x, y), {
                'addr:city': u'Brooklyn',
                'addr:housenumber': u'95',
                'addr:postcode': u'11222',
                'addr:state': u'NY',
                'addr:street': u'Nassau Avenue',
                'building': u'yes',
                'height': u'15.1',
                'name': u'Ziolko Cosmetics & Herbal',
                'nycdoitt:bin': u'3322680',
                'phone': u'718 609 9279',
                'shop': u'cosmetics',
                'source': u'openstreetmap.org',
            }),
        )

        self.assert_has_feature(
            z, x, y, 'pois', {
                'id': 280081650,
                'kind': u'cosmetics',
            })
Beispiel #53
0
    def test_mud_sort_rank(self):
        # Mud landuse should sort above water, below wetland
        import dsl

        z, x, y = (16, 0, 0)
        water_sort_rank = 204
        mud_sort_rank = 219
        wetland_sort_rank = 220

        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'natural': 'mud',
                'source': 'openstreetmap.org',
            }),
            dsl.way(2, dsl.tile_box(z, x, y), {
                'natural': 'water',
                'source': 'openstreetmap.org',
            }),
            dsl.way(3, dsl.tile_box(z, x, y), {
                'natural': 'wetland',
                'source': 'openstreetmap.org',
            }),
        )

        # first, check the ordering
        self.assertTrue(water_sort_rank < mud_sort_rank)
        self.assertTrue(mud_sort_rank < wetland_sort_rank)

        # now check features match that
        self.assert_has_feature(z, x, y, 'landuse', {
            'id': 1,
            'kind': 'mud',
            'sort_rank': mud_sort_rank,
        })

        self.assert_has_feature(z, x, y, 'water', {
            'id': 2,
            'kind': 'water',
            'sort_rank': water_sort_rank,
        })

        self.assert_has_feature(z, x, y, 'landuse', {
            'id': 3,
            'kind': 'wetland',
            'sort_rank': wetland_sort_rank,
        })
    def _check(self, tags, kind):
        import dsl

        z, x, y = 16, 0, 0
        tags['source'] = 'openstreetmap.org'
        self.generate_fixtures(dsl.way(1, dsl.tile_box(z, x, y), tags), )
        self.assert_has_feature(z, x, y, 'landuse', {
            'kind': kind,
        })
    def test_sfo(self):
        # SFO should be "international": both the polygon _and_ the POI.
        import dsl

        z, x, y = (13, 1311, 3170)

        self.generate_fixtures(
            # https://www.openstreetmap.org/way/545819287
            dsl.way(
                545819287, dsl.tile_box(z, x, y), {
                    'aerodrome': 'international',
                    'aerodrome:type': 'public',
                    'aeroway': 'aerodrome',
                    'city_served': 'San Francisco, California',
                    'ele': '4',
                    'iata': 'SFO',
                    'icao': 'KSFO',
                    'name': 'San Francisco International Airport',
                    'source': 'openstreetmap.org',
                    'wikidata': 'Q8688',
                    'wikipedia': 'en:San Francisco International Airport',
                }),
            # https://www.openstreetmap.org/way/22567191
            dsl.way(
                22567191, dsl.tile_diagonal(z, x, y), {
                    'aeroway': 'runway',
                    'length': '3618',
                    'ref': '10L/28R',
                    'surface': 'asphalt',
                    'width': '61',
                    'source': 'openstreetmap.org',
                }),
        )

        # POI
        self.assert_has_feature(z, x, y, 'pois', {
            'id': 545819287,
            'kind': 'aerodrome',
            'kind_detail': 'international',
        })

        self.assert_has_feature(z, x, y, 'landuse', {
            'id': 545819287,
            'kind': 'aerodrome',
            'kind_detail': 'international',
        })

        # runway inside polygon
        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 22567191,
                'kind': 'aeroway',
                'kind_detail': 'runway',
                'aerodrome_kind_detail': 'international',
            })
    def test_washington_monument(self):
        import dsl

        z, x, y = (16, 18744, 25072)

        self.generate_fixtures(
            # https://www.openstreetmap.org/relation/3374540
            dsl.way(
                3374540, dsl.tile_box(z, x, y), {
                    "addr:city": "Washington",
                    "addr:housenumber": "1601",
                    "addr:postcode": "20560",
                    "addr:state": "DC",
                    "addr:street": "Independence Avenue",
                    "building": "obelisk",
                    "building:colour": "white",
                    "dcgis:address": "1601 Independence Ave, NW",
                    "dcgis:aid": "294406",
                    "dcgis:gis": "HSE_0015",
                    "dcgis:list_info": "Reg",
                    "dcgis:nr_eligibl": "0",
                    "dcgis:objectid": "259",
                    "dcgis:ssl": "PAR 03160011",
                    "dcgis:update_date": "Wed Feb 01 00:00:00 UTC 2006",
                    "fee": "no",
                    "height": "169.16",
                    "historic": "monument",
                    "landmark": "yes",
                    "man_made": "obelisk",
                    "memorial:type": "obelisk",
                    "name": "Washington Monument",
                    "name:da": u"Washington-monumentet",
                    "name:de": u"Washington-Denkmal",
                    "name:es": u"Monumento a Washington",
                    "name:hu": u"Washington-emlékmű",
                    "name:it": u"Monumento a Washington",
                    "obelisk:size": "monumental",
                    "roof:colour": "white",
                    "roof:height": "16.76",
                    "roof:shape": "pyramidal",
                    "start_date": "1885-02-28",
                    "tourism": "attraction",
                    "type": "multipolygon",
                    "wikidata": "Q178114",
                    "wikipedia": "en:Washington Monument",
                    'source': u'openstreetmap.org',
                }), )

        self.assert_has_feature(z, x, y, 'pois', {
            'id': 3374540,
            'kind': u'obelisk',
            'min_zoom': 14,
        })
    def _check_remap(self, tags, remapped_kind):
        import dsl

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

        all_tags = tags.copy()
        all_tags['source'] = 'openstreetmap.org'

        self.generate_fixtures(dsl.way(1, dsl.tile_box(z, x, y), all_tags), )

        self.assert_has_feature(z, x, y, 'landuse', {
            'kind': remapped_kind,
        })
Beispiel #58
0
    def test_multiple_shields(self):
        import dsl

        z, x, y = 16, 18022, 25522

        # I-77, I-81, US-11 & US-52 all in one road West Virginia.
        self.generate_fixtures(
            dsl.way(1, dsl.tile_box(z, x, y), {
                'kind': 'admin_area', 'iso_code': 'US',
                'source': 'openstreetmap.org'
            }),
            # http://www.openstreetmap.org/way/51388984
            dsl.way(51388984, dsl.tile_diagonal(z, x, y), {
                'horse': 'no', 'maxspeed': '70 mph', 'bicycle': 'no',
                'source': 'openstreetmap.org', 'hgv': 'designated',
                'surface': 'asphalt', 'oneway': 'yes', 'foot': 'no',
                'lanes': '3', 'sidewalk': 'none',
                'ref': 'I 77;I 81;US 11;US 52', 'highway': 'motorway'
            }),
            dsl.relation(1, {
                'name': 'US 11 (VA)', 'type': 'route', 'route': 'road',
                'wikipedia': 'en:U.S. Route 11', 'is_in:state': 'VA',
                'source': 'openstreetmap.org', 'wikidata': 'Q407534',
                'ref': '11', 'network': 'US:US'
            }, ways=[51388984]),
            dsl.relation(2, {
                'name': 'I 77 (VA) (North)', 'type': 'route', 'route': 'road',
                'wikipedia': 'en:Interstate 77 in Virginia',
                'is_in:state': 'VA', 'source': 'openstreetmap.org',
                'wikidata': 'Q2447354', 'ref': '77', 'network': 'US:I'
            }, ways=[51388984]),
            dsl.relation(3, {
                'direction': 'south', 'name': 'I 81 (VA southbound)',
                'type': 'route', 'route': 'road',
                'wikipedia': 'en:Interstate 81 in Virginia',
                'is_in:state': 'VA', 'source': 'openstreetmap.org',
                'wikidata': 'Q2447647', 'ref': '81', 'network': 'US:I'
            }, ways=[51388984]),
            dsl.relation(4, {
                'name': 'US 52 (VA)', 'type': 'route', 'route': 'road',
                'wikipedia': 'en:U.S. Route 52', 'is_in:state': 'VA',
                'source': 'openstreetmap.org', 'ref': '52', 'network': 'US:US'
            }, ways=[51388984]),
        )

        self.assert_has_feature(
            16, 18022, 25522, 'roads',
            {'kind': 'highway', 'network': 'US:I', 'id': 51388984,
             'shield_text': '77',
             'all_networks': ['US:I', 'US:I', 'US:US', 'US:US'],
             'all_shield_texts': ['77', '81', '11', '52']})
    def test_c_road(self):
        import dsl

        z, x, y = (16, 59435, 40315)

        self.generate_fixtures(
            dsl.way(
                1, dsl.tile_box(z, x, y), {
                    'kind': 'admin_area',
                    'iso_code': 'AU',
                    'source': 'openstreetmap.org',
                }),
            # https://www.openstreetmap.org/way/7787334
            dsl.way(
                7787334, dsl.tile_diagonal(z, x, y), {
                    'name': 'Churchill - Traralgon Road',
                    'surface': 'paved',
                    'source': 'openstreetmap.org',
                    'oneway': 'yes',
                    'ref': 'C475;C476',
                    'highway': 'secondary',
                }),
            dsl.relation(1, {
                'name': 'Mattingley Hill Road',
                'ref': 'C475',
                'route': 'road',
                'addr:state': 'VIC',
                'source': 'openstreetmap.org',
                'type': 'route',
                'addr:country': 'AU',
            },
                         ways=[7787334]),
            dsl.relation(2, {
                'ref': 'C476',
                'route': 'road',
                'addr:state': 'VIC',
                'source': 'openstreetmap.org',
                'type': 'route',
                'addr:country': 'AU',
            },
                         ways=[7787334]),
        )

        self.assert_has_feature(
            z, x, y, 'roads', {
                'id': 7787334,
                'shield_text': '475',
                'network': 'AU:C-road',
                'all_shield_texts': ['475', '476'],
                'all_networks': ['AU:C-road', 'AU:C-road'],
            })